Repository navigation
feat(games): find a game's cover on IGDB - #183
Merged
Merged
Conversation
The games service will show each game's cover from IGDB (decision 68). This adds its IGDB client: Cover searches for the title among main games, expansions, remakes, remasters and ports, falls back to a game named exactly the title, and returns the cover's address. It asks one request at a time, 250 ms apart, under IGDB's four a second, and asks again once with a new Twitch token after a 401. Nothing uses it yet: games-covers wires it in (decision 305).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief
Goal: the
gamesservice can find a game's cover on IGDB with a filtered search and an exact-name fallback (decision 68), within IGDB's 4 requests a second: the sixth ofgames-exophase's eleven steps.Scope: a new package,
services/games/internal/igdb. Its client asks IGDB's games endpoint for a title with the app token that Twitch gives (decision 304) and returns the address of the title's 264×374 cover. Decision 305 and the step's rows in plan §0 and §8.2 come with it.Out of scope:
games-covers);games-covers);homelab-games).Acceptance criteria:
CoversendsPOST /v4/gameswithClient-ID,Authorization: Bearerand the token,Accept: application/json, and the query astext/plainin the body.https://images.igdb.com/igdb/image/upload/t_cover_big/<image_id>.jpg, or "" when there's no match or the match has no cover. An empty title gives "" without asking.find the cover of "<title>":, thenask IGDB:and the status or the transport's error,read IGDB's answer:, or the token's error. Each request gives up after 10 seconds, and an answer over 64 KiB is refused.mise run checkis green.What changed
services/games/internal/igdb/client.go:Newgives theClientthat asks IGDB as a Twitch app.Covermatches the title with the two queries and returns its cover's address.Tokensis what the client needs of*twitch.Tokens.services/games/internal/igdb/ask.go: one request at a time, at least 250 ms apart, with a new token once after a 401, and the answer read.client_test.go: the request, the match, the escaping and the empty title, against anhttpteststand-in for IGDB;fail_test.go: the refused token and the errors;ask_internal_test.go: the 250 ms, one request at a time, the waiting calls' contexts and the 10 seconds, against an in-memory IGDB in synctest bubbles;standin_test.go: the stand-ins.docs/plan.md: decision 305, the §0 row and the §8.2 bullet.QA
-race.http.NewRequestWithContext's error, which a parsed URL and a fixed method never hit.Drop, each header, the status, the 64 KiB and the 10 seconds;categoryis deprecated forgame_type, which the query uses.401with"Authorization Failure".find the cover of "Moon \"Garden\"": ask IGDB: 401 Unauthorized.mise run checkpassed on this branch's tree, merged withmainafter feat(notes): save a note from its editor #180:igdb;Review
games, like the slices of games around it; it's nowendpoint.httptesttests spend about 3 seconds of real time in the 250 ms gap, since a bubble can't hold a network server.Client.games-coversmakes one per process, but the Mac and the laptop share IGDB's limit when they use the same Twitch app, so a 429 could fail a title until a later fetch.Newyet:games-coverswill.Merged under the user's standing OK once CI's
checkis green.