cleanup and refactoring
This commit is contained in:
@@ -21,7 +21,7 @@ Download and Install the [latest release of Obtainium](https://github.com/ImranR
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> This is recommended installation method for beginners and/or new devices
|
> 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. Download the file titled `obtainium-emulation-pack-vX.X.X.json` to your device.
|
||||||
1. Open Obtainium.
|
1. Open Obtainium.
|
||||||
1. Navigate to Import/Export.
|
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
|
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.
|
Same as install method. It'll update existing resources.
|
||||||
It will not remove any other resources you've added.
|
It will not remove any other resources you've added.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ one exists.
|
|||||||
|
|
||||||
You can manually add beta/nightly applications by using the links in the README
|
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.
|
Same as install method. It'll update existing resources.
|
||||||
It will not remove any other resources you've added.
|
It will not remove any other resources you've added.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Download and Install the [latest release of Obtainium](https://github.com/ImranR
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> This is recommended installation method for beginners and/or new devices
|
> 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. Download the file titled `obtainium-emulation-pack-vX.X.X.json` to your device.
|
||||||
1. Open Obtainium.
|
1. Open Obtainium.
|
||||||
1. Navigate to Import/Export.
|
1. Navigate to Import/Export.
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ CATEGORIES = [
|
|||||||
"Utilities",
|
"Utilities",
|
||||||
"PC Emulation",
|
"PC Emulation",
|
||||||
"Streaming",
|
"Streaming",
|
||||||
|
"Track Only",
|
||||||
]
|
]
|
||||||
|
|
||||||
VARIANT_OPTIONS = [
|
VARIANT_OPTIONS = [
|
||||||
@@ -183,6 +184,8 @@ def generate_app_entry(
|
|||||||
) -> dict:
|
) -> dict:
|
||||||
"""Generate a complete app entry."""
|
"""Generate a complete app entry."""
|
||||||
settings = DEFAULT_ADDITIONAL_SETTINGS.copy()
|
settings = DEFAULT_ADDITIONAL_SETTINGS.copy()
|
||||||
|
if "Track Only" in categories:
|
||||||
|
settings["trackOnly"] = True
|
||||||
if include_prereleases:
|
if include_prereleases:
|
||||||
settings["includePrereleases"] = True
|
settings["includePrereleases"] = True
|
||||||
if verify_latest_tag:
|
if verify_latest_tag:
|
||||||
|
|||||||
@@ -5,13 +5,26 @@ import sys
|
|||||||
import urllib.parse
|
import urllib.parse
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from constants import OBTAINIUM_SCHEME, REDIRECT_URL
|
||||||
|
|
||||||
|
|
||||||
def generate_obtainium_url(app: dict[str, Any]) -> str:
|
def generate_obtainium_url(app: dict[str, Any]) -> str:
|
||||||
"""Generate an Obtainium deep-link URL for an app."""
|
"""Generate an Obtainium deep-link URL for an app."""
|
||||||
obtainium_base = "http://apps.obtainium.imranr.dev/redirect.html?r=obtainium://app/"
|
payload = {
|
||||||
app_json = json.dumps(app, separators=(",", ":"))
|
"id": app["id"],
|
||||||
encoded_json = urllib.parse.quote(app_json)
|
"url": app["url"],
|
||||||
return f"{obtainium_base}{encoded_json}"
|
"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:
|
def main(json_file: str) -> None:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import urllib.parse
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from constants import OBTAINIUM_SCHEME, REDIRECT_URL
|
||||||
from utils import get_application_url, get_display_name, should_include_app
|
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"),
|
"allowIdChange": app.get("allowIdChange"),
|
||||||
}
|
}
|
||||||
encoded = urllib.parse.quote(json.dumps(payload, separators=(",", ":")), safe="")
|
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:
|
def generate_category_tables(apps: list[dict[str, Any]]) -> str:
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import sys
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from constants import VARIANTS
|
||||||
|
from utils import should_include_app
|
||||||
|
|
||||||
# Required fields for each app
|
# Required fields for each app
|
||||||
REQUIRED_FIELDS = {"id", "url", "author", "name"}
|
REQUIRED_FIELDS = {"id", "url", "author", "name"}
|
||||||
|
|
||||||
@@ -18,9 +21,6 @@ VALID_META_KEYS = {
|
|||||||
"includeInDualScreen",
|
"includeInDualScreen",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Valid variants
|
|
||||||
VARIANTS = ("standard", "dual-screen")
|
|
||||||
|
|
||||||
|
|
||||||
def validate_app(app: dict[str, Any], index: int) -> list[str]:
|
def validate_app(app: dict[str, Any], index: int) -> list[str]:
|
||||||
"""Validate a single app entry and return list of errors."""
|
"""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:
|
if typo in meta:
|
||||||
errors.append(f"{app_name}: typo in meta key '{typo}', should be '{correct}'")
|
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
|
# Validate categories is a list
|
||||||
categories = app.get("categories")
|
categories = app.get("categories")
|
||||||
if categories is not None and not isinstance(categories, list):
|
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] = {}
|
ids_seen: dict[str, str] = {}
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
meta = app.get("meta", {})
|
if not should_include_app(app, variant):
|
||||||
|
|
||||||
# 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):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
app_id = app.get("id", "")
|
app_id = app.get("id", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user