tmdb

package
v0.13.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: 14 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CastMember

type CastMember struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Character   string `json:"character"`
	ProfilePath string `json:"profile_path"`
	Order       int    `json:"order"`
}

CastMember is an actor in the movie's credits.

type Client

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

Client is a TMDB API v3 HTTP client. 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 TMDB client. apiKey must not be empty. It is stored and used in query parameters. logger is used to log outbound requests (the key value is replaced with "***" in logged URLs).

func (*Client) DiscoverByGenre

func (c *Client) DiscoverByGenre(ctx context.Context, genreID, page int) (*PaginatedResults, error)

DiscoverByGenre fetches movies filtered by genre ID.

func (*Client) FetchPopular

func (c *Client) FetchPopular(ctx context.Context, page int) (*PaginatedResults, error)

FetchPopular fetches popular movies with pagination metadata.

func (*Client) FetchTopRated

func (c *Client) FetchTopRated(ctx context.Context, page int) (*PaginatedResults, error)

FetchTopRated fetches top-rated movies with pagination metadata.

func (*Client) FetchTrending

func (c *Client) FetchTrending(ctx context.Context, page int) (*PaginatedResults, error)

FetchTrending fetches trending movies with pagination metadata.

func (*Client) FetchUpcoming

func (c *Client) FetchUpcoming(ctx context.Context, page int) (*PaginatedResults, error)

FetchUpcoming fetches upcoming movies with pagination metadata.

func (*Client) FindByIMDbID

func (c *Client) FindByIMDbID(ctx context.Context, imdbID string) (int, string, error)

FindByIMDbID looks up a movie by its IMDb ID using the /find endpoint. Returns the TMDB ID and title, or 0/"" if not found.

func (*Client) GenreList

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

GenreList fetches the list of official TMDB movie genres.

func (*Client) GetFranchise

func (c *Client) GetFranchise(ctx context.Context, collectionID int) (*FranchiseDetail, error)

GetFranchise fetches the full details of a TMDB movie collection by ID.

func (*Client) GetList

func (c *Client) GetList(ctx context.Context, listID string, page int) ([]SearchResult, error)

GetList fetches a user-created TMDB list by its numeric or string ID.

func (*Client) GetMovie

func (c *Client) GetMovie(ctx context.Context, tmdbID int) (*MovieDetail, error)

GetMovie fetches full movie details by TMDB ID.

func (*Client) GetMovieExtended

func (c *Client) GetMovieExtended(ctx context.Context, tmdbID int) (*MovieDetail, error)

GetMovieExtended fetches movie details with credits and recommendations in a single API call using TMDB's append_to_response parameter.

func (*Client) GetNowPlayingMovies

func (c *Client) GetNowPlayingMovies(ctx context.Context, page int) ([]SearchResult, error)

GetNowPlayingMovies fetches movies currently in theaters from TMDB. page starts at 1. Returns up to 20 results per page.

func (*Client) GetPerson

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

GetPerson fetches a TMDB person by ID.

func (*Client) GetPersonFilmography

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

GetPersonFilmography returns directed films (personType="director") or top-billed acted films (personType="actor") for the given TMDB person. For actors, only credits where billing order < 5 are returned.

func (*Client) GetPopularMovies

func (c *Client) GetPopularMovies(ctx context.Context, page int) ([]SearchResult, error)

GetPopularMovies fetches the TMDB popular movies list. page starts at 1. Returns up to 20 results per page.

func (*Client) GetTopRatedMovies

func (c *Client) GetTopRatedMovies(ctx context.Context, page int) ([]SearchResult, error)

GetTopRatedMovies fetches the all-time highest rated movies from TMDB. page starts at 1. Returns up to 20 results per page.

func (*Client) GetTrendingMovies

func (c *Client) GetTrendingMovies(ctx context.Context, window string, page int) ([]SearchResult, error)

GetTrendingMovies fetches trending movies from TMDB. window must be "day" or "week". page starts at 1.

func (*Client) GetUpcomingMovies

func (c *Client) GetUpcomingMovies(ctx context.Context, page int) ([]SearchResult, error)

GetUpcomingMovies fetches upcoming movies from TMDB. page starts at 1. Returns up to 20 results per page.

func (*Client) SearchFranchises

func (c *Client) SearchFranchises(ctx context.Context, query string) ([]FranchiseSearchResult, error)

SearchFranchises searches TMDB for movie collections (franchises) by name.

func (*Client) SearchMovies

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

SearchMovies searches TMDB for movies matching query. If year is non-zero it is sent as the primary_release_year filter.

func (*Client) SearchPeople

func (c *Client) SearchPeople(ctx context.Context, query string) ([]PersonSearchResult, error)

SearchPeople searches TMDB for people by name.

type CrewMember

type CrewMember struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Job         string `json:"job"`
	Department  string `json:"department"`
	ProfilePath string `json:"profile_path"`
}

CrewMember is a crew member (director, writer, etc.) in the movie's credits.

type FilmographyItem

type FilmographyItem struct {
	TMDBID     int
	Title      string
	Year       int
	PosterPath string
	Order      int // cast billing order (0 for directors)
}

FilmographyItem is one film entry in a person's filmography.

type FranchiseDetail

type FranchiseDetail struct {
	ID    int
	Name  string
	Parts []FilmographyItem
}

FranchiseDetail is the full response from the TMDB /collection/{id} endpoint.

type FranchiseSearchResult

type FranchiseSearchResult struct {
	ID         int
	Name       string
	PosterPath string
}

FranchiseSearchResult is a single result from the TMDB /search/collection endpoint.

type Genre

type Genre struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Genre is a TMDB movie genre.

type MovieDetail

type MovieDetail struct {
	ID             int
	IMDBId         string
	Title          string
	OriginalTitle  string
	Overview       string
	ReleaseDate    string
	Year           int // parsed from ReleaseDate; 0 if unavailable
	RuntimeMinutes int
	Genres         []string
	PosterPath     string
	BackdropPath   string
	// Status is mapped from the TMDB status string to our internal values.
	// TMDB "Released" → "released"; "In Production" / "Post Production" / anything else → "announced".
	Status string

	// Credits and recommendations are populated only when fetched via
	// GetMovieExtended (append_to_response=credits,recommendations).
	Cast            []CastMember          `json:"cast,omitempty"`
	Crew            []CrewMember          `json:"crew,omitempty"`
	Recommendations []MovieRecommendation `json:"recommendations,omitempty"`
}

MovieDetail is the full response from the TMDB /movie/{id} endpoint.

type MovieRecommendation

type MovieRecommendation struct {
	TMDBID     int    `json:"tmdb_id"`
	Title      string `json:"title"`
	Year       int    `json:"year"`
	PosterPath string `json:"poster_path"`
}

MovieRecommendation is a TMDB-recommended movie.

type PaginatedResults

type PaginatedResults struct {
	Results    []SearchResult `json:"results"`
	Page       int            `json:"page"`
	TotalPages int            `json:"total_pages"`
}

PaginatedResults wraps a list of search results with pagination metadata.

type Person

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

Person is summary info for a TMDB person.

type PersonSearchResult

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

PersonSearchResult is a single result from the TMDB person search endpoint.

type SearchResult

type SearchResult struct {
	ID            int
	Title         string
	OriginalTitle string
	Overview      string
	ReleaseDate   string // "YYYY-MM-DD" or empty
	Year          int    // parsed from ReleaseDate; 0 if unavailable
	PosterPath    string // TMDB path; prefix with image base URL before use
	BackdropPath  string
	Popularity    float64
}

SearchResult is a single result from the TMDB movie search endpoint.

Jump to

Keyboard shortcuts

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