16 Commits

Author SHA1 Message Date
Sam Dornan
6735a318e6 refactor(metadata): share heartbeats, filename id tags and the Moby rom builder (#5134) 2026-10-04 17:01:39 -04:00
Sam Dornan
97c6a29170 refactor(metadata): share provider request retries and error mapping (#5132) 2026-10-04 16:44:54 -04:00
Sam Dornan
c1c3058499 fix(metadata): four provider fixes; test Hasheous, TGDB, CSDb, gamelist and libretro (#5128) 2026-10-04 15:39:48 -04:00
Sam Dornan
9e4b080403 fix(metadata): one UTC helper for release dates, a lint rule against local-time parsing, and Flashpoint tests (#5114) 2026-10-04 11:47:54 -04:00
Sam Dornan
3206bc541f chore(deps): move from httpx to httpx2 (#4830) 2026-09-26 21:17:13 -04:00
Sam Dornan
3679c42732 chore(mypy): report untyped imports instead of disabling the check (#4828) 2026-09-26 20:41:04 -04:00
Sam Dornan
7c2b049b70 chore(mypy): drop warn_return_any and validate provider responses with strict JSON (#4826) 2026-09-26 20:13:55 -04:00
Sam Dornan
4ffc7c5ce1 style: apply the formatting requires-python already implies (#4638) 2026-09-19 12:33:45 -04:00
Georges-Antoine Assi
6dd3353855 refactor(metadata): give the unreachable-provider error one home
The same 503 was built inline at seven sites across the metadata handlers, and
the previous commits added two more copies of it as per-handler `_unavailable`
helpers. `base_handler.unavailable(provider)` now builds it for all of them.

Also renames the search endpoint's cover filter to say what it does and types
the scan test's lookup factory.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 21:16:07 -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
45c8a1057f fix(metadata): guard every scene id parse against the int() digit limit
CPython's int() raises past 4300 digits. The bare-digit branch of
scene_id_or_none already caught that, but the URL parsers, the filename
tag extractors and the Pouet 302 Location parser all called int() on an
unbounded (\d+) capture, so a pasted URL or a scanned filename carrying a
long digit run surfaced as a 500.

Promote pouet_handler's private _int_or_none to utils.int_or_none, next
to valid_youtube_id, and route every scene id conversion through it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 21:23:49 -04:00
Georges-Antoine Assi
afd8b1007d refactor(metadata): move scene_id_or_none into the metadata package
The helper lived in the roms endpoint and reached back into the three scene
handlers through deferred imports. handler.metadata already imports all three
eagerly, so it can own the helper outright and drop the workaround; the branch
chain over `kind` becomes a lookup table. Its test moves beside the other
metadata tests.

Also drop the issue references from the provider docstrings, the config
comments, and the outbound User-Agent headers, which now match the
`RomM/{version}` form the other handlers already send.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 20:59:11 -04:00
Georges-Antoine Assi
f353f3c1fe fix(metadata): cap every provider read and validate embedded video ids
Move the response cap onto MetadataHandler as _fetch_capped and route
Demozoo, Pouet, and CSDb through it. Only CSDb was capped before, while
Demozoo and Pouet read an unbounded body into memory before decoding it.
Pouet's title search now streams too: an ambiguous title answers 200 with
HTML we never parse, but the body was still being buffered.

Validate youtube_video_id where it is read rather than where Demozoo
parses it. The four metadata blobs it reads from are writable through the
raw_*_metadata form fields, so the id reaching the embed URL never had to
come from a provider, and IGDB and LaunchBox never checked it at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 21:15:50 -04:00
Georges-Antoine Assi
1ae540004a refactor(metadata): tidy the scene hardening pass
Accumulate the capped CSDb read in a bytearray, dropping the separate
chunk list and byte counter.

Move the non-string coercion into http_url() so all five call sites can
pass a raw JSON value.

Prove the cap abandons a body mid-stream: the oversized response is now
an endless generator, so the test hangs if the read is not cut short.
Stub the rate limiter it shares with the rest of the suite.

Collapse the duplicated demozoo_url cases into one parametrized test and
fold the malformed-XML assert into the existing parse test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 21:03:27 -04:00
Georges-Antoine Assi
c0d01c58ee fix(metadata): harden the scene metadata handlers
Security review follow-ups on the Demozoo, Pouet, and CSDb handlers.

Default the three sources to off, matching every other provider. They
were the only ones defaulting to on, so an upgrade began contacting
demozoo.org, pouet.net, and csdb.dk on the next scan with no operator
opt-in, reachable through the unauthenticated metadata heartbeat.

Guard the bare id conversion in scene_id_or_none. str.isdigit() accepts
superscripts and other digits int() rejects, so a pasted "²" raised out
of the Edit ROM endpoint as a 500.

Filter the remote demozoo_url through http_url(). It was the only one of
the three URL fields taking a string from the API rather than building
one from a hardcoded template and an integer id.

Match a YouTube id against an explicit ASCII class. isalnum() is
Unicode-aware, so it accepted ids the embed URL never can.

Stream the CSDb response against a byte budget. The cap ran after the
whole body was already buffered, so it bounded the parse but not memory.

Catch defusedxml's refusals. EntitiesForbidden derives from ValueError
and ParseError from SyntaxError, so the existing handler caught neither
and an entity-declaring document raised out of production_from_xml.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 20:49:14 -04:00
Axel Quack
45bcb2bed3 feat(metadata): add Demozoo, Pouët, and CSDb handlers
Identify demoscene productions as ROMs via filename tags, Edit-ROM
id/URL paste, Demozoo ?title= + rank, unique Pouët search.php 302,
and CSDb XML by id (no HTML scrape). Scene ids lock name/summary/cover
so game catalogs cannot attach a similarly titled box.

CSDb XML is parsed with defusedxml and capped; screenshot and extra
links are stored only when they are http(s).

Fixes rommapp/romm#1796 (Phase 0–2).
2026-08-17 08:59:54 +01:00