Files
romm/backend/tests/handler/cassettes/test_fastapi/test_scan_rom.yaml
Michael Manganiello b2ea84b5bb misc: Create IGDB service adapter
Add a new service adapter for the IGDB 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.

The API authorization was also improved to not rely on decorating each
method that makes requests, but instead using an `aiohttp` middleware
to automatically add the required headers to each request.

Utils `mark_expanded` and `mark_list_expanded` where added to help
narrow the types of IGDB's expandable fields when we know they are
expanded, for `mypy` type checking.
2025-08-30 20:21:15 -03:00

267 lines
14 KiB
YAML

interactions:
- request:
body: ""
headers:
accept:
- "*/*"
accept-encoding:
- gzip, deflate, br
connection:
- keep-alive
host:
- playmatch.retrorealm.dev
user-agent:
- RomM/development (https://github.com/rommapp/romm)
method: GET
uri: https://playmatch.retrorealm.dev/api/identify/ids?fileName=Paper+Mario+(USA).z64&fileSize=1024
response:
body:
string: !!binary |
CxKAeyJnYW1lTWF0Y2hUeXBlIjoiTm9NYXRjaCIsImlkIjpudWxsfQM=
headers:
Age:
- "81"
CF-RAY:
- 960c3f243a5caaa4-YYZ
Cache-Control:
- max-age=14400
Cf-Cache-Status:
- HIT
Connection:
- keep-alive
Content-Encoding:
- br
Content-Type:
- application/json
Date:
- Thu, 17 Jul 2025 19:46:39 GMT
Last-Modified:
- Thu, 17 Jul 2025 19:45:17 GMT
Nel:
- '{"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}'
Report-To:
- '{"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=mjZ4A7YtYFmLhvxBpW6QPl821crHqZZvQpN%2B8KgRa1zLBnsoeewii%2FWWpbQC7wKBCHw7a818u5WLZOYV60b7as%2Far6YDNSodkqsgt%2BNs4w9z%2F2bhZL22Sw%3D%3D"}]}'
Server:
- cloudflare
Transfer-Encoding:
- chunked
Vary:
- accept-encoding
X-Ratelimit-Limit:
- "20"
X-Ratelimit-Remaining:
- "19"
X-Version:
- 0.2.0
alt-svc:
- h3=":443"; ma=86400
status:
code: 200
message: OK
- request:
body: ""
headers:
accept:
- "*/*"
accept-encoding:
- gzip, deflate, br
connection:
- keep-alive
content-length:
- "0"
host:
- id.twitch.tv
user-agent:
- python-httpx/0.28.1
method: POST
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
response:
body:
string:
'{"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","expires_in":5394139,"token_type":"bearer"}
'
headers:
Access-Control-Allow-Origin:
- "*"
Connection:
- keep-alive
Content-Length:
- "93"
Content-Type:
- application/json
Date:
- Thu, 17 Jul 2025 19:46:40 GMT
Server:
- nginx
X-Ctxlog-Logid:
- 1-6879531f-38f8868819b1d0d937fa2592
status:
code: 200
message: OK
- request:
body:
search "paper mario"; fields id,name,slug,summary,total_rating,aggregated_rating,first_release_date,artworks.url,cover.url,screenshots.url,platforms.id,platforms.name,alternative_names.name,genres.name,franchise.name,franchises.name,collections.name,game_modes.name,involved_companies.company.name,expansions.id,expansions.slug,expansions.name,expansions.cover.url,expanded_games.id,expanded_games.slug,expanded_games.name,expanded_games.cover.url,dlcs.id,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.id,remakes.slug,remakes.name,remakes.cover.url,remasters.id,remasters.slug,remasters.name,remasters.cover.url,ports.id,ports.slug,ports.name,ports.cover.url,similar_games.id,similar_games.slug,similar_games.name,similar_games.cover.url,age_ratings.rating_category,videos.video_id;
where platforms=[4] & game_type=(10,0,11,8,9); limit 200;
headers:
accept:
- application/json
accept-encoding:
- gzip, deflate, br
authorization:
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
client-id:
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
connection:
- keep-alive
content-length:
- "837"
cookie:
- __cf_bm=7H47jGLCD7N0QVnBaGY2mcfCEMpUw5gT4iIyHC98cDI-1752781599-1.0.1.1-jMQsIcVHa.ZTNb4pn4Dz_Go2SV8eitqm2On0YIRpRn6fBle0M6lHqlb7lnTRZfW_fqr.YWC1nDlmEWXC6.LIqVtMGu_CnGWwR5Hui7Y.it8
host:
- api.igdb.com
user-agent:
- python-httpx/0.28.1
method: POST
uri: https://api.igdb.com/v4/games
response:
body:
string:
"[\n {\n \"id\": 3340,\n \"age_ratings\": [\n {\n \
\ \"id\": 49174,\n \"rating_category\": 8\n },\n {\n \
\ \"id\": 50726,\n \"rating_category\": 3\n },\n {\n\
\ \"id\": 82846,\n \"rating_category\": 13\n }\n ],\n\
\ \"aggregated_rating\": 90.0,\n \"alternative_names\": [\n {\n\
\ \"id\": 39105,\n \"name\": \"Zhi Pian Mario\"\n },\n\
\ {\n \"id\": 78718,\n \"name\": \"Mario Story\"\n \
\ },\n {\n \"id\": 51792,\n \"name\": \"\u7EB8\u7247\u9A6C\
\u91CC\u5965\"\n },\n {\n \"id\": 88088,\n \"name\"\
: \"Super Mario RPG 2\"\n },\n {\n \"id\": 119107,\n \
\ \"name\": \"\u7EB8\u7247\u9A6C\u529B\u6B27\"\n }\n ],\n \"\
artworks\": [\n {\n \"id\": 172439,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ar3p1z.jpg\"\
\n },\n {\n \"id\": 172440,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ar3p20.jpg\"\
\n }\n ],\n \"cover\": {\n \"id\": 80830,\n \"url\":\
\ \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n },\n \
\ \"first_release_date\": 965952000,\n \"franchises\": [\n {\n \
\ \"id\": 845,\n \"name\": \"Mario\"\n }\n ],\n \"game_modes\"\
: [\n {\n \"id\": 1,\n \"name\": \"Single player\"\n \
\ }\n ],\n \"genres\": [\n {\n \"id\": 12,\n \"\
name\": \"Role-playing (RPG)\"\n },\n {\n \"id\": 16,\n \
\ \"name\": \"Turn-based strategy (TBS)\"\n },\n {\n \
\ \"id\": 31,\n \"name\": \"Adventure\"\n }\n ],\n \"\
involved_companies\": [\n {\n \"id\": 148214,\n \"company\"\
: {\n \"id\": 70,\n \"name\": \"Nintendo\"\n }\n\
\ },\n {\n \"id\": 225579,\n \"company\": {\n \
\ \"id\": 812,\n \"name\": \"Gradiente\"\n }\n },\n\
\ {\n \"id\": 225578,\n \"company\": {\n \"id\"\
: 5163,\n \"name\": \"iQue\"\n }\n },\n {\n \
\ \"id\": 264416,\n \"company\": {\n \"id\": 25077,\n \
\ \"name\": \"Intelligent Systems\"\n }\n }\n ],\n\
\ \"name\": \"Paper Mario\",\n \"platforms\": [\n {\n \"\
id\": 5,\n \"name\": \"Wii\"\n },\n {\n \"id\": 4,\n\
\ \"name\": \"Nintendo 64\"\n },\n {\n \"id\": 41,\n\
\ \"name\": \"Wii U\"\n }\n ],\n \"screenshots\": [\n \
\ {\n \"id\": 24167,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/a5r3k2lf3lgvifrycqeg.jpg\"\
\n },\n {\n \"id\": 24170,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/jz66se3deczeta6hd4ys.jpg\"\
\n },\n {\n \"id\": 24169,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ig9ainu9fershqdinox1.jpg\"\
\n },\n {\n \"id\": 24168,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/hdxgs9nruycvrzcgvseu.jpg\"\
\n },\n {\n \"id\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\
\n }\n ],\n \"similar_games\": [\n {\n \"id\": 3349,\n\
\ \"cover\": {\n \"id\": 100900,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co25us.jpg\"\
\n },\n \"name\": \"Paper Mario: The Thousand-Year Door\",\n\
\ \"slug\": \"paper-mario-the-thousand-year-door\"\n },\n \
\ {\n \"id\": 1026,\n \"cover\": {\n \"id\": 181427,\n\
\ \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co3vzn.jpg\"\
\n },\n \"name\": \"The Legend of Zelda: A Link to the Past\"\
,\n \"slug\": \"the-legend-of-zelda-a-link-to-the-past\"\n },\n\
\ {\n \"id\": 3351,\n \"cover\": {\n \"id\": 95596,\n\
\ \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co21rg.jpg\"\
\n },\n \"name\": \"Mario \\u0026 Luigi: Superstar Saga\",\n\
\ \"slug\": \"mario-luigi-superstar-saga\"\n },\n {\n \
\ \"id\": 1280,\n \"cover\": {\n \"id\": 311972,\n \
\ \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co6opw.jpg\"\
\n },\n \"name\": \"Breath of Fire IV\",\n \"slug\":\
\ \"breath-of-fire-iv\"\n },\n {\n \"id\": 1035,\n \
\ \"cover\": {\n \"id\": 170804,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co3nsk.jpg\"\
\n },\n \"name\": \"The Legend of Zelda: The Minish Cap\",\n\
\ \"slug\": \"the-legend-of-zelda-the-minish-cap\"\n },\n \
\ {\n \"id\": 358,\n \"cover\": {\n \"id\": 312995,\n\
\ \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co6pib.jpg\"\
\n },\n \"name\": \"Super Mario Bros.\",\n \"slug\":\
\ \"super-mario-bros\"\n },\n {\n \"id\": 2148,\n \
\ \"cover\": {\n \"id\": 93043,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1zsj.jpg\"\
\n },\n \"name\": \"Banjo-Kazooie\",\n \"slug\": \"banjo-kazooie\"\
\n },\n {\n \"id\": 1068,\n \"cover\": {\n \
\ \"id\": 358989,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co7ozx.jpg\"\
\n },\n \"name\": \"Super Mario Bros. 3\",\n \"slug\"\
: \"super-mario-bros-3\"\n },\n {\n \"id\": 660,\n \
\ \"cover\": {\n \"id\": 357155,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co7nkz.jpg\"\
\n },\n \"name\": \"Darkstone\",\n \"slug\": \"darkstone\"\
\n },\n {\n \"id\": 22387,\n \"cover\": {\n \
\ \"id\": 137538,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co2y4i.jpg\"\
\n },\n \"name\": \"Legrand Legacy\",\n \"slug\": \"\
legrand-legacy\"\n }\n ],\n \"slug\": \"paper-mario\",\n \"\
summary\": \"Paper Mario, a turn-based JRPG entry in the Mario franchise with\
\ a paper-based aesthetic and platforming elements, sees the titular character\
\ working his way through the Mushroom Kingdom\\u0027s diverse locales and\
\ biomes, meeting its inhabitants, fighthing unruly enemies and recruiting\
\ an array of companions in order to once again save Princess Peach from the\
\ clutches of the evil Koopa King Bowser.\",\n \"total_rating\": 88.70635880423836,\n\
\ \"videos\": [\n {\n \"id\": 9914,\n \"video_id\":\
\ \"N6k5mCj5WmQ\"\n },\n {\n \"id\": 61010,\n \"video_id\"\
: \"mZU9sbtU0mc\"\n },\n {\n \"id\": 60102,\n \"video_id\"\
: \"D7tB7pzw6sw\"\n },\n {\n \"id\": 60118,\n \"video_id\"\
: \"HskUPFc2DR0\"\n }\n ],\n \"collections\": [\n {\n \
\ \"id\": 593,\n \"name\": \"Paper Mario\"\n },\n {\n\
\ \"id\": 240,\n \"name\": \"Super Mario\"\n }\n ]\n\
\ }\n]"
headers:
CF-RAY:
- 960c3f28caa6a27b-YUL
Connection:
- keep-alive
Content-Encoding:
- br
Content-Type:
- application/json
Date:
- Thu, 17 Jul 2025 19:46:40 GMT
Server:
- cloudflare
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
alt-svc:
- h3=":443"; ma=86400
cf-cache-status:
- DYNAMIC
vary:
- accept-encoding
via:
- 1.1 612d3e065148a94cbbe94139733f662e.cloudfront.net (CloudFront)
x-amz-apigw-id:
- N3ntFGcyvHcEivQ=
x-amz-cf-id:
- AhhPw2CyDjZIqiw2JWPiolw0Atot5UUlzCGdZVhgnuTGw_8mgRle7w==
x-amz-cf-pop:
- YUL62-C2
x-amzn-remapped-content-length:
- "1494"
x-amzn-remapped-date:
- Thu, 17 Jul 2025 19:46:40 GMT
x-amzn-requestid:
- 75543cc0-04cd-4593-ac44-ad380649a3d2
x-cache:
- Miss from cloudfront
x-count:
- "1"
x-pool:
- default
status:
code: 200
message: OK
version: 1