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
+24 -3
View File
@@ -824,8 +824,17 @@ class ScrapeSearchWorker(QObject):
def run(self):
found = covers.search_metadata_candidates(self.system, self.query, limit=20, timeout=10)
for r in found:
url = r.get("thumb_url")
r["thumb_bytes"] = covers.download_image(url, timeout=8) if url else None
src = r.get("source")
if src == "openvgdb":
r["thumb_bytes"] = covers.fetch_openvgdb_local(r.get("title") or "")
elif src == "libretro":
data = covers.fetch_libretro_local(r.get("title") or "")
r["thumb_bytes"] = data if data else (
covers.download_image(r.get("thumb_url"), timeout=8) if r.get("thumb_url") else None
)
else:
url = r.get("thumb_url")
r["thumb_bytes"] = covers.download_image(url, timeout=8) if url else None
self.results.emit(found)
self.finished.emit()
@@ -849,6 +858,17 @@ class ScrapeFetchWorker(QObject):
def _scrape_cover(system, candidate, rid, timeout=20):
"""Download the cover for a metadata candidate; returns bytes or None."""
src = candidate.get("source")
title = candidate.get("title") or ""
# Cover repositories ship offline bundles — read them directly (no network).
if src == "openvgdb" and title:
data = covers.fetch_openvgdb_local(title)
if data:
return data
if src == "libretro" and title:
data = covers.fetch_libretro_local(title)
if data:
return data
url = candidate.get("image_url")
if url:
data = covers.download_image(url, timeout)
@@ -858,7 +878,6 @@ def _scrape_cover(system, candidate, rid, timeout=20):
if candidate.get("source") == "igdb":
return covers.compose_game_cover(data)
return data
title = candidate.get("title") or ""
if title:
path = covers.fetch_cover(title, rid, system, timeout=timeout)
if path is not None:
@@ -955,6 +974,8 @@ class ScrapeDialog(QDialog):
icon = QIcon(pm)
year = r.get("year") or (r.get("release_date") or "")[:4]
label = f"{r['title']} ({year})" if year else r["title"]
if r.get("source") not in (None, "igdb", "tmdb"):
label += f" [{r['source']}]"
item = QListWidgetItem(icon, label)
if r.get("overview"):
item.setToolTip(r["overview"])