Scrape: include libretro + OpenVGDB covers alongside IGDB

This commit is contained in:
2026-09-07 16:20:39 -04:00
parent 743d5e8e90
commit 5d619e5f59
4 changed files with 137 additions and 17 deletions
+15
View File
@@ -17,6 +17,7 @@ tags removed). The GUI reads this bundle with no network access.
"""
import argparse
import concurrent.futures
import json
import logging
import os
import re
@@ -94,6 +95,19 @@ def build_index(sqlite_path):
return best
def write_index(index, path=None):
"""Persist {key: {"title", "url"}} so the GUI can show readable titles when
searching the offline bundle (see covers._search_openvgdb)."""
path = Path(path) if path else (config.COVERS_DIR / "openvgdb-index.json")
data = {k: {"title": t, "url": u} for k, (t, u, _r) in index.items()}
try:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
except OSError as exc: # noqa: BLE001
log.warning("could not write index %s: %s", path, exc)
return path
def _existing_keys():
"""Titles already present in the bundle (for resume)."""
if not BUNDLE.exists():
@@ -152,6 +166,7 @@ def scrape(limit=None, workers=8, rate=3.0):
index = build_index(sqlite_path)
log.info("indexed %d unique PSP covers", len(index))
write_index(index)
existing = _existing_keys()
todo = [(k, v) for k, v in sorted(index.items()) if k not in existing]