Polish settings, add matching defaults, drop pkg2zip, externalize infra config
- Rework Settings tab into grouped sections - Add preferred-region matching and full-hash-by-default setting - Replace combo-box square arrow with a proper chevron - Fix UMD Refresh button (clicked bool was clearing the view) - Remove pkg2zip.exe fallback (pure-Python decryptor is the primary path) - Move LAN IP/share paths to .env; use example defaults in config
This commit is contained in:
+35
-1
@@ -111,6 +111,36 @@ def normalize_name(name):
|
||||
return _normalize(name)
|
||||
|
||||
|
||||
_EUROPEAN_REGIONS = {
|
||||
"europe", "germany", "france", "spain", "italy", "russia", "netherlands",
|
||||
"portugal", "poland", "united kingdom", "greece", "norway", "sweden",
|
||||
"denmark", "finland", "austria", "belgium", "switzerland",
|
||||
}
|
||||
|
||||
|
||||
def region_matches(region, prefer):
|
||||
"""True if ``region`` satisfies the user's preferred-region hint."""
|
||||
if not prefer or not region:
|
||||
return False
|
||||
tokens = {t.strip().lower() for t in str(region).split(",") if t.strip()}
|
||||
if not tokens:
|
||||
return False
|
||||
prefer = prefer.strip().lower()
|
||||
if prefer in tokens:
|
||||
return True
|
||||
if prefer == "europe":
|
||||
return bool(tokens & _EUROPEAN_REGIONS)
|
||||
return False
|
||||
|
||||
|
||||
def apply_region_preference(candidates, prefer):
|
||||
"""Narrow ``candidates`` to the preferred region (fall back to all)."""
|
||||
if not prefer:
|
||||
return candidates
|
||||
filtered = [c for c in candidates if region_matches(c.get("region"), prefer)]
|
||||
return filtered or candidates
|
||||
|
||||
|
||||
def serial_candidates(conn, record):
|
||||
"""Return all catalog releases matching the disc's serial (size-narrowed)."""
|
||||
serial = record.get("serial")
|
||||
@@ -131,7 +161,7 @@ def serial_candidates(conn, record):
|
||||
return _narrow(conn, [dict(r) for r in rows], record.get("size"))
|
||||
|
||||
|
||||
def match(conn, record):
|
||||
def match(conn, record, prefer_region=None):
|
||||
size = record.get("size")
|
||||
|
||||
# 1. Hash is the most precise key; serials are shared across revisions.
|
||||
@@ -171,6 +201,10 @@ def match(conn, record):
|
||||
for cand in candidates:
|
||||
if cand["id"] == saved["release_id"]:
|
||||
return "choice", cand
|
||||
if prefer_region:
|
||||
filtered = [c for c in candidates if region_matches(c.get("region"), prefer_region)]
|
||||
if len(filtered) == 1:
|
||||
return "region", filtered[0]
|
||||
return "unknown", None
|
||||
|
||||
# 4. Fuzzy fallback (filename + PARAM.SFO title), size-disambiguated.
|
||||
|
||||
Reference in New Issue
Block a user