INNER CODE UNIT · Python
extract_json_from_obtainium_url
ImranR98/apps.obtainium.imranr.dev · scripts/generate_from_url.py:36
def extract_json_from_obtainium_url(url):
"""Extract JSON from the URL."""
raw_json = url.split(APP_URL_PREFIX, 1)[1]
try:
return json.loads(raw_json)
except json.JSONDecodeError:
print(Fore.RED + "Invalid JSON. Please check the URL and try again.")
return None
def validate_app_config(app_config):
"""Check that the payload contains the required keys and a valid package id."""
if not isinstance(app_config, dict):
print(Fore.RED + "Invalid payload: expected a JSON object.")
return False
missing = [key for key in CONFIG_KEYS if not isinstance(app_config.get(key), str) or not app_config[key].strip()]
if missing:
print(Fore.RED + f"Invalid payload: missing or empty keys: {', '.join(missing)}.")