metadata

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 3 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 show metadata at external providers and folds their differing genre labels into one canonical vocabulary, so that a block's filter.genres means the same thing no matter which source a Tunarr library was built from.

The package is provider-agnostic. internal/metadata/tmdb and internal/metadata/tvdb implement Provider; neither reads the environment. API keys arrive through a constructor, sourced by the caller from config or a secret at wiring time.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("show not found")

ErrNotFound reports that a title has no match at a provider. It is an ordinary outcome of a lookup pass -- a caller checks it with errors.Is and moves on to the next show rather than failing the whole pass.

View Source
var ErrUnauthorized = errors.New("provider rejected the api key")

ErrUnauthorized reports that a provider rejected the API key the client was built with. Unlike ErrNotFound it is fatal to a lookup pass: every later call carrying the same key fails the same way, so a caller aborts instead of recording hundreds of shows as unmatched.

Functions

func CanonicalGenres

func CanonicalGenres() []string

CanonicalGenres returns the vocabulary NormalizeGenre maps into, as a fresh copy the caller may sort or filter freely.

func NormalizeGenre

func NormalizeGenre(raw string) (string, bool)

NormalizeGenre folds one raw provider label into the canonical vocabulary. Matching ignores case and surrounding whitespace.

It reports false for a label the vocabulary has no place for -- including the format labels and niche categories listed at the end of genreAliases. Callers drop those rather than inventing a genre an operator cannot filter on.

func NormalizeGenres

func NormalizeGenres(raw []string) []string

NormalizeGenres folds a provider's genre list into the canonical vocabulary, preserving the source order and dropping both duplicates (two raw labels can share one canonical name) and labels NormalizeGenre rejects. It returns nil when nothing survives, so an unmatched list and an empty one are indistinguishable to a caller.

Types

type Provider

type Provider interface {
	// Name returns the provider's short identifier ("tmdb", "tvdb"),
	// which is also the key it sets in ShowMetadata.ExternalIDs.
	Name() string

	// LookupShow resolves a show by title. A year of 0 means "no hint";
	// a non-zero year narrows the search and breaks ties between
	// same-named shows. It returns an error wrapping ErrNotFound when
	// the provider has no match, and one wrapping ErrUnauthorized when
	// the provider rejected the key.
	LookupShow(ctx context.Context, title string, year int) (*ShowMetadata, error)
}

Provider is one external metadata source.

type ShowMetadata

type ShowMetadata struct {
	// Title is the provider's own name for the show, which may differ
	// from the title that was searched for.
	Title string

	// Year is the first-air year, or 0 when the provider gave none.
	Year int

	// Genres are already normalized to the canonical vocabulary by
	// NormalizeGenres: deduplicated, source order preserved, and labels
	// with no canonical equivalent dropped.
	Genres []string

	// Rating is the content rating (TV-MA, PG-13), preferring the US
	// certification because that is the vocabulary Tunarr libraries
	// carry. Empty when the provider published none.
	Rating string

	// Overview is the provider's synopsis.
	Overview string

	// PosterURL is an absolute URL to poster art, empty when the
	// provider has none.
	PosterURL string

	// ExternalIDs maps a source name to this show's ID at that source.
	// It always carries the answering provider's own Name(), plus any
	// cross-references that provider publishes ("imdb", "tmdb",
	// "tvdb").
	ExternalIDs map[string]string
}

ShowMetadata is one provider's answer about one show, in a shape that does not vary by provider.

Directories

Path Synopsis
Package tmdb implements metadata.Provider against The Movie Database's v3 REST API.
Package tmdb implements metadata.Provider against The Movie Database's v3 REST API.
Package tvdb implements metadata.Provider against TheTVDB's v4 REST API.
Package tvdb implements metadata.Provider against TheTVDB's v4 REST API.

Jump to

Keyboard shortcuts

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