From d81d7d72934716d0fb064919c404361b7128b470 Mon Sep 17 00:00:00 2001 From: KittenTM Date: Wed, 1 Apr 2026 00:09:53 +0200 Subject: [PATCH] feat: support fetching fest yaml alongside rotations big changes in this commit lols... why did i originally design it that way anyway? --- .gitignore | 1 + services/boss_retrieval.py | 95 +++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 06dbf63..2624776 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ __pycache__ .env boss.yaml +fes_boss.yaml node_modules build splatnet_backend.egg-info \ No newline at end of file diff --git a/services/boss_retrieval.py b/services/boss_retrieval.py index 4b98700..54dc664 100644 --- a/services/boss_retrieval.py +++ b/services/boss_retrieval.py @@ -7,57 +7,68 @@ from config import settings, BASE_DIR def process_boss_file(): temp_boss = "bosstemp.bin" - output_yaml = "boss.yaml" decrypt_script = os.path.join(BASE_DIR, "services", "decrypt.js") if not os.path.exists(decrypt_script): print(f"{decrypt_script} is missing!") return False + base_url = settings.boss_url.rstrip('/') + tasks = [ + {"url": f"{base_url}/zvGSM4kOrXpkKnpT/schdat2?c=JP&l=en", "output": "boss.yaml"}, + {"url": f"{base_url}/zvGSM4kOrXpkKnpT/optdat2?c=US&l=en", "output": "fes_boss.yaml"} + ] + try: - base_url = settings.boss_url.rstrip('/') - master_url = f"{base_url}/zvGSM4kOrXpkKnpT/schdat2?c=JP&l=en" - - print(f"data get: {master_url}") - - meta_res = requests.get(master_url, timeout=10) - meta_res.raise_for_status() - root = ET.fromstring(meta_res.content) - data_url_element = root.find(".//Url") - if data_url_element is None or not data_url_element.text: - print("woops! no tag found in the XML response") - return False - real_data_url = data_url_element.text.strip() - print(f"parsed data url: {real_data_url}") - res = requests.get(real_data_url, timeout=10) - res.raise_for_status() - - with open(temp_boss, "wb") as f: - f.write(res.content) + success_all = True + for task in tasks: + master_url = task["url"] + output_yaml = task["output"] - node_env = os.environ.copy() - node_env["BOSS_AES_KEY"] = settings.boss_aes_key - node_env["BOSS_HMAC_KEY"] = settings.boss_hmac_key - - result = subprocess.run( - ['node', decrypt_script, temp_boss], - capture_output=True, - text=False, - env=node_env - ) - - if result.returncode != 0: - print(f"decrypt fail! {result.stderr.decode()}") - return False - - byml_obj = oead.byml.from_binary(result.stdout) - yaml_content = oead.byml.to_text(byml_obj) - - with open(output_yaml, "w", encoding="utf-8") as f: - f.write(yaml_content) + print(f"data get: {master_url}") + meta_res = requests.get(master_url, timeout=10) + meta_res.raise_for_status() + root = ET.fromstring(meta_res.content) + data_url_element = root.find(".//Url") - print(f"yay! success: {output_yaml}") - return True + if data_url_element is None or not data_url_element.text: + print("woops! no tag found in the XML response") + success_all = False + continue + + real_data_url = data_url_element.text.strip() + print(f"parsed data url: {real_data_url}") + res = requests.get(real_data_url, timeout=10) + res.raise_for_status() + + with open(temp_boss, "wb") as f: + f.write(res.content) + + node_env = os.environ.copy() + node_env["BOSS_AES_KEY"] = settings.boss_aes_key + node_env["BOSS_HMAC_KEY"] = settings.boss_hmac_key + + result = subprocess.run( + ['node', decrypt_script, temp_boss], + capture_output=True, + text=False, + env=node_env + ) + + if result.returncode != 0: + print(f"decrypt fail! {result.stderr.decode()}") + success_all = False + continue + + byml_obj = oead.byml.from_binary(result.stdout) + yaml_content = oead.byml.to_text(byml_obj) + + with open(output_yaml, "w", encoding="utf-8") as f: + f.write(yaml_content) + + print(f"yay! success: {output_yaml}") + + return success_all except ET.ParseError: print("woops! the url returned non xml... we're hanging here")