Skip to content

Commit

Permalink
download gamedata
Browse files Browse the repository at this point in the history
  • Loading branch information
phstudy committed Nov 1, 2021
1 parent 87d2ecb commit f309346
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

```
Expand Down
10 changes: 10 additions & 0 deletions dsa_downloader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')
Expand Down
21 changes: 21 additions & 0 deletions dsa_downloader/gamedata_downloader.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion dsa_downloader/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
self.bundle_version = res.payload.bundle_version
self.gamedata_version = res.payload.gamedata_version

0 comments on commit f309346

Please sign in to comment.