Use TMDB for TV episode information if no other source is available - #497
Open
egreenmachine wants to merge 2 commits into
Open
egreenmachine wants to merge 2 commits into
egreenmachine wants to merge 2 commits into
Conversation
Show metadata had exactly two backends: TVDB (needs an API key) and Trakt
(needs an authenticated account). TMDB was used for movie release dates and
alias enrichment but never for shows, so a setup with only a TMDB key got
"No metadata returned" for every show while movies worked fine.
_fetch_tmdb_show_data already existed but was unreachable in practice and
returned seasons with no episodes. Two changes make TMDB a real backend:
- _fetch_tmdb_episodes fetches each season from TMDB and maps it to the same
{season: {episode: {title, overview, runtime, first_aired, imdb_id,
absolute}}} shape _fetch_episodes_paginated produces, and
_fetch_tmdb_show_data now populates episodes with it. Without episodes a
show cannot expand into wanted items, so show-level data alone was no more
useful than none.
- get_show_data and get_show_seasons_and_episodes go straight to TMDB when
is_available() is False. Previously they resolved a TVDB id via TMDB and
then made a TVDB request that needs the key they don't have, whose failure
path falls back to Trakt.
_get_metadata_client picks tvdb_client (for its TMDB path) when TMDB is
configured and TVDB is not, and the source name reports 'tmdb'.
TMDB gives air_date without a time or network timezone, so first_aired is
date-only, as it already is for TVDB shows without airsTime.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The previous commit selected the TMDB path whenever a TVDB key was absent and a TMDB key present, without asking whether Trakt was set up. A TMDB key is commonly configured for posters and release dates, so a working Trakt install with no TVDB key would have been silently downgraded to TMDB, which has no per-episode IMDb ids, no absolute numbering and date-only air times. _refresh_show only falls back to Trakt when the primary returns nothing, so partial-but-poorer data would have won. Gate the TMDB path on Trakt being absent too, via tvdb_client.tmdb_only_mode(), and route get_show_data / get_show_seasons_and_episodes to Trakt directly when there is no TVDB key but Trakt is configured. discover_routes calls both functions without going through _get_metadata_client, so the guard belongs in them rather than only in the selector. The check reads the stored Trakt tokens rather than calling trakt_auth.is_authenticated(), which can trigger a network token refresh and runs on every client selection. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
I had an issue where I could not sign up for a TVDB account (website looks dead) and I did not want to pay for Trakt. It looks like TMDB has enough TV show information to populate enough fields to handle the TV shows.
tmdb_only_mode()FalseFalseFalseFalseTrueFalseDisclaimer - I used Claude Code Opus 5.0 to code this up. I am an engineer and have reviewed it, but Python is not my primary language.