From d4a006158f7a0a6329a99307f06cd50524f02e63 Mon Sep 17 00:00:00 2001 From: Richard Macias Date: Sat, 14 Feb 2026 12:59:17 -0600 Subject: [PATCH] cleanup and refactoring --- README.md | 4 ++-- pages/faq.md | 2 +- pages/init.md | 2 +- scripts/add-app.py | 3 +++ scripts/generate-obtainium-urls.py | 21 +++++++++++++++++---- scripts/generate-table.py | 3 ++- scripts/validate-json.py | 26 +++++++++++++++----------- 7 files changed, 41 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 8dddf27..9c2b2b8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Download and Install the [latest release of Obtainium](https://github.com/ImranR > [!TIP] > This is recommended installation method for beginners and/or new devices -1. On your android emulation device, navigate to the [latest release](https://github.com/RJNY/Obtainium-Emulation-Pack/releases/latest) of the Obainium Emulation Pack. +1. On your android emulation device, navigate to the [latest release](https://github.com/RJNY/Obtainium-Emulation-Pack/releases/latest) of the Obtainium Emulation Pack. 1. Download the file titled `obtainium-emulation-pack-vX.X.X.json` to your device. 1. Open Obtainium. 1. Navigate to Import/Export. @@ -129,7 +129,7 @@ one exists. You can manually add beta/nightly applications by using the links in the README -### How do I updated Obtainium Emulation Pack? +### How do I update Obtainium Emulation Pack? Same as install method. It'll update existing resources. It will not remove any other resources you've added. diff --git a/pages/faq.md b/pages/faq.md index 9a5deff..213b9db 100644 --- a/pages/faq.md +++ b/pages/faq.md @@ -9,7 +9,7 @@ one exists. You can manually add beta/nightly applications by using the links in the README -### How do I updated Obtainium Emulation Pack? +### How do I update Obtainium Emulation Pack? Same as install method. It'll update existing resources. It will not remove any other resources you've added. diff --git a/pages/init.md b/pages/init.md index 1c43f4e..c320c82 100644 --- a/pages/init.md +++ b/pages/init.md @@ -21,7 +21,7 @@ Download and Install the [latest release of Obtainium](https://github.com/ImranR > [!TIP] > This is recommended installation method for beginners and/or new devices -1. On your android emulation device, navigate to the [latest release](https://github.com/RJNY/Obtainium-Emulation-Pack/releases/latest) of the Obainium Emulation Pack. +1. On your android emulation device, navigate to the [latest release](https://github.com/RJNY/Obtainium-Emulation-Pack/releases/latest) of the Obtainium Emulation Pack. 1. Download the file titled `obtainium-emulation-pack-vX.X.X.json` to your device. 1. Open Obtainium. 1. Navigate to Import/Export. diff --git a/scripts/add-app.py b/scripts/add-app.py index c490d04..0d21a9a 100644 --- a/scripts/add-app.py +++ b/scripts/add-app.py @@ -42,6 +42,7 @@ CATEGORIES = [ "Utilities", "PC Emulation", "Streaming", + "Track Only", ] VARIANT_OPTIONS = [ @@ -183,6 +184,8 @@ def generate_app_entry( ) -> dict: """Generate a complete app entry.""" settings = DEFAULT_ADDITIONAL_SETTINGS.copy() + if "Track Only" in categories: + settings["trackOnly"] = True if include_prereleases: settings["includePrereleases"] = True if verify_latest_tag: diff --git a/scripts/generate-obtainium-urls.py b/scripts/generate-obtainium-urls.py index dfbeba6..30f3e0d 100644 --- a/scripts/generate-obtainium-urls.py +++ b/scripts/generate-obtainium-urls.py @@ -5,13 +5,26 @@ import sys import urllib.parse from typing import Any +from constants import OBTAINIUM_SCHEME, REDIRECT_URL + def generate_obtainium_url(app: dict[str, Any]) -> str: """Generate an Obtainium deep-link URL for an app.""" - obtainium_base = "http://apps.obtainium.imranr.dev/redirect.html?r=obtainium://app/" - app_json = json.dumps(app, separators=(",", ":")) - encoded_json = urllib.parse.quote(app_json) - return f"{obtainium_base}{encoded_json}" + payload = { + "id": app["id"], + "url": app["url"], + "author": app["author"], + "name": app["name"], + "otherAssetUrls": app.get("otherAssetUrls"), + "apkUrls": app.get("apkUrls"), + "preferredApkIndex": app.get("preferredApkIndex"), + "additionalSettings": app.get("additionalSettings"), + "categories": app.get("categories"), + "overrideSource": app.get("overrideSource"), + "allowIdChange": app.get("allowIdChange"), + } + encoded = urllib.parse.quote(json.dumps(payload, separators=(",", ":")), safe="") + return f"{REDIRECT_URL}?r={OBTAINIUM_SCHEME}{encoded}" def main(json_file: str) -> None: diff --git a/scripts/generate-table.py b/scripts/generate-table.py index 4bc6dd9..9e07aaf 100644 --- a/scripts/generate-table.py +++ b/scripts/generate-table.py @@ -6,6 +6,7 @@ import urllib.parse from collections import defaultdict from typing import Any +from constants import OBTAINIUM_SCHEME, REDIRECT_URL from utils import get_application_url, get_display_name, should_include_app @@ -25,7 +26,7 @@ def make_obtainium_link(app: dict[str, Any]) -> str: "allowIdChange": app.get("allowIdChange"), } encoded = urllib.parse.quote(json.dumps(payload, separators=(",", ":")), safe="") - return f"http://apps.obtainium.imranr.dev/redirect.html?r=obtainium://app/{encoded}" + return f"{REDIRECT_URL}?r={OBTAINIUM_SCHEME}{encoded}" def generate_category_tables(apps: list[dict[str, Any]]) -> str: diff --git a/scripts/validate-json.py b/scripts/validate-json.py index 88fcba7..9eeee5d 100644 --- a/scripts/validate-json.py +++ b/scripts/validate-json.py @@ -5,6 +5,9 @@ import sys from collections import defaultdict from typing import Any +from constants import VARIANTS +from utils import should_include_app + # Required fields for each app REQUIRED_FIELDS = {"id", "url", "author", "name"} @@ -18,9 +21,6 @@ VALID_META_KEYS = { "includeInDualScreen", } -# Valid variants -VARIANTS = ("standard", "dual-screen") - def validate_app(app: dict[str, Any], index: int) -> list[str]: """Validate a single app entry and return list of errors.""" @@ -49,6 +49,17 @@ def validate_app(app: dict[str, Any], index: int) -> list[str]: if typo in meta: errors.append(f"{app_name}: typo in meta key '{typo}', should be '{correct}'") + # Validate additionalSettings is valid inner JSON + additional_settings = app.get("additionalSettings") + if additional_settings is not None: + if not isinstance(additional_settings, str): + errors.append(f"{app_name}: 'additionalSettings' should be a JSON string") + else: + try: + json.loads(additional_settings) + except json.JSONDecodeError as e: + errors.append(f"{app_name}: 'additionalSettings' contains invalid JSON: {e}") + # Validate categories is a list categories = app.get("categories") if categories is not None and not isinstance(categories, list): @@ -63,14 +74,7 @@ def check_duplicate_ids(apps: list[dict[str, Any]], variant: str) -> list[str]: ids_seen: dict[str, str] = {} for app in apps: - meta = app.get("meta", {}) - - # Skip if excluded from this variant - if meta.get("excludeFromExport", False): - continue - if variant == "standard" and not meta.get("includeInStandard", True): - continue - if variant == "dual-screen" and not meta.get("includeInDualScreen", True): + if not should_include_app(app, variant): continue app_id = app.get("id", "")