Documentation
¶
Overview ¶
Package tmdb is a minimal The Movie Database client + on-disk cache.
We do NOT pre-enrich search results (that would add 50-200ms to every search and is wasteful for queries the user won't click). Instead the frontend asks for a match lazily per visible card. The cache makes repeated lookups for the same title near-free.
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) Discover(ctx context.Context, year, genre int) ([]Match, error)
- func (c *Client) FetchEpisodeName(ctx context.Context, seriesID int, season, episode int) string
- func (c *Client) Genres(ctx context.Context) ([]Genre, error)
- func (c *Client) Match(ctx context.Context, rawTitle string) (*Match, error)
- func (c *Client) Recommendations(ctx context.Context, kind string, tmdbID int) ([]Match, error)
- func (c *Client) Trending(ctx context.Context) ([]Match, error)
- func (c *Client) Videos(ctx context.Context, kind string, tmdbID int) ([]Video, error)
- type Genre
- type Match
- type Video
Constants ¶
This section is empty.
Variables ¶
var ErrDisabled = errors.New("tmdb: api key not configured")
ErrDisabled means no API key is configured — handlers should fall through gracefully instead of returning a 500.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
New returns a TMDB client. If apiKey is empty the client returns ErrDisabled from every call — handlers should surface that as "no enrichment available" (404) without exploding. omdbKey is optional: when set, matches are enriched with the real IMDb rating (via OMDb) on top of TMDB's own vote average.
func (*Client) Discover ¶
Discover queries TMDB's /discover for movies AND tv with optional year/genre filters, merged and sorted by popularity (the Em Alta filters). Direction tags don't apply here (it's a filtered query, not the weekly ranking).
func (*Client) FetchEpisodeName ¶
FetchEpisodeName returns the localized episode title for a given TV show's TMDB ID, season, and episode. Falls back to empty string if not found or on error.
func (*Client) Genres ¶
Genres returns the merged movie+tv genre list (deduped), cached for genresTTL.
func (*Client) Match ¶
Match looks up the best TMDB result for a raw torrent title, with caching. Returns (nil, nil) if no match was found — that's a normal "this isn't a known movie/show" case, not an error.
func (*Client) Recommendations ¶
Recommendations returns TMDB's "recommendations" list for a movie or tv id — the same set the site shows under a title's Recommendations tab. Single page (~20 items), best-effort. kind MUST be "movie" or "tv": TMDB ids are namespaced per type, so calling the wrong endpoint would return an unrelated title's recs.
type Match ¶
type Match struct {
TmdbID int `json:"tmdbId"`
ImdbID string `json:"imdbId,omitempty"` // resolved via external_ids; persisted so we never reprocess
Title string `json:"title"`
OriginalTitle string `json:"originalTitle,omitempty"` // untranslated title — used to seed torrent search (releases use the original)
Year int `json:"year"`
PosterURL string `json:"posterUrl"`
Overview string `json:"overview"`
VoteAverage float64 `json:"voteAverage"` // TMDB community score (0-10)
ImdbRating float64 `json:"imdbRating,omitempty"` // real IMDb rating via OMDb (0-10), when available
Kind string `json:"kind"` // "movie" | "tv"
Popularity float64 `json:"popularity,omitempty"` // TMDB popularity score
// Trending direction vs last week's ranking: "up" | "down" | "new" | "same".
Direction string `json:"direction,omitempty"`
RankDelta int `json:"rankDelta,omitempty"` // positions moved (absolute) vs last week
}
Match is the simplified view we expose to the frontend.