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 ¶
- Variables
- func AwardSummary(awards []store.Award) string
- type Arr
- type AwardSource
- type Candidate
- type CoverOption
- type Covers
- type Detailer
- type Fetcher
- func (f *Fetcher) FetchDetails(ctx context.Context, lib store.Library)
- func (f *Fetcher) FetchLibrary(ctx context.Context, lib store.Library)
- func (f *Fetcher) FetchTranslations(ctx context.Context, lib store.Library)
- func (f *Fetcher) Kinds() []string
- func (f *Fetcher) TranslateAll(ctx context.Context)
- type GenreProvider
- type MusicBrainz
- type OpenLibrary
- type Provider
- type Query
- type TMDB
- func (t *TMDB) Check(ctx context.Context, key string) error
- func (t *TMDB) Details(ctx context.Context, kind string, id int64) (*store.DetailsUpdate, error)
- func (t *TMDB) Find(ctx context.Context, kind, ref string) (*store.Metadata, *Candidate, error)
- func (t *TMDB) Genres(ctx context.Context, kind string, id int64) ([]string, error)
- func (t *TMDB) Key() string
- func (t *TMDB) Keywords(ctx context.Context, name string) ([]int64, error)
- func (t *TMDB) Kinds() []string
- func (t *TMDB) Lookup(ctx context.Context, q Query) (*store.Metadata, error)
- func (t *TMDB) Name() string
- func (t *TMDB) Person(ctx context.Context, id int64) (*store.PersonInfo, error)
- func (t *TMDB) Ready() bool
- func (t *TMDB) Search(ctx context.Context, kind, title string, year int) ([]Candidate, error)
- func (t *TMDB) SeasonDetails(ctx context.Context, showID int64, season int) (*store.DetailsUpdate, map[int]store.DetailsUpdate, error)
- func (t *TMDB) SeasonTranslation(ctx context.Context, showID int64, season int, lang string) (store.Translation, map[int]store.Translation, error)
- func (t *TMDB) SetKey(key string)
- func (t *TMDB) Trailers(ctx context.Context, kind string, id int64, season int) ([]Video, error)
- func (t *TMDB) Translations(ctx context.Context, kind string, id int64) (map[string]store.Translation, error)
- type Translator
- type Video
- type Wikidata
Constants ¶
This section is empty.
Variables ¶
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 ...").
var ErrBadKey = errors.New("tmdb: the API key was turned down")
ErrBadKey means TMDB turned the key down.
var ErrNoKey = errors.New("tmdb: no API key")
ErrNoKey is what lookups fail with while TMDB has no key.
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 ¶
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
Kinds lists movies while Radarr is connected and shows while Sonarr is, unless TMDB has a key.
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
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 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 ¶
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 ¶
FetchLibrary looks up every item in the library that hasn't been looked up yet.
func (*Fetcher) FetchTranslations ¶ added in v0.1.1
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) TranslateAll ¶ added in v0.1.1
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) 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) 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
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 (*TMDB) Check ¶ added in v0.1.1
Check asks TMDB whether it accepts key, without changing the one in use.
func (*TMDB) Find ¶ added in v0.2.0
Find looks up one movie or show (kind movie or show) by a TMDB id (949 or tmdb:949), 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 ¶
Genres looks up the genres of a movie or show matched before Matinee kept them.
func (*TMDB) Keywords ¶ added in v0.1.1
Keywords finds the ids of TMDB's keywords named exactly name, ignoring case. There is usually one, sometimes a few duplicates.
func (*TMDB) Search ¶ added in v0.2.0
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
SetKey changes the key while the server runs; "" turns lookups off.
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.