nps: cache TSV lists in data/nps/ instead of the state dir

TSVs live with the other data assets; users can also drop PSP_GAMES.tsv /
PSX_GAMES.tsv there manually to browse offline.
This commit is contained in:
2026-09-07 21:22:43 -04:00
parent 53f671d09a
commit efc8522117
3 changed files with 9 additions and 4 deletions
+3 -3
View File
@@ -36,8 +36,8 @@ def tsv_url(content_type: str, base: str = "") -> str:
return f"{base}/{_TSV_NAMES.get(content_type, _TSV_NAMES['psp'])}"
def _cache_dir() -> Path:
d = config.STATE_DIR / "nps"
def _tsv_dir() -> Path:
d = config.DATA_DIR / "nps"
d.mkdir(parents=True, exist_ok=True)
return d
@@ -110,7 +110,7 @@ def fetch_items(content_type: str, url: str = "", timeout: int = 60) -> List[dic
"""Download (and cache) a TSV, returning parsed item dicts."""
url = url or tsv_url(content_type)
name = _TSV_NAMES.get(content_type, "PSP_GAMES.tsv")
cache = _cache_dir() / name
cache = _tsv_dir() / name
if cache.is_file():
try:
return parse_tsv(cache.read_text(encoding="utf-8", errors="replace"), content_type)