Documentation
¶
Overview ¶
Package api is Matinee's HTTP API and the host for the web player.
Index ¶
- Constants
- func LiveItem(it store.Item) live.Item
- func RemoteAccessOn(ctx context.Context, s settingStore) (bool, error)
- func RemoteForwardedPort(ctx context.Context, s settingStore) (int, error)
- func ServerUUID(ctx context.Context, db *store.Store) (string, error)
- func TMDBKey(ctx context.Context, st *store.Store, fallback string) (string, error)
- type CoverFinder
- type HomeRow
- type KeywordSource
- type Matcher
- type PersonSource
- type Server
- func (s *Server) AlertReadings(ctx context.Context) alerts.Readings
- func (s *Server) BurnStream(ctx context.Context, it store.Item, track string) (int, bool)
- func (s *Server) Drain()
- func (s *Server) Handler() http.Handler
- func (s *Server) HomeHandler() http.Handler
- func (s *Server) RemoteHandler() http.Handler
- func (s *Server) StreamCounts() (playing, transcodes int)
- type StoragePath
- type TMDBKeyHolder
- type TrailerSource
Constants ¶
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).
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.
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.
const SettingHardwareAcceleration = "hardware_acceleration"
SettingHardwareAcceleration holds serverSettings.HardwareAcceleration. The server reads it at startup to set up the transcoder.
const SettingRemoteAccess = "remote_access"
SettingRemoteAccess holds serverSettings.RemoteAccess. The server reads it at startup.
const SettingRemoteForwardedPort = "remote_forwarded_port"
SettingRemoteForwardedPort holds serverSettings.RemoteForwardedPort.
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 RemoteAccessOn ¶
RemoteAccessOn reads the setting.
func RemoteForwardedPort ¶ added in v0.1.1
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
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.
Types ¶
type CoverFinder ¶ added in v0.1.7
CoverFinder lists covers to pick from.
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
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 ¶
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
// 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
// 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
// contains filtered or unexported fields
}
func (*Server) AlertReadings ¶ added in v0.1.12
AlertReadings is the server now, for the alert rules.
func (*Server) BurnStream ¶
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) HomeHandler ¶
HomeHandler serves the same API as Handler, on the listener meant for the home network.
func (*Server) RemoteHandler ¶
RemoteHandler serves the same API as Handler, on the remote access port. Nothing that arrives there counts as coming from home.
func (*Server) StreamCounts ¶ added in v0.1.11
StreamCounts is how many players are playing now, and how many transcodes are running.
type StoragePath ¶ added in v0.1.11
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.
Source Files
¶
- alerts.go
- analysis.go
- api.go
- arr.go
- backups.go
- books.go
- collections.go
- cors.go
- covers.go
- devices.go
- diagnose.go
- discover.go
- downloads.go
- drain.go
- extras.go
- filters.go
- friends.go
- fs_other.go
- gapless.go
- health.go
- holidays.go
- home.go
- homerows.go
- imports.go
- languages.go
- live.go
- livetv.go
- lyrics.go
- markwatched.go
- match.go
- metrics.go
- next.go
- people.go
- playlists.go
- plugins.go
- podcasts.go
- profiles.go
- quality.go
- radio.go
- ratings.go
- remote.go
- rows.go
- signin.go
- subsync.go
- subtitlesearch.go
- themes.go
- thumbnails.go
- tmdbkey.go
- together.go
- trailers.go
- users.go
- versions.go
- voice.go
- watchlist.go