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:
+3
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user