diff --git a/README.md b/README.md index 8159d2f..9bfd3aa 100644 --- a/README.md +++ b/README.md @@ -4,34 +4,59 @@ DSA Downloader is a Disney Sorcerer's Arena resources downloader, which allow developers to download localization files and assets. ## How to use -Installing the library using pip: + +Show supported commands + +``` +$ dsa-downloader --help +Usage: dsa-downloader [OPTIONS] COMMAND [ARGS]... + +Options: + --debug / --no-debug + --help Show this message and exit. + +Commands: + download-assets Download assets. + download-langs Download localization files. + extract-config Extract bootstrap config from APK file. +``` + +Install the library using pip ``` -$ pip install dsa-downloader +$ pip install dsa-downloader -U ``` -Extracting bootstrap config from apk +Extract bootstrap config from *APK* file ``` $ dsa-downloader extract-config com.glu.disneygame.apk +bootstrap_config file is written to out/bootstrap_config.json. ``` -Downloading localization files +Download localization files ``` $ dsa-downloader download-langs --langs ChineseTraditional --langs English +ChineseTraditional localization file is written to out/langs/Loc_ChineseTraditional.txt. +ChineseTraditional localization file is written to out/langs/Loc_ChineseTraditional.json. +English localization file is written to out/langs/Loc_English.txt. +English localization file is written to out/langs/Loc_English.json. ``` -Downloading assets +Download assets ``` $ dsa-downloader download-assets + 2%|██▋ | 81/3896 [00:03<03:00, 21.08it/s] ``` ## Docker -Extracting bootstrap config from apk +Use docker container to extract bootstrap config from *APK* file ``` -docker run -it --rm -v "$PWD":/dsa study/dsa-downloader dsa-downloader extract-config com.glu.disneygame.apk +$ docker run --rm -v "$PWD":/dsa study/dsa-downloader dsa-downloader \ + extract-config com.glu.disneygame.apk +bootstrap_config file is written to out/bootstrap_config.json. ``` \ No newline at end of file diff --git a/dsa_downloader/asset_processor.py b/dsa_downloader/asset_processor.py index f6bf5d2..37f1a54 100644 --- a/dsa_downloader/asset_processor.py +++ b/dsa_downloader/asset_processor.py @@ -1,3 +1,4 @@ +import click import UnityPy import requests import os diff --git a/dsa_downloader/cli.py b/dsa_downloader/cli.py index 468dafa..17b24f2 100644 --- a/dsa_downloader/cli.py +++ b/dsa_downloader/cli.py @@ -15,7 +15,7 @@ def cli(ctx, debug): ctx.obj['DEBUG'] = debug -@cli.command() +@cli.command(help='Extract bootstrap config from APK file.') @click.pass_context @click.argument('path_to_apk', type=click.Path(exists=True)) @click.argument('output_path', type=click.Path(dir_okay=False), default='out/bootstrap_config.json') @@ -24,14 +24,14 @@ def extract_config(ctx, path_to_apk, output_path): extractor.bootstrap_extract_config(path_to_apk, output_path) -@cli.command() +@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') @click.argument('output_path', type=click.Path(), default='out/langs') @click.option('--langs', type=click.Choice( ["ChineseTraditional", "ChineseSimplified", "English", "French", "German", "Italian", "Japanese", "Korean", "PortugueseBrazilian", "Russian", "Spanish"], case_sensitive=False), default=["English"], - multiple=True) + multiple=True, help="Languages to be extracted.") def download_langs(ctx, path_to_boostrap_config, output_path, langs): lang_downloader = language_downloader.LanguageDownloader(ctx.obj['DEBUG'], path_to_boostrap_config, output_path) @@ -39,13 +39,15 @@ def download_langs(ctx, path_to_boostrap_config, output_path, langs): lang_downloader.download_lang(lang) -@cli.command() +@cli.command(help='Download assets.') @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/assets') @click.argument('extracted_path', type=click.Path(), default='out/assets_extracted') -@click.option('--extract_asset', type=click.BOOL, default=True) -@click.option('--threads', type=click.INT, default=10) +@click.option('--extract-asset', type=click.BOOL, default=True, + help="Flag to turn on/off asset extraction.") +@click.option('--threads', type=click.INT, default=10, + help="Threads count to download/extract assets.", metavar='') def download_assets(ctx, path_to_boostrap_config, output_path, extract_asset, extracted_path, threads): handler = asset_processor.AssetHandler(ctx.obj['DEBUG'], path_to_boostrap_config, output_path, extracted_path, threads) diff --git a/dsa_downloader/config_extractor.py b/dsa_downloader/config_extractor.py index 0a2a689..5b7040b 100644 --- a/dsa_downloader/config_extractor.py +++ b/dsa_downloader/config_extractor.py @@ -18,11 +18,11 @@ def bootstrap_extract_config(self, apk_path, output_path): data = obj.read() if data.name == "bootstrap_config": if self.debug: - click.echo("bootstrap_config was found") + click.echo("bootstrap_config is found") click.echo("try to extract bootstrap_config") output_file = open(output_path, 'w') output_file.write(data.text) output_file.flush() output_file.close() - click.echo(f"bootstrap_config was extracted to {output_path}") + click.echo(f"bootstrap_config file is written to {output_path}.") exit(0) diff --git a/dsa_downloader/language_downloader.py b/dsa_downloader/language_downloader.py index b2f8f59..bcc20af 100644 --- a/dsa_downloader/language_downloader.py +++ b/dsa_downloader/language_downloader.py @@ -1,3 +1,4 @@ +import click import requests import json import os @@ -12,7 +13,6 @@ def __init__(self, debug, bootstrap_file, output_path): os.makedirs(output_path, exist_ok=True) def download_lang(self, lang): - print(f'Downloading Loc_{lang}...') loc_res = requests.get(f'{self.meta.loc_cdn_base_url}/localization/{self.meta.loc_version}/Loc_{lang}.txt') loc_res.encoding = 'utf-8' @@ -20,6 +20,7 @@ def download_lang(self, lang): fout.write(loc_res.text) fout.flush() fout.close() + click.echo(f"{lang} localization file is written to {self.output_path}/Loc_{lang}.txt.") with open(f'{self.output_path}/Loc_{lang}.json', 'w', encoding='utf8') as fout: rst = dict() @@ -31,3 +32,4 @@ def download_lang(self, lang): rst[words[0]] = '' json_dumps_str = json.dumps(rst, sort_keys=True, ensure_ascii=False, indent=2) print(json_dumps_str, file=fout) + click.echo(f"{lang} localization file is written to {self.output_path}/Loc_{lang}.json.") diff --git a/setup.cfg b/setup.cfg index 30fda56..4a959b0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,9 @@ [metadata] name = dsa-downloader url = https://github.com/phstudy/dsa-downloader -description_file = README.md description = Disney Sorcerer's Arena resources downloader +long_description = file: README.md +long_description_content_type = text/markdown author = Study Hsueh author_email = ph.study@gmail.com maintainer = Study Hsueh