cleanup and refactoring

This commit is contained in:
Richard Macias
2026-02-14 12:59:17 -06:00
parent 75d135035c
commit d4a006158f
7 changed files with 41 additions and 20 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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", "")