tmdb

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 2 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 tmdb implements a client for the TMDB API https://developer.themoviedb.org/docs/getting-started

Index

Constants

View Source
const (
	SizePoster   = "w780"
	SizeBackdrop = "w780"
	SizeStill    = "w300"
	SizeOriginal = "original"
)

The sizes of images, which are the widths TMDB has, or the original

View Source
const (

	// DefaultQuota is the most requests each minute, unless OptQuota sets
	// another, which is the rate limit
	DefaultQuota = uint(rateLimit * 60)
)

Variables

This section is empty.

Functions

func BackdropSize

func BackdropSize(dimension int) string

BackdropSize returns the smallest size of a backdrop, which is wider than it's high, whose width is at least the dimension, in pixels, or else the original

func OptQuota

func OptQuota(quota uint) client.ClientOpt

OptQuota limits the client's requests to the quota each minute, by spacing them evenly. The quota can't be more than TMDB allows, which is DefaultQuota, and a quota of zero is DefaultQuota.

func PosterSize

func PosterSize(dimension int) string

PosterSize returns the smallest size of a poster, whose height is one and a half times its width, whose width and height are at least the dimension, in pixels, when one of them is, or else the original

func StillSize

func StillSize(dimension int) string

StillSize returns the smallest size of an episode's still, which is wider than it's high, whose width is at least the dimension, in pixels, or else the original

Types

type Client

type Client struct {
	*client.Client
}

Client is a profile HTTP client that wraps the base HTTP client

func New

func New(apikey string, opts ...client.ClientOpt) (*Client, error)

New creates a TMDB client with the API Read Access Token, and options. Its requests are limited to DefaultQuota each minute, unless OptQuota sets another.

func (*Client) GetMovie

func (c *Client) GetMovie(ctx context.Context, id uint64) (*schema.MovieDetails, error)

GetMovie returns the details of a movie, such as its runtime

func (*Client) GetTVEpisode

func (c *Client) GetTVEpisode(ctx context.Context, id, season, episode uint64) (*schema.TVEpisode, error)

GetTVEpisode returns an episode of a TV show, by its season and episode numbers, such as its name and runtime, with its identifiers in other databases, such as IMDb

func (*Client) GetTVShow

func (c *Client) GetTVShow(ctx context.Context, id uint64) (*schema.TVShowDetails, error)

GetTVShow returns the details of a TV show, such as the typical runtimes of its episodes, with its identifiers in other databases, such as IMDb

func (*Client) Image

func (c *Client) Image(ctx context.Context, size, path string) ([]byte, error)

Image returns the image at the path, which is a movie's or show's poster or backdrop path, or an episode's still path, such as /qJ2tW6WMUDux911r6m7haRef0WH.jpg, in the size, such as SizePoster. The image server doesn't need the API token, so it isn't sent, but the request counts towards the client's quota.

func (*Client) SearchMovies

SearchMovies returns a page of the movies whose titles match the search, with the most relevant first

func (*Client) SearchTVShows

func (c *Client) SearchTVShows(ctx context.Context, req schema.TVSearchRequest) (*schema.TVSearchResponse, error)

SearchTVShows returns a page of the TV shows whose names match the search, with the most relevant first. TMDB searches shows, rather than episodes, which are got from a show with GetTVEpisode.

type Query

type Query struct {
	Name    string
	Year    int  // 0 if no year was found
	Season  int  // 0 unless Episode is also set
	Episode int  // 0 unless this looks like a TV episode
	TV      bool // true for a TV show's video, even without an Episode
}

Query is a search query extracted from a media file's path: the title to search for, its release year if present, and (for a TV episode) its season/episode number.

func ExtractQuery

func ExtractQuery(path string) Query

ExtractQuery derives a search query - title, year, and (for a TV episode) season/episode - from a media file's path. The title and year which the filename doesn't have are from the folder of the movie or show, which is the file's folder, or its parent when that's a season or extras folder, such as "Show (Year)/Season 2/03 Episode Title.mkv", in which the season is from the season folder, and the episode from the start of the filename. A video with an episode, or in a season folder, is a TV show's, even when its episode isn't known, such as "Show/Season 1/Pilot.mkv", whose title is the show's.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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