1
0
Files
AppSettings-archiver/__init__.py
Clair Delafuente eb98e8a37e Add version to __init__.py
I might be incredibly stupid, if there's any better way to do this because I'm currently referencing it twice which is like.. potentially decoupling.. let me know please ;-;
2025-08-19 02:54:25 -04:00

59 lines
2.2 KiB
Python

import requests
import os
import config
import logging
import sys
import json
__version__ = "1.0.0"
# Load configuration
ROBLOSECURITY = getattr(config, 'roblosecurity', None)
DST_DIR = getattr(config, 'dst_dir', './AppSettings')
LOG_LEVEL = getattr(config, 'log_level', 'INFO')
# Collect AppSettings endpoints
AppSettings = getattr(config, 'CustomTrackedAppSettings', {"PCDesktopClient": "https://clientsettingscdn.roblox.com/v2/settings/application/PCDesktopClient", "MacDesktopClient": "https://clientsettingscdn.roblox.com/v2/settings/application/MacDesktopClient"})
# Prepare logs
if not os.path.exists("logs"):
os.makedirs("logs")
log_format = logging.Formatter(
"[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(log_format)
logfile_handler = logging.FileHandler("logs/appsettings.log", mode="w")
logfile_handler.setFormatter(log_format)
log = logging.getLogger("AppSettings-archiver")
log.setLevel(LOG_LEVEL)
log.addHandler(stdout_handler)
log.addHandler(logfile_handler)
log.info(f"AppSettings-archiver version {__version__} started")
if ROBLOSECURITY is None:
log.warning(f"{"#"*6} ROBLOSECURITY IS NOT SET, SOME FFLAGS MAY BE MISSING {"#"*6}")
if log.level == logging.DEBUG:
log.warning(f"{"#"*6} DEBUG LOGS ENABLED, THIS IS A LITTLE LOUDER {"#"*6}")
os.makedirs(DST_DIR, exist_ok=True)
for AppSetting in AppSettings:
log.debug(f"Attempting to retrieve {AppSetting}")
response = requests.get(AppSettings[AppSetting], headers={"Cookie": f".ROBLOSECURITY={ROBLOSECURITY}"})
if response.status_code == 200:
log.info(f"Successfully retrieved {AppSetting}")
log.debug(f"Response is {len(response.content)/(1<<10):,.0f} kilobytes")
formatted_response = json.dumps(response.json(), indent=4)
log.debug(f"Formatted {AppSetting}")
expected_path = os.path.join(DST_DIR, f"{AppSetting}.json")
with open(expected_path, "w") as f:
f.write(formatted_response)
log.debug(f"Wrote {AppSetting} to {expected_path}")
else:
log.error(f"Failed to retrieve {AppSetting}: {response.status_code}")