diff --git a/README.md b/README.md index 717b1c0..d6be3ce 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,10 @@ Options: --help Show this message and exit. Commands: - download-assets Download assets. - download-langs Download localization files. - extract-config Extract bootstrap config from APK file. + download-assets Download assets. + download-langs Download localization files. + download-gamedata Download gamedata. + extract-config Extract bootstrap config from APK file. ``` Install the library using pip @@ -34,6 +35,13 @@ $ dsa-downloader extract-config com.glu.disneygame.apk bootstrap_config file is written to out/bootstrap_config.json. ``` +Download gamedata + +``` +$ dsa-downloader download-gamedata +gamedata-static.bin is written to out/gamedata/9c49b3b7-1479-4c28-8894-d1da716e36ce_gamedata.bin +``` + Download localization files ``` diff --git a/dsa_downloader/cli.py b/dsa_downloader/cli.py index 17b24f2..4006a52 100644 --- a/dsa_downloader/cli.py +++ b/dsa_downloader/cli.py @@ -2,6 +2,7 @@ from dsa_downloader import config_extractor from dsa_downloader import language_downloader from dsa_downloader import asset_processor +from dsa_downloader import gamedata_downloader @click.group() @@ -24,6 +25,15 @@ def extract_config(ctx, path_to_apk, output_path): extractor.bootstrap_extract_config(path_to_apk, output_path) +@cli.command(help='Download gamedata.') +@click.pass_context +@click.argument('path_to_boostrap_config', type=click.Path(exists=True), default='out/bootstrap_config.json') +@click.argument('output_path', type=click.Path(), default='out/gamedata') +def download_gamedata(ctx, path_to_boostrap_config, output_path): + downloader = gamedata_downloader.GamedataDownloader(ctx.obj['DEBUG'], path_to_boostrap_config, output_path) + downloader.download_gamedata() + + @cli.command(help='Download localization files.') @click.pass_context @click.argument('path_to_boostrap_config', type=click.Path(exists=True), default='out/bootstrap_config.json') diff --git a/dsa_downloader/gamedata_downloader.py b/dsa_downloader/gamedata_downloader.py new file mode 100644 index 0000000..8731859 --- /dev/null +++ b/dsa_downloader/gamedata_downloader.py @@ -0,0 +1,21 @@ +import click +import requests +import os +from dsa_downloader import meta + + +class GamedataDownloader: + def __init__(self, debug, bootstrap_file, output_path): + self.debug = debug + self.meta = meta.Meta(bootstrap_file) + self.output_path = output_path + os.makedirs(self.output_path, exist_ok=True) + + def download_gamedata(self): + gamedata_res = requests.get(f'{self.meta.asset_cdn_base_url}/gamedata/{self.meta.gamedata_version}/gamedata-static.bin') + + with open(f"{self.output_path}/{self.meta.gamedata_version}_gamedata.bin", 'wb') as fout: + fout.write(gamedata_res.content) + fout.flush() + fout.close() + click.echo(f"gamedata-static.bin is written to {self.output_path}/{self.meta.gamedata_version}_gamedata.bin") diff --git a/dsa_downloader/meta.py b/dsa_downloader/meta.py index 6705a0d..ed5625e 100644 --- a/dsa_downloader/meta.py +++ b/dsa_downloader/meta.py @@ -20,4 +20,5 @@ def __init__(self, boostrap_file): self.loc_version = res.payload.loc_version self.loc_cdn_base_url = res.payload.loc_cdn_base_url self.asset_cdn_base_url = res.payload.asset_cdn_base_url - self.bundle_version = res.payload.bundle_version \ No newline at end of file + self.bundle_version = res.payload.bundle_version + self.gamedata_version = res.payload.gamedata_version \ No newline at end of file