Commit Graph

50 Commits

Author SHA1 Message Date
Georges-Antoine Assi
3b2a9e3043 refactor(scan): share one failure path across the provider lookups
Every gathered provider already resolved through a single loop that logs the
failure, drops the source from the attempted set and falls back to an empty
match. SteamGridDB, which searches on the names the other providers produce and
so cannot join that gather, hand-wrote the same three steps again, and the
search endpoint hand-wrote a third copy. Extract the loop body into
`resolve_fetch` and route SteamGridDB through it.

In the search endpoint the cover gathers now tolerate exceptions instead, so a
failed lookup costs a thumbnail rather than the whole result set. That also
covers Libretro, whose lookup had no guard at all and could fail the request.

On the test side, the platform, rom and `fs_rom` scaffolding was written out
three times across the two scan tests; it now lives in `tests/handler/scan_stubs.py`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 20:58:27 -04:00
Spinnich
24bc4c221b fix(scan): don't let a failed lookup clear the id it couldn't check
A complete rescan clears the id of every source it consulted that came back
empty. That reads an outage as a conclusive miss for the providers that report
a failure as an empty match, so a rescan run while one was down wiped the id it
would otherwise have confirmed, hand-set ones included.

Each of those now reports the failure and leaves the tolerance to the caller,
which is what the gather loop's discard already assumed:

- Pouët, CSDb and Demozoo stop swallowing the 503 their own `_request` raises,
  and Pouët's title search raises it rather than answering "no unique title".
- SteamGridDB and Flashpoint stop catching `Exception` around a whole lookup;
  HLTB stops catching it around its search.
- ScreenScraper answers empty for every remaining ROM once its daily-quota or
  credentials breaker trips, so the scan reads that state off the service and
  drops it from the sources the rescan may clear.

SteamGridDB resolves outside the gather and so needs the discard at its call
site. Search keeps degrading to no thumbnail, since its cover art sits on top
of matches the other providers already produced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 20:49:51 +00:00
Georges-Antoine Assi
2882f9711a Restore DMCA placeholder comment on the grid filter
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:55 -04:00
Georges-Antoine Assi
77925db009 Drop redundant DMCA placeholder comments
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:16 -04:00
Georges-Antoine Assi
6217235c4e Skip DMCA-locked grids when scraping SteamGridDB
SteamGridDB does not remove assets taken down under DMCA; it returns them
with "lock": true and strips the URL signature, so the CDN serves a
placeholder image reading "This asset has been removed in response to a
DMCA takedown notice" for both the full asset and its thumbnail.

Filter locked grids in _get_game_covers, the single funnel for scan
matching, ID lookups and the manual cover picker.

Closes #4003

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:21:00 -04:00
Georges-Antoine Assi
b805f36f26 refactor: extract cover filters into composable, simplify controls
Move the SearchCoverDialog filtering/sorting logic into a
useCoverFilters composable. Drop the "All sources" dropdown (and its
locale key), turn the sort control into a left-floated toggle with a
Relevance/Most votes label, rename the providers-covers key to
metadata-providers, and stop resetting filters on every re-search.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 20:52:18 -04:00
Georges-Antoine Assi
08fa010383 feat: add filters to manual cover search (SteamGridDB)
Adds client-side filters to the v2 manual cover-search dialog so users
can narrow SteamGridDB results without endless scrolling:

- Source (SteamGridDB / each metadata provider)
- Resolution (dynamically built from the results present)
- Style (alternate / blurred / material / no logo / white logo)
- Uploader (searchable list of contributors)
- Content toggles (NSFW / humor / epilepsy, NSFW off by default)
- Sort by relevance or most votes

Backend surfaces the rich per-cover metadata SGDB already returned but
was discarding: SGDBResource / SearchCoverSchema now carry width,
height, style, author, score and content flags, and the cover-search
path fetches every content variant so the picker can toggle them
client-side. Auto-scan cover selection is unchanged and stays
safe-by-default.

New keys translated across all 18 locales.

Closes #3749

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 19:08:01 -04:00
TowyTowy
27a013b1fd fix(scan): make Hasheous and SteamGridDB scan lookups fault-tolerant
HasheousHandler.lookup_rom and SGDBBaseHandler.get_details_by_names now
resolve to an empty match instead of raising, matching the best-effort
pattern already used by PlaymatchHandler.lookup_rom and
SGDBBaseHandler.get_rom_by_id, so one failing provider can't abort a
scan or discard the other providers' results (#2236).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 10:53:00 +02:00
Georges-Antoine Assi
7a5185fe22 complete rest of handler 2025-09-20 19:38:26 -04:00
Georges-Antoine Assi
8c33a95637 remove hartbeat from bh endpoint 2025-09-20 17:57:38 -04:00
Georges-Antoine Assi
3c4113f8a8 Merge branch 'master' into flashpoint-metadata-handler 2025-09-11 21:27:48 -04:00
Georges-Antoine Assi
d7e85ba633 [ROMM-1333] Use metadata tag in filename to match game 2025-09-07 14:12:30 -04:00
Michael Manganiello
d216bad78b misc: Add MetadataHandler's is_enabled method
Convert `MetadataHandler` to an abstract base class and add an
`is_enabled` class method that allows every metadata handler to
independently report whether it is enabled based on its configuration.

This avoids the need for global variables in the config module, allowing
us to change the enabled state of a metadata handler at runtime if
needed.
2025-09-03 22:13:28 -03:00
Georges-Antoine Assi
ef2546ec08 fix base handler filename 2025-08-27 12:40:16 -04:00
Georges-Antoine Assi
d41a920c37 normalize split tiles for ssfr 2025-08-17 20:29:44 -04:00
Georges-Antoine Assi
f0574577c9 Prefer lower IDs when matching games with same title 2025-08-17 19:53:29 -04:00
Georges-Antoine Assi
d005dba90b fix a bunch of shit 2025-08-09 11:16:12 -04:00
Georges-Antoine Assi
659a3eb104 use jaro-winkler algo 2025-08-08 16:54:26 -04:00
Georges-Antoine Assi
1a2944806b Use best-match algo for more providers 2025-08-07 16:57:29 -04:00
Georges-Antoine Assi
f3a74bc892 changes from review 2025-08-07 11:33:02 -04:00
Georges-Antoine Assi
53cf1bdc72 implement real lev distnce 2025-08-06 11:04:24 -04:00
Georges-Antoine Assi
eb6498da61 custom similarity implementation 2025-08-06 10:27:04 -04:00
Georges-Antoine Assi
1d797e286b custom implement mix 2025-08-06 10:21:54 -04:00
Zurdi
5dc82ab7da Merge pull request #2087 from rommapp/fix/fallback-cover-to-provider
fix: SGDB cover fallback
2025-07-16 16:33:50 +02:00
Georges-Antoine Assi
d65463860b skip sgdb if no api key set 2025-07-16 10:14:22 -04:00
zurdi
90c247959e refactor: simplify game cover retrieval logic in SGDBBaseHandler 2025-07-16 13:48:16 +00:00
zurdi
1e3977e80f feat: enhance fuzzy matching in SGDBBaseHandler by implementing Levenshtein distance sorting 2025-07-15 15:10:05 +00:00
zurdi
dbe2566fe8 feat: integrate Levenshtein distance for improved fuzzy matching in SGDBBaseHandler 2025-07-15 09:31:04 +00:00
zurdi
ff3643060c refactor: improve fuzzy matching in SGDBBaseHandler for game search 2025-07-15 09:18:53 +00:00
Georges-Antoine Assi
3781cbdb6b catch json errors on all ends 2025-07-12 19:16:50 -04:00
Georges-Antoine Assi
bdef16e8a7 remove print lines 2025-07-12 16:16:10 -04:00
Georges-Antoine Assi
44caccc0dc search sgdb after getting all game titles 2025-07-12 15:55:20 -04:00
Georges-Antoine Assi
b5a2dc8d37 exclude nsfw and epileptic covers 2025-07-12 12:26:08 -04:00
Georges-Antoine Assi
d349eef42a add options to normalization 2025-07-12 10:48:04 -04:00
Georges-Antoine Assi
c76caed145 normalized search results 2025-07-12 09:56:18 -04:00
Georges-Antoine Assi
862779803a use normalized exact matching 2025-07-11 21:22:05 -04:00
Georges-Antoine Assi
2bd5ff0cac add sgdb to scan page 2025-07-11 18:55:56 -04:00
Georges-Antoine Assi
837d36375d Fix metadata issues in heasheous handler 2025-07-09 09:14:41 -04:00
Michael Manganiello
bf9fb12f91 misc: Create SteamGridDB service adapter
Add a new service adapter for the SteamGridDB API, to separate
concerns with RomM's handler for metadata.

This adapter is agnostic to the handler and only provides methods to
interact with the API, and correctly return typed responses.
2025-06-25 09:42:32 -03:00
zurdi
2a5bf1ab5b Add SGDBInvalidAPIKeyException for handling invalid API key errors 2025-04-01 09:52:33 +00:00
Georges-Antoine Assi
7fafd452ed update sgdb handler 2025-02-24 21:57:14 -05:00
zurdi
a51dd03e1a Added full offline support and configurable logging level and API requests debug logs 2024-11-27 17:12:13 +00:00
Michael Manganiello
7c6dfa8e50 feat: Use ContextVar to share httpx AsyncClient instance between requests 2024-07-23 01:29:32 -03:00
Michael Manganiello
b61bb11bce feat: Use async requests to retrieve SteamGridDB covers
This change avoids blocking requests when retrieving covers from
SteamGridDB, which is the main bottleneck as the current implementation
iterates over paginated results for multiple games.

Using an asynchronous client like `httpx` provides a good performance
improvement, and reduces the latency when calling this endpoint.
Also, the inclusion of FastAPI `lifespan` allows instantiating a single
client on startup.

When testing with "Final Fantasy V Advance", the endpoint goes from ~9s
to ~1.5s to retrieve all covers.
2024-07-09 22:37:14 -03:00
zurdi
f7b14b43d6 fixed everything from trunk 2024-07-09 13:43:14 +02:00
Michael Manganiello
23ef1fb419 fix: Correctly traverse SteamGridDB API pages
The SteamGridDB API has a bug, where the `total` field for the paginated
endpoint `/v2/grids/game/:gameId` sometimes double/triple counts results
(e.g. returning `total=172` when there are actually 86 results).

To avoid this issue, this change relies on each page's number of
results. If the received page has less than the requested amount of
grids, we know that is the last page.
2024-07-07 12:16:30 -03:00
zurdi
a07133d678 added filter for static/animated cover 2024-06-27 16:45:56 +02:00
zurdi
180c373e1e steamgridDB integration added 2024-06-26 17:36:02 +02:00
Georges-Antoine Assi
b2085f87a8 bunch of fixes for trunk 2024-05-21 17:10:11 -04:00
Georges-Antoine Assi
9ad28f3294 more refactoring again 2024-05-05 16:32:40 -04:00