api

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 88 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 HeaderRestarting = "Matinee-Restarting"

HeaderRestarting is on every answer once the server is shutting down, so a player hears about it from whatever it asks next.

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 CoverFinder added in v0.1.7

type CoverFinder interface {
	Find(ctx context.Context, q metadata.Query) []metadata.CoverOption
}

CoverFinder lists covers to pick from.

type DatabaseInfo added in v0.2.7

type DatabaseInfo struct {
	// DSN is the database in use; Configured is what the server's settings
	// say, an older database when it was moved and they weren't changed.
	DSN, Configured string
	// DataDir is the data folder, where a SQLite file goes by default.
	DataDir string
	// Kubernetes: the data folder is emptied whenever the pod is replaced,
	// so a SQLite file can't live there.
	Kubernetes bool
}

DatabaseInfo is where the server's database is.

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"`
	// Kind is set on the rows of Recently added split by kind
	// (recentlyAdded:{kind}), e.g. "movie", so apps can name them.
	Kind  string       `json:"kind,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 Matcher added in v0.2.0

type Matcher interface {
	Ready() bool
	Search(ctx context.Context, kind, title string, year int) ([]metadata.Candidate, error)
	Find(ctx context.Context, kind, ref string) (*store.Metadata, *metadata.Candidate, error)
}

Matcher searches the online database movies and shows are matched with.

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
	// Schedule rescans every library every so often; nil means never.
	Schedule   *scan.Schedule
	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
	// Thumbs makes and keeps the seek bar's pictures; nil offers none.
	Thumbs *thumbs.Generator
	Art    *artwork.Cache
	// Covers finds covers for admins to pick from; nil offers none online.
	Covers    CoverFinder
	Subtitles *subtitle.Converter
	// Levels works out songs' sound levels for the music visualizer; nil
	// means the visualizer has nothing to draw from.
	Levels *spectrum.Analyzer
	// Lyrics finds songs' words; nil offers none.
	Lyrics    *lyrics.Finder
	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
	// Matcher looks titles up for admins fixing a match (see match.go); nil
	// offers none. Refetch looks up what a library's titles still need
	// online, after a match changed; nil leaves it to the next scan.
	Matcher Matcher
	Refetch func(ctx context.Context, lib store.Library)
	// Connections knows which sites outside aren't answering (see
	// internal/netstate); nil reports none.
	Connections *netstate.Tracker
	// OnTMDBKey runs after an admin changes the TMDB key.
	OnTMDBKey func()
	// OnArr runs after an admin connects or disconnects Radarr or Sonarr.
	OnArr func()
	// ThemeDir holds the admin's own theme files (see themes.go); empty means
	// only the built-in themes.
	ThemeDir string

	// Games plays games on the server and streams them to players (see
	// games.go); nil when this server can't.
	Games *gamestream.Manager
	// GameHost plays PC games (internal/gamehost), when one is set up.
	GameHost *gamehost.Client
	// PlayStation plays a PlayStation on the home network (see
	// playstation.go); nil when this server can't.
	PlayStation *psremote.Bridge

	// 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

	// Together holds Watch together sessions (see together.go); nil makes one.
	Together *together.Hub

	// Podcasts follows podcast libraries' shows (see podcasts.go).
	// PodcastIndexBase is Podcast Index's API; empty is the real one.
	Podcasts         *podcast.Manager
	PodcastIndexBase string
	// RadioBase is Radio Browser's API, for finding stations; empty is the
	// real one. stationTitles has the song each station played last.
	RadioBase string

	// OpenSubtitlesBase is the OpenSubtitles API; empty is the real one.
	OpenSubtitlesBase string

	// LiveTV keeps live TV sources up to date (see livetv.go); nil makes
	// one that only refreshes when asked.
	LiveTV *livetv.Manager

	// BackgroundCtx scopes scans started by API calls; it outlives any one request.
	BackgroundCtx context.Context

	// Health keeps the admin dashboard's readings and log lines (see
	// health.go); nil makes one that has no log lines. Storage lists the
	// server's own folders, for its disk space.
	Health  *health.Monitor
	Storage []StoragePath

	// Alerts emails and posts to webhooks when something needs an admin
	// (see alerts.go); nil makes one that only sends while the API runs.
	Alerts *alerts.Manager
	// Backups makes and restores copies of a SQLite database; nil makes none.
	Backups *backup.Manager
	// Database is where the database is, for moving it (see database.go).
	Database DatabaseInfo
	// Updates looks for newer versions and installs them where it can.
	Updates *update.Manager
	// Restart stops the server and starts it again (cmd/matinee); nil
	// when it can't restart itself.
	Restart func()
	// contains filtered or unexported fields
}

func (*Server) AlertReadings added in v0.1.12

func (s *Server) AlertReadings(ctx context.Context) alerts.Readings

AlertReadings is the server now, for the alert rules.

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) Drain added in v0.1.4

func (s *Server) Drain()

Drain is the server starting to shut down, for an update or a restart: it stops counting as ready, players waiting for commands hear at once that it's restarting, and every answer says so too. Requests keep being served.

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) ReadBoxOffice added in v0.2.3

func (s *Server) ReadBoxOffice(ctx context.Context)

ReadBoxOffice reads what's new from each Box Office that Radarr or Sonarr connect to, once each when both go to the same one.

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.

func (*Server) ReportUnreadable added in v0.2.4

func (s *Server) ReportUnreadable(ctx context.Context, itemID int64)

ReportUnreadable reports a problem with a video the background jobs gave up reading as damaged, when a Box Office that fixes problems is connected and an admin turned this on (settingReplaceDamaged), so Box Office gets another copy by itself. It's filed once, in the name of the first admin, and not while the video has a problem reported already.

func (*Server) RunNotifications added in v0.2.3

func (s *Server) RunNotifications(ctx context.Context)

RunNotifications reads Box Office's notifications until ctx ends.

func (*Server) StreamCounts added in v0.1.11

func (s *Server) StreamCounts() (playing, transcodes int)

StreamCounts is how many players are playing now, and how many transcodes are running.

type StoragePath added in v0.1.11

type StoragePath struct {
	Use  string
	Path string
}

StoragePath is a folder the server keeps things in, for the dashboard's disk space list. Use names it: data, transcode, thumbnails, images or downloads.

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