Compare commits

...

3 Commits

Author SHA1 Message Date
1caadad664 feat(hsr): begin wrap launcher api
Currently working on /resource endpoint
2023-06-29 22:56:34 +07:00
e6933f067a docs: add some docs 2023-06-29 22:55:53 +07:00
9a52c68326 chore: add Yaagl project link
I forgor
2023-06-26 17:27:08 +07:00
5 changed files with 204 additions and 1 deletions

View File

@ -23,7 +23,7 @@ not be responsible for it. (*Turn-based game* have a ban wave already, see AAGL
This launcher focuses on the API and CLI, for GUI-based launcher you may want to check out:
+ [An Anime Game Launcher](https://aagl.launcher.moe/) - That famous launcher for an open-world anime game.
+ [Yaagl]
+ [Yaagl](https://github.com/3Shain/yet-another-anime-game-launcher) - All in one launcher for MacOS.
+ [Honkers launcher](https://github.com/an-anime-team/honkers-launcher) - Another launcher for an anime game.
+ [Honkers Railway](https://github.com/an-anime-team/the-honkers-railway-launcher) - A launcher for a turn-based anime game.

View File

@ -0,0 +1,178 @@
"""
Class wrapper for API endpoint /resource
"""
class Segment:
path: str
md5: str
# str -> int and checked if int is 0 then None
package_size: int | None
class VoicePack:
"""
Voice pack information
`name` maybe converted from `path` if the server returns empty string.
Attributes:
TODO
"""
language: str
name: str
path: str
# str -> int
size: int
md5: str
# str -> int
package_size: int
class Diff:
"""
Game resource diff from a version to latest information
Attributes:
TODO
"""
name: str
version: str
path: str
# str -> int
size: int
md5: str
is_recommended_update: bool
voice_packs: list[VoicePack]
# str -> int
package_size: int
class Latest:
"""
Latest game resource information
`name` maybe converted from `path` if the server returns empty string,
and if `path` is empty too then it'll convert the name from the first
segment of `segments` list.
Attributes:
TODO
"""
name: str
version: str
path: str
# str -> int
size: int
md5: str
entry: str
voice_packs: list[VoicePack]
# str but checked for empty string
decompressed_path: str | None
segments: list[Segment]
# str -> int
package_size: int
def __init__(
self,
name: str,
version: str,
path: str,
size: int,
md5: str,
entry: str,
voice_packs: list[VoicePack],
decompressed_path: str | None,
segments: list[Segment],
package_size: int,
) -> None:
self.name = name
self.version = version
self.path = path
self.size = size
self.md5 = md5
self.entry = entry
self.voice_packs = voice_packs
self.decompressed_path = decompressed_path
self.segments = segments
self.package_size = package_size
class Game:
latest: Latest
diffs: list[Diff]
class Plugin:
name: str
# str but checked for empty string
version: str | None
path: str
# str -> int
size: int
md5: str
# str but checked for empty string
entry: str | None
# str -> int
package_size: int
class LauncherPlugin:
plugins: list[Plugin]
# str -> int
version: int
class DeprecatedPackage:
name: str
md5: str
class DeprecatedFile:
path: str
# str but checked for empty string
md5: str | None
class Data:
"""
Data class for /resource endpoint
"""
# I'm generous enough to convert the string into int
# for you guys, wtf Mihoyo?
game: Game
# ?? Mihoyo for plugin["plugins"] which is a list of Plugin objects
plugin: LauncherPlugin
web_url: str
# ?? Mihoyo
force_update: None
# Will be a Game object if a pre-download is available.
pre_download_game: Game | None
deprecated_packages: list[DeprecatedPackage]
# Maybe a SDK for Bilibili version in Genshin?
sdk: None
deprecated_files: list[DeprecatedFile]
def __init__(
self,
game: Game,
plugin: Plugin,
web_url: str,
force_update: None,
pre_download_game: Game | None,
deprecated_packages: list[DeprecatedPackage],
sdk: None,
deprecated_files: list[DeprecatedFile],
) -> None:
self.game = game
self.plugin = plugin
self.web_url = web_url
self.force_update = force_update
self.pre_download_game = pre_download_game
self.deprecated_packages = deprecated_packages
self.sdk = sdk
self.deprecated_files = deprecated_files

View File

@ -1,3 +1,25 @@
class LAUNCHER_API:
"""Launcher API constants."""
RESOURCE_PATH: str = "mdk/launcher/api/resource"
OS: dict = {
"url": "https://hkrpg-launcher-static.hoyoverse.com/hkrpg_global/",
"params": {
"channel_id": 1,
"key": "vplOVX8Vn7cwG8yb",
"launcher_id": 35,
},
}
CN: dict = {
"url": "https://api-launcher.mihoyo.com/hkrpg_cn/mdk/launcher/api/resource",
"params": {
"channel_id": 1,
"key": "6KcVuOkbcqjJomjZ",
"launcher_id": 33,
},
}
LATEST_VERSION = (1, 1, 0)
MD5SUMS = {
"1.0.5": {

View File

View File

@ -115,6 +115,9 @@ class Game(GameABC):
Credits to An Anime Team for the code that does the magic:
https://github.com/an-anime-team/anime-game-core/blob/main/src/games/star_rail/game.rs#L49
If the above method fails, it'll fallback to read the config.ini file
for the version. (Doesn't work with AAGL-based launchers)
This returns (0, 0, 0) if the version could not be found
(usually indicates the game is not installed)