-
Notifications
You must be signed in to change notification settings - Fork 97
feat(web): add AniList and TVDB metadata with BYOK #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ProdigyV21
merged 6 commits into
ProdigyV21:main
from
Himanth-reddy:feat/metadata-anilist-tvdb-byok
Aug 12, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ce3526
feat(android): add AniList, TVDB v4 integration, metadata dispatcher …
Himanth-reddy 5d802c2
feat(web): add AniList, TVDB v4 integration, metadata dispatcher & BY…
Himanth-reddy bc41cb7
fix(web): support seasonNumber and episodeNumber in AniZip parser
Himanth-reddy 6dffa92
feat(web): complete metadata dispatcher vertical slice
Himanth-reddy add1069
refactor(metadata): address PR 495 review feedback and CodeRabbit fixes
Himanth-reddy 7e9c25c
Merge main and complete web metadata integration
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| import type { MediaItem } from "../types"; | ||
| import type { MetadataMediaType, MetadataResolver } from "./types"; | ||
|
|
||
| const ANILIST_GRAPHQL_ENDPOINT = "https://graphql.anilist.co"; | ||
|
|
||
| const MEDIA_QUERY = ` | ||
| query ($id: Int, $search: String) { | ||
| Media(id: $id, search: $search, type: ANIME) { | ||
| id | ||
| idMal | ||
| title { | ||
| romaji | ||
| english | ||
| native | ||
| } | ||
| description | ||
| bannerImage | ||
| coverImage { | ||
| extraLarge | ||
| large | ||
| medium | ||
| color | ||
| } | ||
| format | ||
| status | ||
| episodes | ||
| duration | ||
| averageScore | ||
| popularity | ||
| genres | ||
| season | ||
| seasonYear | ||
| studios(isMain: true) { | ||
| nodes { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const SEARCH_QUERY = ` | ||
| query ($search: String) { | ||
| Page(page: 1, perPage: 20) { | ||
| media(search: $search, type: ANIME) { | ||
| id | ||
| idMal | ||
| title { | ||
| romaji | ||
| english | ||
| native | ||
| } | ||
| description | ||
| bannerImage | ||
| coverImage { | ||
| large | ||
| medium | ||
| } | ||
| averageScore | ||
| seasonYear | ||
| episodes | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| function mapAniListToMediaItem(media: any): MediaItem { | ||
| const title = media.title?.english || media.title?.romaji || media.title?.native || "Untitled Anime"; | ||
| const poster = media.coverImage?.extraLarge || media.coverImage?.large || media.coverImage?.medium || null; | ||
| const rating = media.averageScore ? (media.averageScore / 10).toFixed(1) : undefined; | ||
|
|
||
| return { | ||
| id: media.id, | ||
| anilistId: media.id, | ||
| title, | ||
| subtitle: media.title?.romaji !== title ? media.title?.romaji : undefined, | ||
| overview: media.description ? media.description.replace(/<[^>]*>?/gm, "") : "", | ||
| year: media.seasonYear ? String(media.seasonYear) : undefined, | ||
| rating, | ||
| duration: media.duration ? `${media.duration}m` : undefined, | ||
| mediaType: "tv", | ||
| isAnime: true, | ||
| image: poster ?? undefined, | ||
| backdrop: media.bannerImage ?? poster ?? null, | ||
| badge: media.format ?? "ANIME", | ||
| genres: media.genres ?? [], | ||
| status: media.status, | ||
| numberOfEpisodes: media.episodes ?? null | ||
| }; | ||
| } | ||
|
|
||
| export const aniListResolver: MetadataResolver = { | ||
| id: "anilist", | ||
| name: "AniList", | ||
| supportedTypes: ["anime"], | ||
|
|
||
| async getDetails(id: string | number, _mediaType?: MetadataMediaType): Promise<MediaItem | null> { | ||
| try { | ||
| const isNumeric = !isNaN(Number(id)); | ||
| const variables = isNumeric ? { id: Number(id) } : { search: String(id) }; | ||
|
|
||
| const res = await fetch(ANILIST_GRAPHQL_ENDPOINT, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json", Accept: "application/json" }, | ||
| body: JSON.stringify({ query: MEDIA_QUERY, variables }) | ||
| }); | ||
|
|
||
| if (!res.ok) return null; | ||
| const json = await res.json(); | ||
| if (!json.data?.Media) return null; | ||
|
|
||
| return mapAniListToMediaItem(json.data.Media); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }, | ||
|
|
||
| async search(query: string, _mediaType?: MetadataMediaType): Promise<MediaItem[]> { | ||
| try { | ||
| const res = await fetch(ANILIST_GRAPHQL_ENDPOINT, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json", Accept: "application/json" }, | ||
| body: JSON.stringify({ query: SEARCH_QUERY, variables: { search: query } }) | ||
| }); | ||
|
|
||
| if (!res.ok) return []; | ||
| const json = await res.json(); | ||
| const items = json.data?.Page?.media ?? []; | ||
| return items.map(mapAniListToMediaItem); | ||
| } catch { | ||
| return []; | ||
| } | ||
| } | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the web app context I checked, adding this visible section only persists values:
MetadataDispatcheris not imported anywhere, and existing search/details/catalog flows still callweb/lib/tmdb.tsdirectly, so none ofcustomTmdbApiKey,customTvdbApiKey, or the provider-order fields affect requests. Users can enter keys and see “TVDB enabled”, but metadata remains on the previous TMDB path until this section is wired into the fetchers.Useful? React with 👍 / 👎.