metadata

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 26 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 metadata looks up descriptions and artwork from online providers. Providers are an extension point: TMDB (movies and TV) and MusicBrainz (music) are built in, and metadata plugins will implement the same interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	TMDBBaseURL  = "https://api.themoviedb.org/3"
	TMDBImageURL = "https://image.tmdb.org/t/p/"
)

Where TMDB's API and images are. Variables so the docs' screenshot server can point a build at a stand-in (go build -ldflags "-X ...").

View Source
var ErrBadKey = errors.New("tmdb: the API key was turned down")

ErrBadKey means TMDB turned the key down.

View Source
var ErrNoKey = errors.New("tmdb: no API key")

ErrNoKey is what lookups fail with while TMDB has no key.

View Source
var ErrUnknownRef = errors.New("not a TMDB id, TMDB address or IMDb id")

ErrUnknownRef means Find didn't understand what it was given.

Functions

func AwardSummary

func AwardSummary(awards []store.Award) string

AwardSummary sums awards up in a line, e.g. "Won 4 Academy Awards · 31 wins and 62 nominations".

Types

type Arr added in v0.2.2

type Arr struct {
	Store *store.Store
	// TMDB, when it has a key, looks everything up instead.
	TMDB *TMDB
	// contains filtered or unexported fields
}

Arr looks movies up through Radarr and shows through Sonarr (or Box Office, which answers as both), while TMDB has no key. They already know each title's poster, backdrop and description, from their own metadata service, so an admin who has connected them needn't get a TMDB key for artwork. Seasons and episodes wait for TMDB.

func (*Arr) Forget added in v0.2.2

func (a *Arr) Forget()

Forget drops what Arr knows of the connections and libraries, after an admin changes a connection.

func (*Arr) Kinds added in v0.2.2

func (a *Arr) Kinds() []string

Kinds lists movies while Radarr is connected and shows while Sonarr is, unless TMDB has a key.

func (*Arr) Lookup added in v0.2.2

func (a *Arr) Lookup(ctx context.Context, q Query) (*store.Metadata, error)

Lookup finds the title in the app's library, and failing that, the way the app's own Add New page does.

func (*Arr) Name added in v0.2.2

func (a *Arr) Name() string

type AwardSource

type AwardSource interface {
	Awards(ctx context.Context, wikidataID string) ([]store.Award, error)
}

AwardSource looks up the awards a title won or was nominated for.

type Candidate added in v0.2.0

type Candidate struct {
	ID       int64  `json:"id"`
	Title    string `json:"title"`
	Year     int    `json:"year,omitempty"`
	Overview string `json:"overview,omitempty"`
	Poster   string `json:"poster,omitempty"` // a small one, for the list
}

Candidate is a title a search found, for an admin fixing a match to pick.

type CoverOption added in v0.1.7

type CoverOption struct {
	URL    string `json:"url"`   // the full-size image
	Thumb  string `json:"thumb"` // a small one, to show in the list
	Source string `json:"source"`
	Title  string `json:"title"`            // what the source calls it
	Detail string `json:"detail,omitempty"` // which edition: year, country, format
}

CoverOption is a cover an admin can pick for an album or book.

type Covers added in v0.1.7

type Covers struct {
	MusicBrainz *MusicBrainz // for albums; nil leaves out the Cover Art Archive
	OpenLibrary *OpenLibrary // for books; nil leaves out Open Library
	ITunesURL   string       // defaults to the public services; tests point them elsewhere
	DeezerURL   string
	UserAgent   string
	Client      *http.Client
}

Covers finds covers to pick from: every edition's on the Cover Art Archive, and Apple's, Deezer's and Open Library's store and catalog covers. None of them needs a key. Each source answers what it can; one that's down leaves the others.

func NewCovers added in v0.1.7

func NewCovers(version string, mb *MusicBrainz, ol *OpenLibrary) *Covers

func (*Covers) Find added in v0.1.7

func (c *Covers) Find(ctx context.Context, q Query) []CoverOption

Find lists covers for an album (q.Kind "album", with its artist) or a book ("book", with its author), best sources first.

type Detailer

type Detailer interface {
	// Details looks up a movie or show by the provider id its lookup found.
	Details(ctx context.Context, kind string, id int64) (*store.DetailsUpdate, error)
	// SeasonDetails looks up a season's cast, and each episode's guest stars
	// and crew, keyed by episode number.
	SeasonDetails(ctx context.Context, showID int64, season int) (*store.DetailsUpdate, map[int]store.DetailsUpdate, error)
}

Detailer is a provider that also knows the longer details of movies and shows: cast and crew, studios, ratings and what they have in common with other titles.

type EpisodeList added in v0.2.4

type EpisodeList struct {
	// Episodes are the show's episodes from the first, specials left
	// out, each where it's shown in the order and where it's found online.
	Episodes []store.Place
	// Aired counts the episodes of each season as it aired, specials left
	// out, to tell whether 104 can be season 1, episode 4.
	Aired map[int]int
	// Japanese says the show is from Japan, where a number like 104 is
	// the 104th episode much more often than season 1, episode 4.
	Japanese bool
}

EpisodeList is a show's episodes in one of its orders.

type EpisodeLister added in v0.2.4

type EpisodeLister interface {
	EpisodeList(ctx context.Context, showID int64, order string) (*EpisodeList, error)
}

EpisodeLister lists a show's episodes in an order; TMDB is one. It returns nil, nil when the show isn't there.

type Fetcher

type Fetcher struct {
	Store     *store.Store
	Providers []Provider
	// Plugins lists providers that plugins add for their own item kinds, as
	// they are now; nil for none.
	Plugins func() []Provider
	// Awards looks up titles' awards, if set.
	Awards AwardSource
	// Edition reads a video file's edition from its path, for grouping
	// files matched to the same movie as versions of it (see
	// store.GroupVersions); nil leaves versions to the scan.
	Edition func(path string) string
	Log     *slog.Logger
	// contains filtered or unexported fields
}

Fetcher fills in metadata for newly scanned items.

func (*Fetcher) FetchDetails

func (f *Fetcher) FetchDetails(ctx context.Context, lib store.Library)

FetchDetails fills in cast, crew and details for a library's matched movies, shows and seasons, and for the episodes of those seasons.

func (*Fetcher) FetchLibrary

func (f *Fetcher) FetchLibrary(ctx context.Context, lib store.Library)

FetchLibrary looks up every item in the library that hasn't been looked up yet.

func (*Fetcher) FetchTranslations added in v0.1.1

func (f *Fetcher) FetchTranslations(ctx context.Context, lib store.Library)

FetchTranslations fills in a library's titles in other languages: every language for movies and shows, which takes one lookup each, and the languages people use for seasons and episodes, which take one a season.

func (*Fetcher) Kinds

func (f *Fetcher) Kinds() []string

Kinds lists every item kind some provider looks up.

func (*Fetcher) PlaceEpisodes added in v0.2.4

func (f *Fetcher) PlaceEpisodes(ctx context.Context, lib store.Library) int

PlaceEpisodes puts the episodes named by absolute number of a library's matched shows in their seasons. It returns how many moved.

func (*Fetcher) TranslateAll added in v0.1.1

func (f *Fetcher) TranslateAll(ctx context.Context)

TranslateAll fills in translations for every library, such as when someone starts using a new language. A call while it runs makes it run once more.

type GenreProvider

type GenreProvider interface {
	Genres(ctx context.Context, kind string, id int64) ([]string, error)
}

GenreProvider is a Provider that can look up the genres of a movie or show it matched earlier, by its id.

type MusicBrainz

type MusicBrainz struct {
	BaseURL      string // defaults to the public services; tests point them elsewhere
	CoverURL     string
	WikidataURL  string
	WikipediaURL string
	UserAgent    string // MusicBrainz asks every client to name itself
	Client       *http.Client
	// Interval spaces requests to MusicBrainz, which allows one a second.
	Interval time.Duration
	// contains filtered or unexported fields
}

MusicBrainz identifies artists and albums on musicbrainz.org, with album covers from the Cover Art Archive and artist photos and biographies from Wikidata and Wikipedia. None of them need an API key.

func NewMusicBrainz

func NewMusicBrainz(version string) *MusicBrainz

func (*MusicBrainz) Kinds

func (m *MusicBrainz) Kinds() []string

func (*MusicBrainz) Lookup

func (m *MusicBrainz) Lookup(ctx context.Context, q Query) (*store.Metadata, error)

func (*MusicBrainz) Name

func (m *MusicBrainz) Name() string

type OpenLibrary added in v0.1.3

type OpenLibrary struct {
	BaseURL   string // defaults to the public services; tests point them elsewhere
	CoverURL  string
	UserAgent string
	Client    *http.Client
	// Interval spaces requests, to be a polite user of a free service.
	Interval time.Duration
	// contains filtered or unexported fields
}

OpenLibrary finds covers for audiobooks and photos of their authors on openlibrary.org, which needs no API key. Its covers are of the printed book, which is what most audiobook covers are made from.

func NewOpenLibrary added in v0.1.3

func NewOpenLibrary(version string) *OpenLibrary

func (*OpenLibrary) Kinds added in v0.1.3

func (o *OpenLibrary) Kinds() []string

func (*OpenLibrary) Lookup added in v0.1.3

func (o *OpenLibrary) Lookup(ctx context.Context, q Query) (*store.Metadata, error)

func (*OpenLibrary) Name added in v0.1.3

func (o *OpenLibrary) Name() string

type Provider

type Provider interface {
	Name() string
	// Kinds lists the item kinds the provider looks up.
	Kinds() []string
	Lookup(ctx context.Context, q Query) (*store.Metadata, error)
}

Provider identifies items with an online database. Lookup returns nil, nil when nothing matches.

type Query

type Query struct {
	Kind    string // movie, show, season, episode, artist or album
	Title   string
	Year    int
	ShowID  int64 // provider id of the season's or episode's show
	Season  int
	Episode int
	// IDs are the ids in a movie's or show's file or folder name, which
	// pin its match instead of a search by title.
	IDs    mediaid.IDs
	Artist string // the album's artist, or the book's author
	// MusicBrainz ids from an album's tags, when its files have them.
	ReleaseID      string
	ReleaseGroupID string
	// For a plugin's kinds: the item's file and what the plugin keeps with it.
	Path string
	Data json.RawMessage
}

Query describes the item to identify.

type TMDB

type TMDB struct {
	BaseURL  string // defaults to the public API; tests point it elsewhere
	ImageURL string
	Client   *http.Client
	// Region picks which country's age ratings to show; defaults to US.
	Region string
	// contains filtered or unexported fields
}

TMDB looks up movies and TV on themoviedb.org. It takes either a v3 API key or a v4 read access token. Without a key it looks up nothing: Kinds is empty, and every lookup fails with ErrNoKey.

func NewTMDB

func NewTMDB(key string) *TMDB

func (*TMDB) Check added in v0.1.1

func (t *TMDB) Check(ctx context.Context, key string) error

Check asks TMDB whether it accepts key, without changing the one in use.

func (*TMDB) Details

func (t *TMDB) Details(ctx context.Context, kind string, id int64) (*store.DetailsUpdate, error)

Details implements Detailer.

func (*TMDB) EpisodeList added in v0.2.4

func (t *TMDB) EpisodeList(ctx context.Context, showID int64, order string) (*EpisodeList, error)

EpisodeList lists a show's episodes in an order: the seasons as they aired, or a DVD or absolute order from TMDB's episode groups. A show without the order asked for gets the aired one, in one long season for the absolute order.

func (*TMDB) Find added in v0.2.0

func (t *TMDB) Find(ctx context.Context, kind, ref string) (*store.Metadata, *Candidate, error)

Find looks up one movie or show (kind movie or show) by a TMDB id (949 or tmdb:949), a TheTVDB id (tvdb:81189), a themoviedb.org address or an IMDb id (tt0113277, or an imdb.com address). It returns nil, nil when there's no such title.

func (*TMDB) Genres

func (t *TMDB) Genres(ctx context.Context, kind string, id int64) ([]string, error)

Genres looks up the genres of a movie or show matched before Matinee kept them.

func (*TMDB) Key

func (t *TMDB) Key() string

Key is the API key or read access token in use; "" when there's none.

func (*TMDB) Keywords added in v0.1.1

func (t *TMDB) Keywords(ctx context.Context, name string) ([]int64, error)

Keywords finds the ids of TMDB's keywords named exactly name, ignoring case. There is usually one, sometimes a few duplicates.

func (*TMDB) Kinds

func (t *TMDB) Kinds() []string

Kinds is empty while TMDB has no key, so nothing waits on it.

func (*TMDB) Lookup

func (t *TMDB) Lookup(ctx context.Context, q Query) (*store.Metadata, error)

func (*TMDB) Name

func (t *TMDB) Name() string

func (*TMDB) Person

func (t *TMDB) Person(ctx context.Context, id int64) (*store.PersonInfo, error)

Person looks up someone's biography.

func (*TMDB) Ready added in v0.1.1

func (t *TMDB) Ready() bool

Ready reports whether TMDB has a key to look things up with.

func (*TMDB) Search added in v0.2.0

func (t *TMDB) Search(ctx context.Context, kind, title string, year int) ([]Candidate, error)

Search lists the movies or shows (kind movie or show) TMDB finds for a title, best first.

func (*TMDB) SeasonDetails

func (t *TMDB) SeasonDetails(ctx context.Context, showID int64, season int) (*store.DetailsUpdate, map[int]store.DetailsUpdate, error)

SeasonDetails implements Detailer.

func (*TMDB) SeasonTranslation added in v0.1.1

func (t *TMDB) SeasonTranslation(ctx context.Context, showID int64, season int, lang string) (store.Translation, map[int]store.Translation, error)

SeasonTranslation looks up a season's name and description in one i18n language, with each episode's, keyed by episode number. Text TMDB has no translation for is left empty.

func (*TMDB) SetKey added in v0.1.1

func (t *TMDB) SetKey(key string)

SetKey changes the key while the server runs; "" turns lookups off.

func (*TMDB) Trailers

func (t *TMDB) Trailers(ctx context.Context, kind string, id int64, season int) ([]Video, error)

Trailers lists a movie's, show's or season's trailers, best first: those in the context's language (store.WithLanguage), then English ones; within each, official trailers, then other trailers, then teasers. kind is movie or show; season is 0 for a whole show.

func (*TMDB) Translations added in v0.1.1

func (t *TMDB) Translations(ctx context.Context, kind string, id int64) (map[string]store.Translation, error)

Translations looks up a movie's or show's title, description and tagline in every language TMDB has them in, keyed by i18n language.

type Translator added in v0.1.1

type Translator interface {
	// Translations looks up a movie's or show's title, description and
	// tagline in every language it has them in, keyed by i18n language.
	Translations(ctx context.Context, kind string, id int64) (map[string]store.Translation, error)
	// SeasonTranslation looks up a season's and its episodes' text in one
	// language; episodes are keyed by number.
	SeasonTranslation(ctx context.Context, showID int64, season int, lang string) (store.Translation, map[int]store.Translation, error)
}

Translator is a provider that also knows titles' text in other languages.

type Video

type Video struct {
	Name string
	Site string // only YouTube for now
	Key  string // the site's video id
	Type string // Trailer or Teaser
}

Video is a trailer or teaser TMDB lists for a title.

type Wikidata

type Wikidata struct {
	Endpoint  string // SPARQL endpoint; tests point it elsewhere
	UserAgent string
	Client    *http.Client
}

Wikidata looks up awards on wikidata.org, which needs no key. TMDB knows each title's Wikidata id.

func NewWikidata

func NewWikidata(version string) *Wikidata

func (*Wikidata) Awards

func (w *Wikidata) Awards(ctx context.Context, id string) ([]store.Award, error)

Jump to

Keyboard shortcuts

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