api

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 52 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 api is Matinee's HTTP API and the host for the web player.

Index

Constants

View Source
const (
	TMDBKeyFromSettings    = "settings"
	TMDBKeyFromEnvironment = "environment" // MATINEE_TMDB_KEY or --tmdb-key
	TMDBKeyBuiltIn         = "built-in"
	TMDBKeyNone            = "none"
)

Where the TMDB key in use comes from (tmdbStatus.Source).

View Source
const APIVersion = 1

APIVersion is the version of the documented API served under /api/v1 (openapi.yaml). Changes within a version only add things; anything that would break an app goes in /api/v2.

View Source
const SettingHardwareAcceleration = "hardware_acceleration"

SettingHardwareAcceleration holds serverSettings.HardwareAcceleration. The server reads it at startup to set up the transcoder.

View Source
const SettingRemoteAccess = "remote_access"

SettingRemoteAccess holds serverSettings.RemoteAccess. The server reads it at startup.

View Source
const SettingRemoteForwardedPort = "remote_forwarded_port"

SettingRemoteForwardedPort holds serverSettings.RemoteForwardedPort.

View Source
const SettingTMDBKey = "tmdb_api_key"

SettingTMDBKey holds a TMDB key an admin entered in Settings. It wins over MATINEE_TMDB_KEY and a key built into the server; clearing it goes back to those.

Variables

This section is empty.

Functions

func LiveItem added in v0.1.1

func LiveItem(it store.Item) live.Item

LiveItem is how the feed describes an item.

func RemoteAccessOn

func RemoteAccessOn(ctx context.Context, s settingStore) (bool, error)

RemoteAccessOn reads the setting.

func RemoteForwardedPort added in v0.1.1

func RemoteForwardedPort(ctx context.Context, s settingStore) (int, error)

RemoteForwardedPort reads the setting: the router port an admin forwarded to the remote access port by hand, or 0.

func ServerUUID added in v0.1.1

func ServerUUID(ctx context.Context, db *store.Store) (string, error)

ServerUUID is this server's own id, made up the first time it runs. It stays the same when the server is renamed or moves.

func TMDBKey added in v0.1.1

func TMDBKey(ctx context.Context, st *store.Store, fallback string) (string, error)

TMDBKey is the key the server starts with: the one saved in Settings, or else fallback (from the environment or built in).

Types

type HomeRow

type HomeRow struct {
	ID    string `json:"id"` // e.g. "genre:Science Fiction"
	Title string `json:"title"`
	Genre string `json:"genre"`
	// CollectionID is set on the rows of collections pinned to Home.
	CollectionID string `json:"collectionId,omitempty"`
	// Starter is set on a built-in collection's row (see store.starters).
	Starter string `json:"starter,omitempty"`
	// Holiday is set on the row for a holiday coming up, e.g. "halloween"
	// (see holidays.go).
	Holiday string `json:"holiday,omitempty"`
	// RelatedTo is the title a related:{id} row is like, so apps can word
	// "More like …" in their own language.
	RelatedTo string       `json:"relatedTo,omitempty"`
	Items     []store.Item `json:"items"`
	// More says the row has more titles than it shows: GET /rows/{id} has
	// them all (see rows.go).
	More bool `json:"more,omitempty"`
}

HomeRow is one of the home screen's rows: a holiday's, a pinned collection or a genre.

type KeywordSource added in v0.1.1

type KeywordSource interface {
	Keywords(ctx context.Context, name string) ([]int64, error)
}

KeywordSource finds TMDB's keywords by name. *metadata.TMDB is one.

type PersonSource

type PersonSource interface {
	Person(ctx context.Context, id int64) (*store.PersonInfo, error)
}

PersonSource looks up people's biographies; metadata.TMDB is one.

type Server

type Server struct {
	Store   *store.Store
	Scanner *scan.Scanner
	Watcher *scan.Watcher // nil means libraries aren't watched for changes
	// ScanInterval is how often every library is rescanned; 0 means never.
	ScanInterval time.Duration
	Transcoder   *stream.Transcoder
	HW           *hwaccel.Manager // hardware transcoding; nil means the CPU only
	Downloads    *download.Manager
	Analyzer     *analyze.Analyzer // nil when media analysis is off for this server
	Art          *artwork.Cache
	Subtitles    *subtitle.Converter
	Web          fs.FS // built web player; nil serves a placeholder
	Log          *slog.Logger
	MediaRoot    string // where the folder picker starts; empty means /
	Name         string // what the apps call this server
	// UUID names this server for good, whatever its name or address (see
	// ServerUUID); Home Assistant tells servers apart by it.
	UUID string
	// TrailerSource lists trailers online; nil, or TMDB without a key,
	// offers none.
	TrailerSource TrailerSource
	// Keywords finds TMDB keywords for holiday rows; nil (or no TMDB key)
	// matches on words alone.
	Keywords KeywordSource
	// People has biographies; nil (or no TMDB key) shows only names and photos.
	People PersonSource
	// TMDB is the client whose key admins can change in Settings (see
	// tmdbkey.go); nil means it can't be changed here. TMDBFallback is the
	// key it goes back to when the one in Settings is cleared, and
	// TMDBFallbackSource where that one comes from (environment or built-in).
	TMDB               TMDBKeyHolder
	TMDBFallback       string
	TMDBFallbackSource string
	// OnTMDBKey runs after an admin changes the TMDB key.
	OnTMDBKey func()
	// ThemeDir holds the admin's own theme files (see themes.go); empty means
	// only the built-in themes.
	ThemeDir string

	// Remote keeps remote access going (see remote.go); nil when this
	// server doesn't offer it.
	Remote *remote.Manager
	// PublicURL is the address set with MATINEE_PUBLIC_URL, if any.
	PublicURL string
	// LookupHost resolves PublicURL's host; nil uses the system resolver.
	LookupHost func(ctx context.Context, host string) ([]string, error)

	// HomeListener means the home network has its own listener (HomeHandler),
	// so requests to the main one never count as coming from home.
	HomeListener bool

	// Translate looks up translations for every library, when people start
	// using a language; nil without an online provider that has them.
	Translate func(context.Context)

	// Plugins are the installed plugins (see plugins.go); nil means this
	// server doesn't run them. PluginCatalog lists the official ones; empty
	// for none.
	Plugins       *plugin.Manager
	PluginCatalog string

	// Live keeps track of open players and runs the event feed (see
	// live.go); nil makes one.
	Live *live.Hub

	// BackgroundCtx scopes scans started by API calls; it outlives any one request.
	BackgroundCtx context.Context
	// contains filtered or unexported fields
}

func (*Server) BurnStream

func (s *Server) BurnStream(ctx context.Context, it store.Item, track string) (int, bool)

BurnStream finds the embedded stream of a picture subtitle track, for the download converter.

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) HomeHandler

func (s *Server) HomeHandler() http.Handler

HomeHandler serves the same API as Handler, on the listener meant for the home network.

func (*Server) RemoteHandler

func (s *Server) RemoteHandler() http.Handler

RemoteHandler serves the same API as Handler, on the remote access port. Nothing that arrives there counts as coming from home.

type TMDBKeyHolder added in v0.1.1

type TMDBKeyHolder interface {
	Key() string
	SetKey(key string)
	// Check asks TMDB whether it accepts key.
	Check(ctx context.Context, key string) error
}

TMDBKeyHolder is the TMDB client whose key admins can change while the server runs. *metadata.TMDB is one.

type TrailerSource

type TrailerSource interface {
	Trailers(ctx context.Context, kind string, id int64, season int) ([]metadata.Video, error)
}

TrailerSource lists a title's trailers online. *metadata.TMDB is one.

Jump to

Keyboard shortcuts

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