fix: migrate deprecated settings keys. update scripts to track deprecated Obtainium settings

This commit is contained in:
Richard Macias
2026-02-27 23:02:32 -06:00
parent 41a037a7f6
commit 9c9cbe0bc8
7 changed files with 69 additions and 37 deletions

View File

@@ -14,6 +14,7 @@ GITHUB_NOREPLY_SUFFIX = "@users.noreply.github.com"
# ---------------------------------------------------------------------------
# Obtainium source types and settings schema
# Derived from Obtainium source code: lib/app_sources/*.dart
# Reference: ~/code/Obtainium
# ---------------------------------------------------------------------------
# Valid overrideSource values (runtime type names from Obtainium)
@@ -104,11 +105,12 @@ SOURCE_SPECIFIC_KEYS: dict[str, set[str]] = {
"sortMethodChoice",
"useLatestAssetDateAsReleaseDate",
"releaseTitleAsVersion",
"dontSortReleasesList",
"github-creds",
"GHReqPrefix",
},
"GitLab": {
"fallbackToOlderReleases",
"gitlab-creds",
},
"Codeberg": {
# Inherits GitHub's settings
@@ -120,18 +122,38 @@ SOURCE_SPECIFIC_KEYS: dict[str, set[str]] = {
"sortMethodChoice",
"useLatestAssetDateAsReleaseDate",
"releaseTitleAsVersion",
"dontSortReleasesList",
},
"FDroid": {
"filterVersionsByRegEx",
"trySelectingSuggestedVersionCode",
"autoSelectHighestVersionCode",
},
"IzzyOnDroid": {
# Inherits FDroid's settings
"filterVersionsByRegEx",
"trySelectingSuggestedVersionCode",
"autoSelectHighestVersionCode",
},
"FDroidRepo": {
"appIdOrName",
"pickHighestVersionCode",
"trySelectingSuggestedVersionCode",
},
"SourceHut": {
"fallbackToOlderReleases",
},
"APKPure": {
"fallbackToOlderReleases",
"stayOneVersionBehind",
"useFirstApkOfVersion",
},
"APKMirror": {
"fallbackToOlderReleases",
"filterReleaseTitlesByRegEx",
},
"Farsroid": {
"useFirstApkOfVersion",
},
"HTML": {
"intermediateLink",
"customLinkFilterRegex",
@@ -143,21 +165,23 @@ SOURCE_SPECIFIC_KEYS: dict[str, set[str]] = {
"versionExtractWholePage",
"requestHeader",
"defaultPseudoVersioningMethod",
"supportFixedAPKURL",
"sortByFileNamesNotLinks",
},
"DirectAPKLink": {
"intermediateLink",
"customLinkFilterRegex",
"filterByLinkText",
"skipSort",
"reverseSort",
"sortByLastLinkSegment",
"requestHeader",
"defaultPseudoVersioningMethod",
},
}
# Deprecated keys still accepted for backward compatibility.
# Obtainium auto-migrates these on load (see appJSONCompatibilityModifiers
# in lib/providers/source_provider.dart). New configs should use the
# replacement key instead.
DEPRECATED_SETTINGS_KEYS: dict[str, str] = {
"dontSortReleasesList": "sortMethodChoice",
"supportFixedAPKURL": "defaultPseudoVersioningMethod",
"sortByFileNamesNotLinks": "sortByLastLinkSegment",
}
# Settings keys that contain regex patterns (should be validated)
REGEX_SETTINGS_KEYS = {
"apkFilterRegEx",

View File

@@ -8,6 +8,7 @@ from urllib.parse import urlparse
from constants import (
COMMON_SETTINGS_KEYS,
DEPRECATED_SETTINGS_KEYS,
REGEX_SETTINGS_KEYS,
SOURCE_HOST_MAP,
SOURCE_SPECIFIC_KEYS,
@@ -57,7 +58,7 @@ def _detect_source_from_url(url: str) -> str | None:
def _valid_keys_for_source(source: str | None) -> set[str]:
valid = set(COMMON_SETTINGS_KEYS)
valid = set(COMMON_SETTINGS_KEYS) | set(DEPRECATED_SETTINGS_KEYS)
if source and source in SOURCE_SPECIFIC_KEYS:
valid |= SOURCE_SPECIFIC_KEYS[source]
return valid
@@ -184,6 +185,13 @@ def _validate_additional_settings(
if err:
errors.append(err)
# Warn on deprecated keys
for key, replacement in DEPRECATED_SETTINGS_KEYS.items():
if key in settings:
warnings.append(
f"{app_name}: deprecated key '{key}', use '{replacement}' instead"
)
# Check for source-inappropriate keys
url = app.get("url", "")
effective_source = app.get("overrideSource") or _detect_source_from_url(url)