Skip to content

Use TMDB for TV episode information if no other source is available - #497

Open
egreenmachine wants to merge 2 commits into
godver3:devfrom
egreenmachine:feature/tmdb-show-data
Open

egreenmachine wants to merge 2 commits into
godver3:devfrom
egreenmachine:feature/tmdb-show-data

Conversation

@egreenmachine

Copy link
Copy Markdown

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.

Configuration tmdb_only_mode() Routes to
TVDB + Trakt + TMDB False tvdb
TVDB only False tvdb
Trakt + TMDB, no TVDB False trakt
Trakt only False trakt
TMDB only True tmdb
Nothing configured False none

Disclaimer - 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.

egreenmachine and others added 2 commits September 4, 2026 11:40
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant