Documentation
¶
Overview ¶
Package tmdbtv provides a TMDB API v3 client for TV series data.
Index ¶
- Constants
- func BrowseQuery(f BrowseFilter) (string, url.Values, error)
- func NormalizeRegion(r string) string
- type BrowseFilter
- type CastMember
- type Client
- func (c *Client) Browse(ctx context.Context, f BrowseFilter) (*PaginatedSeries, error)
- func (c *Client) DiscoverTVByGenre(ctx context.Context, genreID, page int) (*PaginatedSeries, error)
- func (c *Client) GetAlternativeTitles(ctx context.Context, tmdbID int) ([]string, error)
- func (c *Client) GetExternalIDs(ctx context.Context, tmdbID int) (ExternalIDs, error)
- func (c *Client) GetPerson(ctx context.Context, personID int) (*Person, error)
- func (c *Client) GetPersonTVCredits(ctx context.Context, personID int, personType string) ([]PersonCredit, error)
- func (c *Client) GetPopularTV(ctx context.Context, page int) (*PaginatedSeries, error)
- func (c *Client) GetSeasonEpisodes(ctx context.Context, tmdbID int, seasonNum int) ([]EpisodeDetail, error)
- func (c *Client) GetSeries(ctx context.Context, tmdbID int) (*SeriesDetail, error)
- func (c *Client) GetSeriesExtended(ctx context.Context, tmdbID int) (*SeriesDetail, error)
- func (c *Client) GetTVGenres(ctx context.Context) ([]Genre, error)
- func (c *Client) GetTrendingTV(ctx context.Context, window string, page int) (*PaginatedSeries, error)
- func (c *Client) SearchPaginated(ctx context.Context, query string, page int) (*PaginatedSeries, error)
- func (c *Client) SearchSeries(ctx context.Context, query string, year int) ([]SearchResult, error)
- func (c *Client) WatchProviders(ctx context.Context, region string) ([]WatchProvider, error)
- type CrewMember
- type EpisodeDetail
- type ExternalIDs
- type Genre
- type PaginatedSeries
- type Person
- type PersonCredit
- type SearchResult
- type SeasonSummary
- type SeriesDetail
- type SeriesRecommendation
- type WatchProvider
Constants ¶
const ( CategoryTrending = "trending" CategoryPopular = "popular" CategoryTopRated = "top-rated" CategoryNewOnline = "new" // new series on streaming services CategoryComingSoon = "coming-soon" )
Browse categories shared with Pilot's Discover page.
Variables ¶
This section is empty.
Functions ¶
func BrowseQuery ¶ added in v0.2.0
func BrowseQuery(f BrowseFilter) (string, url.Values, error)
BrowseQuery turns a filter into the TMDB path and query parameters. Kept free of I/O so the date windows and filters are easy to test.
func NormalizeRegion ¶ added in v0.2.0
NormalizeRegion returns a valid upper-case country code, defaulting to US.
Types ¶
type BrowseFilter ¶ added in v0.2.0
type BrowseFilter struct {
Category string
Page int
GenreID int
ProviderID int // TMDB watch provider (e.g. 8 = Netflix); needs Region
MinRating float64 // TMDB vote average, 0-10
Region string // ISO 3166-1 country, e.g. "US"
Today time.Time
}
BrowseFilter is one Discover page request: a category plus optional filters. Trending is a fixed TMDB list and ignores the filters.
type CastMember ¶
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 ¶
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) Browse ¶ added in v0.2.0
func (c *Client) Browse(ctx context.Context, f BrowseFilter) (*PaginatedSeries, error)
Browse fetches one page of a Discover category with filters applied.
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 ¶
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 ¶
GetExternalIDs returns the series' IMDb and TVDB ids (/tv/{id}/external_ids). Either may be empty/zero when TMDB has none.
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 (*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 ¶
GetSeries fetches full series details by TMDB ID, including the season list.
func (*Client) GetSeriesExtended ¶
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 ¶
GetTVGenres returns the list of TMDB TV genres.
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) SearchPaginated ¶ added in v0.2.0
func (c *Client) SearchPaginated(ctx context.Context, query string, page int) (*PaginatedSeries, error)
SearchPaginated searches TV series by title for the Discover page, with paging, for the Discover page.
func (*Client) SearchSeries ¶
SearchSeries searches TMDB for TV series matching query. If year is non-zero it is sent as the first_air_date_year filter.
func (*Client) WatchProviders ¶ added in v0.2.0
WatchProviders lists the streaming services available for TV in a country, most prominent first.
type CrewMember ¶
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 PaginatedSeries ¶
type PaginatedSeries struct {
Results []SearchResult
Page int
TotalPages int
}
PaginatedSeries is a page of series results from a TMDB list endpoint (popular, trending, browse, discover-by-genre).
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 ¶
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 ¶
SeriesRecommendation is a recommended series from the recommendations append.
type WatchProvider ¶ added in v0.2.0
type WatchProvider struct {
ID int `json:"id"`
Name string `json:"name"`
LogoPath string `json:"logo_path"`
}
WatchProvider is a streaming service TMDB knows about in a country.