diff --git a/various-tools/batch download lister/generation.py b/various-tools/batch download lister/generation.py index 7f9f62e..52fcc1b 100644 --- a/various-tools/batch download lister/generation.py +++ b/various-tools/batch download lister/generation.py @@ -1,21 +1,41 @@ import os import json +import zlib base_dir = os.getcwd() +def file_crc32(filepath): + with open(filepath, "rb") as f: + return zlib.crc32(f.read()) + +# 1. Stage files stage_folder = os.path.join(base_dir, "stage") -stage_files = [f for f in os.listdir(stage_folder) if os.path.isfile(os.path.join(stage_folder, f))] +stage_files = { + f: file_crc32(os.path.join(stage_folder, f)) + for f in os.listdir(stage_folder) + if os.path.isfile(os.path.join(stage_folder, f)) +} with open("download_manifest.json", "w", encoding="utf-8") as f: json.dump(stage_files, f, ensure_ascii=False, indent=2) +# 2. Android audio files (.ogg.zip) audio_folder = os.path.join(base_dir, "audio") -ogg_zip_files = [f for f in os.listdir(audio_folder) if f.endswith(".ogg.zip") and os.path.isfile(os.path.join(audio_folder, f))] +ogg_zip_files = { + f: file_crc32(os.path.join(audio_folder, f)) + for f in os.listdir(audio_folder) + if f.endswith(".ogg.zip") and os.path.isfile(os.path.join(audio_folder, f)) +} with open("download_manifest_android.json", "w", encoding="utf-8") as f: json.dump(ogg_zip_files, f, ensure_ascii=False, indent=2) -m4a_zip_files = [f for f in os.listdir(audio_folder) if f.endswith(".m4a.zip") and os.path.isfile(os.path.join(audio_folder, f))] +# 3. iOS audio files (.m4a.zip) +m4a_zip_files = { + f: file_crc32(os.path.join(audio_folder, f)) + for f in os.listdir(audio_folder) + if f.endswith(".m4a.zip") and os.path.isfile(os.path.join(audio_folder, f)) +} with open("download_manifest_ios.json", "w", encoding="utf-8") as f: json.dump(m4a_zip_files, f, ensure_ascii=False, indent=2) \ No newline at end of file diff --git a/various-tools/batch download lister/readme.txt b/various-tools/batch download lister/readme.txt index 271b7c6..5728367 100644 --- a/various-tools/batch download lister/readme.txt +++ b/various-tools/batch download lister/readme.txt @@ -1,3 +1,7 @@ Since flutter cannot do native zipcrypto and beautifulSoup shenanigans, I opted to pre-compute the list of files that the downloader should take. -Place this script with the `pak` files and run. It will generate 3 json files, one for `common` (stages), one for `android` (ogg), and one for `ios` (m4a). The flutter app will simply query the endpoint and use the list to download. \ No newline at end of file +Place this script with the `pak` files and run. It will generate 3 json files, one for `common` (stages), one for `android` (ogg), and one for `ios` (m4a). + +Move these files to api/config. + +The flutter app will simply query the endpoint and use the list to download. \ No newline at end of file