tmdbtv

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tmdbtv provides a TMDB API v3 client for TV series data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CastMember

type CastMember struct {
	ID          int
	Name        string
	Character   string
	ProfilePath string
	Order       int
}

CastMember is a top-billed cast entry from the credits append.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a TMDB API v3 HTTP client scoped to TV series endpoints. All outbound requests are logged. The API key is never logged. Outbound calls are rate-limited and GET responses are cached for a short TTL. Client is safe for concurrent use.

func New

func New(apiKey string, logger *slog.Logger) *Client

New creates a new tmdbtv Client. apiKey must not be empty. logger is used to log outbound requests; the API key value is replaced with "***" in logged URLs.

func (*Client) DiscoverTVByGenre

func (c *Client) DiscoverTVByGenre(ctx context.Context, genreID, page int) (*PaginatedSeries, error)

DiscoverTVByGenre returns popular series in the given TMDB genre.

func (*Client) GetAlternativeTitles

func (c *Client) GetAlternativeTitles(ctx context.Context, tmdbID int) ([]string, error)

GetAlternativeTitles fetches the list of alternate titles TMDB knows about for the series. Includes per-region marketing names ("Star Wars: Andor" for "Andor"), original-language titles, and any user-submitted aliases. The canonical title is NOT included — callers prepend it themselves so the matcher checks against the full set.

Returns an empty slice (no error) when TMDB has no alternates.

func (*Client) GetExternalIDs

func (c *Client) GetExternalIDs(ctx context.Context, tmdbID int) (ExternalIDs, error)

GetExternalIDs returns the series' IMDb and TVDB ids (/tv/{id}/external_ids). Either may be empty/zero when TMDB has none.

func (*Client) GetOnTheAirTV

func (c *Client) GetOnTheAirTV(ctx context.Context, page int) (*PaginatedSeries, error)

GetOnTheAirTV returns series with episodes airing in the next ~7 days. This is the TV analog to a movies "upcoming" list (TMDB has no /tv/upcoming).

func (*Client) GetPerson

func (c *Client) GetPerson(ctx context.Context, personID int) (*Person, error)

GetPerson fetches basic info for a TMDB person.

func (*Client) GetPersonTVCredits

func (c *Client) GetPersonTVCredits(ctx context.Context, personID int, personType string) ([]PersonCredit, error)

GetPersonTVCredits returns the TV series a person is credited on. For personType "director" it returns crew credits with job "Director"; for anything else (actors) it returns top-billed cast credits (order < 5), mirroring Prism's movie filmography behaviour.

func (*Client) GetPopularTV

func (c *Client) GetPopularTV(ctx context.Context, page int) (*PaginatedSeries, error)

func (*Client) GetSeasonEpisodes

func (c *Client) GetSeasonEpisodes(ctx context.Context, tmdbID int, seasonNum int) ([]EpisodeDetail, error)

GetSeasonEpisodes fetches the episode list for a single season.

func (*Client) GetSeries

func (c *Client) GetSeries(ctx context.Context, tmdbID int) (*SeriesDetail, error)

GetSeries fetches full series details by TMDB ID, including the season list.

func (*Client) GetSeriesExtended

func (c *Client) GetSeriesExtended(ctx context.Context, tmdbID int) (*SeriesDetail, error)

GetSeriesExtended fetches the same /tv/{id} payload as GetSeries but also requests credits and recommendations via append_to_response, and populates the Rating, Cast, Crew, and Recommendations fields. It is used by the Discover detail page; Add/RefreshMetadata use the lighter GetSeries instead.

func (*Client) GetTVGenres

func (c *Client) GetTVGenres(ctx context.Context) ([]Genre, error)

GetTVGenres returns the list of TMDB TV genres.

func (*Client) GetTopRatedTV

func (c *Client) GetTopRatedTV(ctx context.Context, page int) (*PaginatedSeries, error)

GetTopRatedTV returns the highest-rated TV series from TMDB.

func (*Client) GetTrendingTV

func (c *Client) GetTrendingTV(ctx context.Context, window string, page int) (*PaginatedSeries, error)

GetTrendingTV returns trending TV series from TMDB. window must be "day" or "week" (defaults to "week").

func (*Client) SearchSeries

func (c *Client) SearchSeries(ctx context.Context, query string, year int) ([]SearchResult, error)

SearchSeries searches TMDB for TV series matching query. If year is non-zero it is sent as the first_air_date_year filter.

type CrewMember

type CrewMember struct {
	ID          int
	Name        string
	Job         string
	Department  string
	ProfilePath string
}

CrewMember is a key crew entry (creator, EP, writer, director) from the credits append.

type EpisodeDetail

type EpisodeDetail struct {
	ID             int
	SeasonNumber   int
	EpisodeNumber  int
	Title          string
	Overview       string
	AirDate        string
	StillPath      string
	RuntimeMinutes int
}

EpisodeDetail holds per-episode metadata returned by /tv/{id}/season/{n}.

type ExternalIDs

type ExternalIDs struct {
	IMDBID string // "tt0903747"; empty when unknown
	TVDBID int    // 0 when unknown
}

ExternalIDs are a series' ids on other databases, as TMDB knows them.

type Genre

type Genre struct {
	ID   int
	Name string
}

Genre is a TMDB TV genre.

type PaginatedSeries

type PaginatedSeries struct {
	Results    []SearchResult
	Page       int
	TotalPages int
}

PaginatedSeries is a page of series results from a TMDB list endpoint (popular, trending, top-rated, on-the-air, discover-by-genre).

type Person

type Person struct {
	ID                 int
	Name               string
	ProfilePath        string
	KnownForDepartment string
}

Person holds basic TMDB person info from /person/{id}.

type PersonCredit

type PersonCredit struct {
	TMDBID     int
	Title      string
	Year       int
	PosterPath string
	Order      int
	// EpisodeCount is how many episodes the person appears in / worked on.
	// Used to rank real roles above one-off talk-show / self appearances,
	// since the cast `order` field is unreliable for TV.
	EpisodeCount int
}

PersonCredit is a single TV series a person is credited on, from /person/{id}/tv_credits.

type SearchResult

type SearchResult struct {
	ID            int
	Title         string
	OriginalTitle string
	Overview      string
	FirstAirDate  string
	Year          int
	PosterPath    string
	BackdropPath  string
	Popularity    float64
	VoteAverage   float64
}

SearchResult is a single item from a /search/tv response.

type SeasonSummary

type SeasonSummary struct {
	SeasonNumber int
	EpisodeCount int
	AirDate      string
}

SeasonSummary is a brief season entry embedded in SeriesDetail.

type SeriesDetail

type SeriesDetail struct {
	ID             int
	Title          string
	OriginalTitle  string
	Overview       string
	FirstAirDate   string
	Year           int
	RuntimeMinutes int
	Genres         []string
	PosterPath     string
	BackdropPath   string
	// Status is one of "continuing", "ended", or "upcoming".
	Status  string
	Network string
	Seasons []SeasonSummary
	// IMDBID ("tt...") and TVDBID come from external_ids; empty/zero when
	// TMDB has none.
	IMDBID string
	TVDBID int

	// The fields below are only populated by GetSeriesExtended (which
	// requests append_to_response=credits,recommendations). GetSeries
	// leaves them empty to keep the Add/RefreshMetadata payload light.
	Rating          float64
	Cast            []CastMember
	Crew            []CrewMember
	Recommendations []SeriesRecommendation
}

SeriesDetail holds full series metadata returned by /tv/{id}.

type SeriesRecommendation

type SeriesRecommendation struct {
	TMDBID     int
	Title      string
	Year       int
	PosterPath string
}

SeriesRecommendation is a recommended series from the recommendations append.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL