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 AwardSource
- 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) 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) 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.
Functions ¶
func AwardSummary ¶
AwardSummary sums awards up in a line, e.g. "Won 4 Academy Awards · 31 wins and 62 nominations".
Types ¶
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 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
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
// 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) 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) 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.