store

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 30 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 store keeps all server state in a single SQLite database.

Index

Constants

View Source
const (
	OrderAired    = "aired"    // the seasons as they aired (the default)
	OrderDVD      = "dvd"      // the seasons of the DVD and Blu-ray sets
	OrderAbsolute = "absolute" // one long season, numbered from the first
)

Episode orders a show's absolute-numbered episodes can be put in.

View Source
const (
	CollectionSmart  = "smart"
	CollectionManual = "manual"
)
View Source
const (
	DownloadQueued    = "queued"    // waiting for the converter
	DownloadPreparing = "preparing" // being converted or checksummed
	DownloadReady     = "ready"     // File can be fetched
	DownloadFailed    = "failed"    // see Error; asking again retries
	DownloadExpired   = "expired"   // the device has it and the server's copy was cleaned up
)

Download states.

View Source
const (
	PreferLocal  = ""          // files next to the media, then online (the default)
	PreferOnline = "online"    // online details win over the files
	LocalOnly    = "localOnly" // only the files: nothing is looked up online
)

Metadata modes of a library: where a title's details come from first.

View Source
const (
	FieldTitle    = "title"
	FieldYear     = "year"
	FieldOverview = "overview"
	FieldGenres   = "genres"
	FieldRating   = "rating"
	FieldPoster   = "poster"
	FieldBackdrop = "backdrop"
	// FieldPeople is the cast and crew, which only a file sets.
	FieldPeople = "people"
)

Editable fields: the ones an .nfo file or an admin can set.

View Source
const (
	// SettingMovedTo, in the old database, is the new database's address.
	SettingMovedTo = "database_moved_to"
	// SettingMovedFrom, in the new database, says where it was moved from
	// (without a password) and when, as JSON.
	SettingMovedFrom = "database_moved_from"
	// SettingMovePending is a move an admin asked for in Settings, which
	// the server makes the next time it starts, before anything else uses
	// the database.
	SettingMovePending = "database_move_pending"
	// SettingMoveError is why the last move failed.
	SettingMoveError = "database_move_error"
)

Settings that belong to one database and aren't copied to the new one.

View Source
const (
	NotificationInfo     = "info"
	NotificationWarning  = "warning"
	NotificationCritical = "critical"
)

Notification levels.

View Source
const (
	LibraryAll   = "all"   // everything in it, rated or not
	LibraryRated = "rated" // titles rated up to the profile's level
)

Library modes for kids profiles. A library without one is hidden.

View Source
const (
	RequestPending  = "pending"  // waiting for an admin
	RequestApproved = "approved" // added to Radarr or Sonarr
	RequestDeclined = "declined"
	RequestFailed   = "failed" // adding it failed; see Error. Approving again retries.
)

Request states.

View Source
const (
	AskEdition = "edition"
	AskBetter  = "better"
	AskReplace = "replace"
)

What a request asks Box Office for, beyond adding a title.

View Source
const DefaultKeep = 3

DefaultKeep is how many newest episodes a show keeps until the person picks.

View Source
const FactPlatform = "system"

FactPlatform labels the system a game is for, such as Super Nintendo (gamelib.FactSystem); games are filtered by it.

View Source
const (
	// IssueReplaced: another copy took the reported one's place.
	IssueReplaced = "replaced"
)

Issue resolutions.

View Source
const LiveBrokenAfter = 2

LiveBrokenAfter is how many checks in a row a channel fails before it's hidden.

View Source
const QualityOriginal = "original"

QualityOriginal downloads the file as it is, unconverted.

Variables

View Source
var (
	ErrCodeExpired = errors.New("code expired")
	ErrCodeDenied  = errors.New("sign-in was declined")
	ErrCodePending = errors.New("waiting for approval")
)
View Source
var (
	// ErrInviteUsed means someone already made an account with the invite.
	ErrInviteUsed = errors.New("this invite was already used")
	// ErrInviteExpired means the invite is too old.
	ErrInviteExpired = errors.New("this invite has expired")
	// ErrUsernameTaken means another account has the name.
	ErrUsernameTaken = errors.New("that username is taken")
)
View Source
var CollectionSorts = map[string]bool{
	"title": true, "added": true, "released": true, "year": true, "rating": true,
	"runtime": true, "lastPlayed": true, "shuffle": true,
}

CollectionSorts are the orders a collection can have besides its own: a smart collection's filter order or a manual one's hand-kept order. "shuffle" is a different order each day.

View Source
var ErrAdminFriend = errors.New("admins see every library; make them a regular account first")

ErrAdminFriend means an admin can't be limited to some libraries.

View Source
var ErrBackupUnsupported = errors.New("backups are made for SQLite; back up PostgreSQL with pg_dump")

ErrBackupUnsupported: Matinee copies SQLite databases itself; a PostgreSQL database is backed up with pg_dump.

View Source
var ErrBadRating = errors.New("a rating is from 1 to 10")

ErrBadRating means a rating isn't a whole number from 1 to 10.

View Source
var ErrLastAdmin = errors.New("the server needs at least one admin")

ErrLastAdmin means a change would leave the server with no admin.

View Source
var ErrNotEmpty = errors.New("that database already has Matinee's data in it; move to an empty database")

ErrNotEmpty: the database to move to already has Matinee's data in it.

View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrPodcastTitleTaken = errors.New("this library already has a show with that name")

ErrPodcastTitleTaken means the library already has a different show with the same name.

View Source
var ErrStationTaken = errors.New("that station is already in the library")

ErrStationTaken means the library has that stream already.

View Source
var FixableIssues = []string{"video", "audio", "language", "wrong"}

FixableIssues are the kinds Box Office fixes by itself, by getting another copy: the others wait for an admin.

View Source
var IssueKinds = []string{"video", "audio", "language", "subtitles", "wrong", "other"}

Issue kinds. "language" is sound in the wrong language.

View Source
var KeepChoices = []int{1, 2, 3, 5, 10}

KeepChoices are how many of a show's newest episodes phones may keep.

View Source
var NoTrackChoice = TrackChoice{Audio: -1}

NoTrackChoice is a choice with nothing picked.

View Source
var RatableKinds = map[string]bool{
	"movie": true, "show": true, "season": true, "episode": true,
	"artist": true, "album": true, "track": true, "book": true,
	"podcast": true, "podcastEpisode": true,
}

RatableKinds are what can be rated.

View Source
var RecentlyAddedKinds = []string{"movie", "show", "album", "book", "podcast"}

RecentlyAddedKinds are the kinds Home splits Recently added into, in the order its rows come: movies, TV shows, albums, audiobooks and podcasts.

View Source
var SortFields = []string{"title", "added", "released", "year", "rating", "myRating", "runtime", "lastPlayed", "series"}

SortFields are the orders a filter can list titles in.

View Source
var WatchListKinds = map[string]bool{"movie": true, "show": true}

WatchListKinds are what can go on a watch list: things you sit down to watch, not their seasons, episodes or music.

View Source
var WatchedStates = []string{"unwatched", "inProgress", "watched", "notStarted", "started"}

WatchedStates are the values ItemFilter.Watched takes.

Functions

func CheckSQLite added in v0.2.0

func CheckSQLite(ctx context.Context, path string) error

CheckSQLite says whether the file at path is a SQLite database Matinee made, as one being restored must be.

func ChosenID added in v0.1.7

func ChosenID(poster string) (int64, bool)

ChosenID returns the item whose picked cover a poster value names.

func CopySQLite added in v0.2.0

func CopySQLite(ctx context.Context, from, to string) error

CopySQLite copies the SQLite database at from (with anything still in its write-ahead log) to the new file to, without Matinee having it open.

func Describe added in v0.2.7

func Describe(dsn string) string

Describe is where dsn is, for people to read: a PostgreSQL URL without its password, or a SQLite file's path.

func EpisodeURL added in v0.1.7

func EpisodeURL(path string) string

EpisodeURL is where an episode's audio is: its path without the #fragment that keeps it unique.

func Follow added in v0.2.7

func Follow(ctx context.Context, dsn string, o Options) (string, error)

Follow is the database Matinee uses when it's set up with dsn: dsn, or where it was moved to (and where that was moved to, and so on).

func FormatUserCode

func FormatUserCode(code string) string

FormatUserCode shows a user code as ABCD-EFGH.

func GaplessKey added in v0.1.13

func GaplessKey(version int, tracks []GaplessTrack) string

GaplessKey names an album's files as they are now, so the detector listens again when songs are added, removed or changed.

func IsPostgres added in v0.2.7

func IsPostgres(dsn string) bool

IsPostgres says whether dsn is a PostgreSQL URL (otherwise it's a SQLite file).

func IsRemote added in v0.1.7

func IsRemote(path string) bool

IsRemote says whether an item's path is an address on the internet rather than a file on the server, as podcast episodes' are.

func LanguageFrom added in v0.1.1

func LanguageFrom(ctx context.Context) string

LanguageFrom returns the language WithLanguage set, or "".

func LetterOf added in v0.2.4

func LetterOf(sortTitle string) string

LetterOf is the letter a sort title files under: its first letter without accents and in capitals, or # when it starts with anything else.

func LiveChannelID added in v0.2.0

func LiveChannelID(sourceID, streamURL string) string

LiveChannelID is the id a channel gets from its source and stream.

func LocalPersonID added in v0.2.4

func LocalPersonID(name string) int64

LocalPersonID is the id of a person a file next to the media credits without their TMDB id: below zero, so it's never a TMDB person's, and the same for the same name in every file, so their page lists all their titles.

func MediaKey

func MediaKey(version int, size, mtime int64) string

MediaKey identifies one version of a file, as analyzed by one version of the analysis. The scanner updates size and mtime when a file changes.

func MovedTo added in v0.2.7

func MovedTo(ctx context.Context, dsn string, o Options) (string, error)

MovedTo is where the database at dsn was moved to, or "" if it wasn't. It reads the note without opening the database the usual way, so the old database isn't upgraded or changed. It waits for a PostgreSQL server like OpenWith does.

func NormalizeInviteCode added in v0.1.10

func NormalizeInviteCode(code string) string

NormalizeInviteCode takes a code as someone typed or pasted it.

func NormalizeUserCode

func NormalizeUserCode(code string) string

NormalizeUserCode accepts a typed code in any case, with or without the dash or spaces.

func NotifyMeKey added in v0.2.3

func NotifyMeKey(kind string, tmdbID, tvdbID int) string

NotifyMeKey names a title for NotifyMeTitles.

func PairHash added in v0.1.13

func PairHash(pair string) string

PairHash is how a pairing secret is kept: only the device and the phone that scanned its QR code know the secret itself.

func Replacements added in v0.2.0

func Replacements(files []LibraryFile, missing map[int64]bool) map[int64]int64

Replacements pairs each missing file with the file that took its place: another file of the library with the same key that isn't missing itself. The map goes from the missing file's id to its replacement's.

Files with the same key can also be versions of one item (see GroupVersions). A missing version is simply removed, since what people did with it is kept on its item. A missing item takes one of the files still there, preferring one that isn't a version of anything yet (most likely the new copy), so its id and everyone's history stay even when it had versions. When more items than files went missing for one key, none are paired, since it can't be told which took which.

func SchemaTarget added in v0.2.0

func SchemaTarget() int

SchemaTarget is the schema version this Matinee migrates databases to.

func SessionID

func SessionID(token string) string

SessionID is the public id of a session token.

func SortTitle

func SortTitle(title string) string

SortTitle drops a leading article so "The Matrix" sorts under M.

func UndoMove added in v0.2.7

func UndoMove(ctx context.Context, dsn string) error

UndoMove takes the note about a move away from the database at dsn, so Matinee uses it again, as it was before the move.

func ValidEpisodeOrder added in v0.2.4

func ValidEpisodeOrder(o string) bool

ValidEpisodeOrder reports whether o is an episode order.

func ValidKeep added in v0.1.13

func ValidKeep(n int) bool

ValidKeep says whether n is one of KeepChoices.

func ValidMetadataMode added in v0.2.4

func ValidMetadataMode(m string) bool

ValidMetadataMode reports whether m is a metadata mode.

func WithLanguage added in v0.1.1

func WithLanguage(ctx context.Context, language string) context.Context

WithLanguage makes items read with ctx come in a language, one of the i18n languages. "" or English shows them as they are.

Types

type AbsoluteEpisode added in v0.2.4

type AbsoluteEpisode struct {
	ID      int64
	Number  int
	Compact bool // the number might be a season and episode run together
}

AbsoluteEpisode is an episode named by its number from the show's first.

type Added added in v0.2.3

type Added int

Added says what AddNotification did.

const (
	NotAdded  Added = iota // they have it from that source already
	AddedNew               // it's new
	Repeated               // it's the same as one they have, which now counts it
	Escalated              // it's a repeat, and more serious than before
)

type AlbumFiles added in v0.1.7

type AlbumFiles struct {
	ID       int64
	Title    string
	ArtistID int64
	Artist   string
	Paths    []string
}

AlbumFiles is an album with its artist and the paths of its tracks.

type AlbumToRead added in v0.1.15

type AlbumToRead struct {
	ID   int64
	Path string
}

AlbumToRead is an album and one of its files.

type AnalysisFile

type AnalysisFile struct {
	ID    int64
	Title string
	Path  string
	Size  int64
	Mtime int64
	Key   string // media_key as stored, "" when never analyzed
}

AnalysisFile is a file the background analysis may need to look at.

type ArtlessContainer added in v0.1.3

type ArtlessContainer struct {
	ID    int64
	Paths []string
}

ArtlessContainer is an album or book without a cover from its own files, and the files under it, to look for one in their folders.

type Award

type Award struct {
	Name  string   `json:"name"` // e.g. Academy Award for Best Picture
	Year  int      `json:"year,omitempty"`
	Won   bool     `json:"won"`
	Names []string `json:"names,omitempty"` // the people it went to, when not the title itself
}

type Book added in v0.1.2

type Book struct {
	Item
	Parts    []BookPart    `json:"parts"`
	Chapters []BookChapter `json:"chapters"`
}

Book is a book with its parts in order and its chapters.

type BookChapter added in v0.1.2

type BookChapter struct {
	Title   string `json:"title"`
	StartMs int64  `json:"startMs"`
	EndMs   int64  `json:"endMs"`
	PartID  int64  `json:"partId"`
}

BookChapter is a chapter on the book's own clock, which runs across its parts.

type BookGroup added in v0.1.2

type BookGroup struct {
	Name  string  `json:"name"`
	Books int     `json:"books"`
	Items []int64 `json:"itemIds"` // up to four books, first in reading order
}

BookGroup is a series or a narrator, with how many books it has and a few of them for artwork.

type BookInfo added in v0.1.2

type BookInfo struct {
	Narrators   []string
	Series      string
	SeriesIndex *float64 // its place in the series, such as 2 or 2.5
	Overview    string
}

BookInfo is what a book's files say about it.

type BookPart added in v0.1.2

type BookPart struct {
	Item
	StartMs int64 `json:"startMs"`
}

BookPart is one file of a book, and where on the book's clock it starts.

type BoxSet

type BoxSet struct {
	ID    int64  `json:"id"` // TMDB collection id
	Name  string `json:"name"`
	Count int    `json:"count"`
	// ItemIDs are its titles in the library, oldest first, for artwork.
	ItemIDs []int64 `json:"itemIds"`
}

BoxSet is one of TMDB's collections, such as a trilogy, with at least two of its titles in the library. Box sets fill themselves from metadata.

type ChosenImage added in v0.1.7

type ChosenImage struct {
	Data        []byte
	ContentType string
	Source      string // the URL it came from, or "upload"
}

ChosenImage is a cover an admin picked.

type Collection

type Collection struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

Collection is a series of movies, such as a franchise's films.

type Counts added in v0.2.3

type Counts struct {
	// Items is how many items there are of each kind (movie, show, episode,
	// artist, album, track, book, podcast...), leaving out extra versions
	// of the same title.
	Items     map[string]int
	Users     int // accounts, without guests and profiles
	Libraries int
}

Counts is what a dashboard shows of the server's contents.

type Credit

type Credit struct {
	PersonID int64  `json:"personId"`
	Name     string `json:"name"`
	Role     string `json:"role,omitempty"` // character, or job such as Director
	// Department groups crew: Directing, Writing, Sound, Camera, Production…
	Department string `json:"department,omitempty"`
	Episodes   int    `json:"episodes,omitempty"` // for a show's cast: how many episodes they're in
	HasPhoto   bool   `json:"hasPhoto"`

	Photo string `json:"-"` // URL
}

Credit is one person's part in a title: a character they play, or a job.

type Credits

type Credits struct {
	Cast []Credit `json:"cast"`
	// Guests are an episode's guest stars.
	Guests []Credit `json:"guests,omitempty"`
	Crew   []Credit `json:"crew"`
}

Credits are the people in a title, in billing order.

type CreditsVideo added in v0.1.13

type CreditsVideo struct {
	ID int64
	// Group is the season for an episode, whose episodes are compared with
	// each other, and the movie itself for a movie.
	Group      int64
	Kind       string // episode or movie
	Title      string
	Path       string
	Size       int64
	Mtime      int64
	DurationMs int64
	Index      int    // episode number, 0 when unknown
	Key        string // file_key as stored, "" when never looked at
	StartMs    int64
	EndMs      int64
	// MediaInfo is the media analysis' JSON, which says where a chapter
	// titled Credits starts, if any (see probe.MediaInfo).
	MediaInfo string
}

CreditsVideo is an episode or movie the credits detector may look at.

type DatabaseInfo added in v0.1.11

type DatabaseInfo struct {
	Kind    string `json:"kind"` // sqlite or postgres
	Version string `json:"version,omitempty"`
	// Size is the database's size in bytes; 0 when unknown.
	Size int64 `json:"size"`
	// Schema is how many of Matinee's migrations it has.
	Schema int `json:"schema"`
	// PingMs is how long a trivial query took.
	PingMs float64 `json:"pingMs"`
	// Connections: open, in use, and how often a query had to wait for one
	// and for how long in all.
	OpenConns int     `json:"openConns"`
	InUse     int     `json:"inUse"`
	WaitCount int64   `json:"waitCount"`
	WaitMs    float64 `json:"waitMs"`
	Items     int     `json:"items"`
	Users     int     `json:"users"`
	Libraries int     `json:"libraries"`
}

DatabaseInfo describes the database for the admin dashboard.

type Details

type Details struct {
	Tagline          string      `json:"tagline,omitempty"`
	OriginalTitle    string      `json:"originalTitle,omitempty"`
	OriginalLanguage string      `json:"originalLanguage,omitempty"` // a language name, e.g. Japanese
	ReleaseDate      string      `json:"releaseDate,omitempty"`      // YYYY-MM-DD; first air date for shows
	EndDate          string      `json:"endDate,omitempty"`          // last air date of a show that ended
	Status           string      `json:"status,omitempty"`           // e.g. Released, Returning Series, Ended
	Certification    string      `json:"certification,omitempty"`    // e.g. PG-13 or TV-MA
	Genres           []string    `json:"genres,omitempty"`
	Studios          []string    `json:"studios,omitempty"`
	Networks         []string    `json:"networks,omitempty"`
	Countries        []string    `json:"countries,omitempty"`
	Languages        []string    `json:"languages,omitempty"` // spoken languages
	Budget           int64       `json:"budget,omitempty"`    // US dollars
	Revenue          int64       `json:"revenue,omitempty"`   // worldwide box office, US dollars
	Collection       *Collection `json:"collection,omitempty"`
	Seasons          int         `json:"seasons,omitempty"`
	Episodes         int         `json:"episodes,omitempty"`
	IMDbID           string      `json:"imdbId,omitempty"`
	WikidataID       string      `json:"wikidataId,omitempty"`
	// Awards are the wins and nominations Wikidata knows of, wins first.
	Awards []Award `json:"awards,omitempty"`
	// AwardSummary is one line for the main details pane, e.g. "Won 4
	// Academy Awards" or "12 wins and 30 nominations".
	AwardSummary string `json:"awardSummary,omitempty"`
}

Details is the longer description of a movie, show or episode that the details pages show: everything beyond the title, overview and artwork.

type DetailsUpdate

type DetailsUpdate struct {
	Details Details
	Cast    []Credit
	Guests  []Credit
	Crew    []Credit
	Terms   []Term
	// RatingLevel is the level of Details.Certification (see the rating package).
	RatingLevel int
}

DetailsUpdate is what a provider knows about a title beyond Metadata.

type Device

type Device struct {
	Name     string
	Platform string // ios, android, web, tv…
}

Device names the app or browser a session belongs to.

type DeviceCode

type DeviceCode struct {
	DeviceCode string // secret; only the device has it
	UserCode   string // what the person types, without the dash
	Device     Device
	ExpiresAt  time.Time
}

type Download

type Download struct {
	ID       string `json:"id"`
	ItemID   int64  `json:"itemId"`
	DeviceID string `json:"deviceId"`
	Quality  string `json:"quality"`
	Subtitle string `json:"subtitle,omitempty"` // a picture subtitle track drawn into the video
	State    string `json:"state"`
	Progress int    `json:"progress"` // thousandths, while preparing
	Error    string `json:"error,omitempty"`
	Size     int64  `json:"size,omitempty"`
	SHA256   string `json:"sha256,omitempty"`
	// MD5 is there for devices that can hash a file natively only with MD5;
	// it guards against a broken transfer, not tampering.
	MD5        string `json:"md5,omitempty"`
	MimeType   string `json:"mimeType,omitempty"`
	CreatedAt  int64  `json:"createdAt"`
	UpdatedAt  int64  `json:"updatedAt"`
	FinishedAt int64  `json:"finishedAt,omitempty"` // when the device said it has the whole file

	UserID   int64  `json:"-"`
	Attempts int    `json:"-"`
	File     string `json:"-"` // the prepared file's path: the original, or one in the download cache
	// The original's size and mtime when File was named, to notice it changing.
	SourceSize  int64 `json:"-"`
	SourceMtime int64 `json:"-"`
}

type Edit added in v0.2.4

type Edit struct {
	Title    *string   `json:"title,omitempty"`
	Year     *int      `json:"year,omitempty"`
	Overview *string   `json:"overview,omitempty"`
	Genres   *[]string `json:"genres,omitempty"`
	Rating   *float64  `json:"rating,omitempty"`
}

Edit is an admin's change to a title's details. Nil fields stay as they are.

type EpisodeInfo added in v0.1.7

type EpisodeInfo struct {
	Link string `json:"link,omitempty"`
	// Type is full, trailer or bonus.
	Type string `json:"episodeType"`
}

EpisodeInfo is what an episode's page shows besides the item itself.

type Fact added in v0.1.1

type Fact struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

Fact is one labelled line about an item.

type FilePart added in v0.2.4

type FilePart struct {
	Path       string `json:"-"`
	DurationMs int64  `json:"durationMs"`
	Size       int64  `json:"size"`
}

FilePart is one file of a movie in parts.

type FileRef added in v0.1.9

type FileRef struct {
	ID              int64
	Path            string
	Kind            string
	ParentID        int64
	ParentKind      string
	GrandparentID   int64
	GrandparentKind string
}

FileRef is a file Matinee knows and the two items above it (a season and show, an album and artist, a book and author), for matching another server's records to Matinee's items by path (see the importer package).

type FilterOptions

type FilterOptions struct {
	Genres         []FilterValue  `json:"genres"`
	Tags           []FilterValue  `json:"tags"`
	Studios        []FilterValue  `json:"studios"`
	Countries      []FilterValue  `json:"countries"`
	Languages      []FilterValue  `json:"languages"`
	Certifications []FilterValue  `json:"certifications"`
	Collections    []FilterValue  `json:"collections"`
	Platforms      []FilterValue  `json:"platforms"` // games' systems
	Directors      []FilterPerson `json:"directors"` // the most frequent
	Cast           []FilterPerson `json:"cast"`      // the most frequent
	YearMin        int            `json:"yearMin,omitempty"`
	YearMax        int            `json:"yearMax,omitempty"`
	HasRatings     bool           `json:"hasRatings"`
	HasRuntimes    bool           `json:"hasRuntimes"`
	HasReleased    bool           `json:"hasReleased"`
}

FilterOptions says what a library's titles can be filtered by: the values present, most common first, and the range of years, ratings and runtimes.

type FilterPerson

type FilterPerson struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	HasPhoto bool   `json:"hasPhoto"`
	Count    int    `json:"count"` // titles they're in
}

FilterPerson is someone credited in a library.

type FilterValue

type FilterValue struct {
	Value string `json:"value"`
	Label string `json:"label,omitempty"` // when the value is an id
	Count int    `json:"count"`
}

FilterValue is one value a filter field can take in a library, and how many titles have it.

type FoundSubtitle added in v0.1.10

type FoundSubtitle struct {
	ID       string
	ItemID   int64
	Language string
	Label    string
	Release  string
	SDH      bool
	Forced   bool
	Source   string
	Data     []byte
	Format   string
	AddedBy  int64
	AddedAt  int64
}

FoundSubtitle is a subtitle file found online for a video.

type GameVersion added in v0.2.7

type GameVersion struct {
	ID   int64
	Path string
	// Data is what the Games library keeps with the game (PluginData).
	Data      json.RawMessage
	VersionOf int64
	// OldEdition is its edition now; Edition is for the caller to fill.
	OldEdition string
	Edition    string
}

GameVersion is a game file of a library, for grouping a game's versions (its regions, revisions or arcade clones) as one title.

type GaplessAlbum added in v0.1.13

type GaplessAlbum struct {
	ID     int64
	Title  string
	Artist string
	Tracks []GaplessTrack
	// Key is what the detector last listened to (see GaplessKey).
	Key string
}

GaplessAlbum is an album to listen to, with its songs in playing order.

type GaplessTrack added in v0.1.13

type GaplessTrack struct {
	ID         int64
	Path       string
	DurationMs int64
	Disc       int
	Size       int64
	Mtime      int64
}

type HolidayMatch added in v0.1.1

type HolidayMatch struct {
	Words    []string
	Keywords []string // TMDB keyword ids, as kept in item_terms
}

HolidayMatch says which movies suit a holiday. A title matches when it has one of the TMDB keywords, or one of the words is in its title or overview. Words are matched without regard to case.

type IntroEpisode added in v0.1.10

type IntroEpisode struct {
	ID         int64
	SeasonID   int64
	Title      string
	Path       string
	Size       int64
	Mtime      int64
	DurationMs int64
	Index      int    // episode number, 0 when unknown
	Key        string // file_key as stored, "" when never looked at
	StartMs    int64
	EndMs      int64
	// MediaInfo is the media analysis' JSON, which says where a chapter
	// titled Intro is, if any (see probe.MediaInfo).
	MediaInfo string
}

IntroEpisode is an episode the intro detector may look at.

type Invite added in v0.1.10

type Invite struct {
	Code      string  `json:"code"`
	Name      string  `json:"name,omitempty"` // who it's for, as the admin wrote it
	Libraries []int64 `json:"libraries"`
	CreatedBy string  `json:"createdBy,omitempty"`
	CreatedAt int64   `json:"createdAt"`
	ExpiresAt int64   `json:"expiresAt"`
	// UsedBy is the account made from it, once someone used it.
	UsedBy string `json:"usedBy,omitempty"`
	UsedAt int64  `json:"usedAt,omitempty"`
}

Invite is a link an admin made to let one friend in.

type Issue

type Issue struct {
	ID         string `json:"id"`
	ItemID     int64  `json:"itemId"`
	Kind       string `json:"kind"` // one of IssueKinds
	Note       string `json:"note,omitempty"`
	Resolved   bool   `json:"resolved"`
	Resolution string `json:"resolution,omitempty"` // replaced, or empty when an admin just closed it
	UserID     int64  `json:"userId"`
	Username   string `json:"username"`
	CreatedAt  int64  `json:"createdAt"`
	ResolvedAt int64  `json:"resolvedAt,omitempty"`
	// Language is the language (ISO 639-1) the sound should be in, for
	// the wrong language.
	Language string `json:"language,omitempty"`
	// RequestID is the request for another copy sent to Box Office for
	// it, if any, and FileKey the reported file (see FileKey), to tell
	// when another has taken its place.
	RequestID string `json:"requestId,omitempty"`
	FileKey   string `json:"-"`
}

type Item

type Item struct {
	ID          int64    `json:"id"`
	LibraryID   int64    `json:"libraryId"`
	ParentID    *int64   `json:"parentId,omitempty"`
	Kind        string   `json:"kind"`
	Title       string   `json:"title"`
	Year        *int     `json:"year,omitempty"`
	IndexNumber *int     `json:"index,omitempty"`
	DiscNumber  *int     `json:"disc,omitempty"`
	DurationMs  *int64   `json:"durationMs,omitempty"`
	Container   string   `json:"container,omitempty"`
	VideoCodec  string   `json:"videoCodec,omitempty"`
	AudioCodec  string   `json:"audioCodec,omitempty"`
	Width       *int     `json:"width,omitempty"`
	Height      *int     `json:"height,omitempty"`
	AddedAt     int64    `json:"addedAt"`
	Playable    bool     `json:"playable"`
	ChildCount  int      `json:"childCount,omitempty"`
	PositionMs  int64    `json:"positionMs,omitempty"`
	Played      bool     `json:"played,omitempty"`
	Overview    string   `json:"overview,omitempty"`
	Rating      *float64 `json:"rating,omitempty"`
	// MyRating is the person's own rating, 1 to 10 (half stars out of
	// five); nil when they haven't rated it.
	MyRating  *int `json:"myRating,omitempty"`
	HasPoster bool `json:"hasPoster"`
	// PosterTag changes with a cover an admin picked, for clients to add
	// to the image URL as ?v= so they don't show the old one from a cache.
	PosterTag   string `json:"posterTag,omitempty"`
	HasBackdrop bool   `json:"hasBackdrop"`
	// For episodes: the show's title and season number, for cards outside the show's pages.
	ShowTitle   string `json:"showTitle,omitempty"`
	SeasonIndex *int   `json:"seasonIndex,omitempty"`

	// For albums and tracks: who made it, and for tracks the album it's
	// on (the album's id is ParentID), so a player can say what's playing.
	// A track on a soundtrack or compilation names its own artist, with
	// that artist's id only when the library has a page for them. The
	// scanner sets Artist on a track only when it isn't the album's.
	Artist   string `json:"artist,omitempty"`
	ArtistID *int64 `json:"artistId,omitempty"`
	Album    string `json:"album,omitempty"`
	// RecordLabel is the label an album, or a song's album, came out on.
	RecordLabel string `json:"recordLabel,omitempty"`
	// VersionOf is the item a file is another version of: the same movie
	// or episode in another file, such as a 4K copy or an extended cut.
	// Lists show only that item, and watched marks, places to resume from,
	// ratings and watch lists are kept on it for every version. See
	// GroupVersions.
	VersionOf *int64 `json:"versionOf,omitempty"`
	// Edition is the cut a version's file name names, such as "Director's Cut".
	Edition string `json:"edition,omitempty"`
	// Parts are the files of a movie that comes in parts (CD1, CD2), in
	// order, the movie's own first; absent for a movie in one file. See
	// GroupParts.
	Parts []FilePart `json:"parts,omitempty"`
	// LockedFields are the details an admin edited by hand, which no
	// lookup changes; LocalFields the ones an .nfo file next to it set.
	LockedFields []string `json:"lockedFields,omitempty"`
	LocalFields  []string `json:"localFields,omitempty"`
	// For books and their parts: who wrote it, and for a part the book's
	// title (the book's id is ParentID). Books also name their narrators
	// and their place in a series, such as 2 or 2.5.
	Author      string   `json:"author,omitempty"`
	AuthorID    *int64   `json:"authorId,omitempty"`
	Book        string   `json:"book,omitempty"`
	Narrators   []string `json:"narrators,omitempty"`
	Series      string   `json:"series,omitempty"`
	SeriesIndex *float64 `json:"seriesIndex,omitempty"`
	// For podcasts and their episodes: who makes the show, and for an
	// episode the show's title (the show's id is ParentID) and the day it
	// came out, as 2006-01-02.
	Podcast     string `json:"podcast,omitempty"`
	Released    string `json:"released,omitempty"`
	OnWatchList bool   `json:"onWatchList,omitempty"`
	// Genres of a movie or show, from its online match.
	Genres []string `json:"genres,omitempty"`
	// MediaTags sums up what the background analysis found, such as 4k,
	// hdr, dolby-vision, atmos or 5.1 (see probe.MediaInfo.Tags). Shows get
	// every tag any of their episodes has. Empty until analyzed.
	MediaTags []string `json:"mediaTags,omitempty"`
	// Gapless says an album's songs play straight into each other, with no
	// gap between them, as on a DJ mix or a live album; tracks say it of
	// their album. Players then play the album's songs as one continuous
	// stream (see Server.startGapless). GaplessChoice is the household's
	// own choice for an album, nil when Matinee decides; GaplessFound says
	// Matinee found the songs run into each other (see internal/gapless).
	Gapless       bool  `json:"gapless,omitempty"`
	GaplessChoice *bool `json:"gaplessChoice,omitempty"`
	GaplessFound  bool  `json:"gaplessFound,omitempty"`

	Poster   string `json:"-"`
	Backdrop string `json:"-"`
	TMDBID   *int64 `json:"-"`
	MetaAt   int64  `json:"-"` // 0 until online metadata was looked up
	// Pending is true while an online lookup for the item is still to come.
	Pending bool   `json:"pending,omitempty"`
	Path    string `json:"-"`
	Size    int64  `json:"-"`
	Mtime   int64  `json:"-"`
	// SubtitleStreams is the probed embedded subtitle streams as JSON, only
	// set when upserting a file. See Store.SubtitleStreams.
	SubtitleStreams string `json:"-"`
	// Chapters are a file's own marked chapters, only set when upserting a
	// file. See Store.Book.
	Chapters []probe.Chapter `json:"-"`

	// Facts are labelled lines a plugin found for an item of a kind it
	// adds, such as Manufacturer: Namco, shown on its page.
	Facts []Fact `json:"facts,omitempty"`
	// PluginData is what a plugin keeps with an item of a kind it adds, as
	// JSON, for the plugin's player.
	PluginData json.RawMessage `json:"pluginData,omitempty"`
	// Absolute is an episode's number counted from the show's first, when
	// its file is named that way, only set when upserting a file;
	// AbsoluteCompact says it might be a season and episode run together,
	// as 104. See absolute.go.
	Absolute        *int `json:"-"`
	AbsoluteCompact bool `json:"-"`
	// Details are applied with ApplyMetadata after a scan files the item,
	// when the library kind already knows them (a plugin's kinds can).
	Details *Metadata `json:"-"`
	// contains filtered or unexported fields
}

Item is anything browsable: a playable file or a container of other items.

type ItemFilter

type ItemFilter struct {
	Library []int64 `json:"library,omitempty"` // none: every library
	// Kind limits results to movie, show, artist, album, episode, track,
	// author, book or part. Without it, a library's top level is listed:
	// movies, shows, artists or authors.
	Kind []string `json:"kind,omitempty"`
	Q    string   `json:"q,omitempty"` // words in the title

	Genre    []string `json:"genre,omitempty"`
	NotGenre []string `json:"notGenre,omitempty"`

	YearMin int `json:"yearMin,omitempty"`
	YearMax int `json:"yearMax,omitempty"`
	// Release dates are YYYY-MM-DD; shows use their first air date. Titles
	// without one count as released on January 1st of their year.
	ReleasedAfter  string `json:"releasedAfter,omitempty"`
	ReleasedBefore string `json:"releasedBefore,omitempty"`
	ReleasedWithin int    `json:"releasedWithin,omitempty"` // days

	// When a title was added to the library; a show counts as added when
	// its newest episode was.
	AddedAfter  string `json:"addedAfter,omitempty"`  // YYYY-MM-DD
	AddedBefore string `json:"addedBefore,omitempty"` // YYYY-MM-DD
	AddedWithin int    `json:"addedWithin,omitempty"` // days

	RatingMin float64 `json:"ratingMin,omitempty"` // 0–10
	RatingMax float64 `json:"ratingMax,omitempty"`
	// Runtime in minutes; a show's is its average episode's.
	RuntimeMin int `json:"runtimeMin,omitempty"`
	RuntimeMax int `json:"runtimeMax,omitempty"`

	// Watched is unwatched (something left to play), inProgress (started,
	// not finished), watched (all played), notStarted (none played) or
	// started (any of it played or begun, such as albums listened to), for
	// the person asking.
	Watched string `json:"watched,omitempty"`

	Tag    []string `json:"tag,omitempty"` // media tags, such as 4k or atmos (see Item.MediaTags)
	NotTag []string `json:"notTag,omitempty"`

	Person   []int64 `json:"person,omitempty"`   // TMDB person ids credited in any role
	Director []int64 `json:"director,omitempty"` // directed or created it (or one of its episodes)

	Studio        []string `json:"studio,omitempty"`        // studios, and networks for shows
	Country       []string `json:"country,omitempty"`       // production countries
	Language      []string `json:"language,omitempty"`      // original language, e.g. Japanese
	Certification []string `json:"certification,omitempty"` // e.g. PG-13 or TV-MA
	Collection    []int64  `json:"collection,omitempty"`    // TMDB collection ids

	WatchList bool `json:"watchList,omitempty"` // only titles on the person's watch list

	Series   []string `json:"series,omitempty"`   // books in these series
	Narrator []string `json:"narrator,omitempty"` // books any of these people narrate

	Label []string `json:"label,omitempty"` // record labels: albums on them, and artists with albums on them

	Platform []string `json:"platform,omitempty"` // games for any of these systems, such as Super Nintendo

	Sort  string `json:"sort,omitempty"`  // see SortFields; title by default
	Order string `json:"order,omitempty"` // asc or desc; each sort has its own default
	Limit int    `json:"limit,omitempty"`
}

ItemFilter picks titles by their metadata. The same filter travels as URL query parameters (?genre=Comedy&yearMin=1980&sort=year) and as JSON, with the same names, so a library page's filter can be saved as it is, such as for a smart collection. Within one field any value matches, except tag and person, where every value must. Fields that are relative to today, such as addedWithin, are worked out each time the filter runs.

func ParseItemFilter

func ParseItemFilter(q url.Values) (ItemFilter, error)

ParseItemFilter reads a filter from URL query parameters. Parameters it doesn't know are left alone; a known one with a bad value is an error.

func (ItemFilter) Validate

func (f ItemFilter) Validate() error

Validate checks the values that must be one of a few, and the dates.

func (ItemFilter) Values

func (f ItemFilter) Values() url.Values

Values is the filter as URL query parameters, the reverse of ParseItemFilter.

type Letter added in v0.2.4

type Letter struct {
	Letter string `json:"letter"` // A to Z, # for digits and symbols, or a letter of another alphabet
	Index  int    `json:"index"`  // the first title's place in the list
	Count  int    `json:"count"`
}

Letter is where titles starting with one letter begin in a filtered list, for the A to Z bar beside a library's grid.

type Library

type Library struct {
	ID    int64    `json:"id"`
	Name  string   `json:"name"`
	Kind  string   `json:"kind"` // movies, tv or music
	Paths []string `json:"paths"`
	// MetadataMode says where movies' and shows' details come from first:
	// PreferLocal, PreferOnline or LocalOnly.
	MetadataMode string `json:"metadataMode"`
}

type LibraryCount added in v0.1.1

type LibraryCount struct{ Titles, Files int }

LibraryCount is how big a library is: its titles (movies, shows, artists) and its files.

type LibraryFile added in v0.2.0

type LibraryFile struct {
	ID   int64
	Path string
	Kind string
	// Key is what the file is (see fileKey); "" when it can't be matched.
	Key string

	// VersionOf is the item this file is another version of, or 0.
	VersionOf int64
	// PartOf is the movie this file is a later part of, or 0.
	PartOf int64
	// ShowID is an episode's show; NFOHash identifies the .nfo file last
	// read for the file, "" for none.
	ShowID  int64
	NFOHash string
	// contains filtered or unexported fields
}

LibraryFile is a file a library lists, with what it's matched on.

type LiveChannel added in v0.2.0

type LiveChannel struct {
	ID         string   `json:"id"`
	SourceID   string   `json:"sourceId"`
	Name       string   `json:"name"`
	Number     string   `json:"number,omitempty"`
	GuideID    string   `json:"-"`
	Categories []string `json:"categories,omitempty"`
	StreamURL  string   `json:"-"`
	UserAgent  string   `json:"-"`
	Referrer   string   `json:"-"`
	Hidden     bool     `json:"hidden,omitempty"`
	Broken     bool     `json:"broken,omitempty"`
	CheckedAt  int64    `json:"checkedAt,omitempty"`
}

LiveChannel is a TV channel from a source.

type LiveFilter added in v0.2.0

type LiveFilter struct {
	Countries  []string `json:"countries,omitempty"`
	Categories []string `json:"categories,omitempty"`
	Languages  []string `json:"languages,omitempty"`
}

LiveFilter is what a source picks from iptv-org's lists.

type LiveProgram added in v0.2.0

type LiveProgram struct {
	ChannelID   string `json:"channelId"`
	Start       int64  `json:"start"`
	Stop        int64  `json:"stop"`
	Title       string `json:"title"`
	Subtitle    string `json:"subtitle,omitempty"`
	Description string `json:"description,omitempty"`
	Category    string `json:"category,omitempty"`
	Image       string `json:"image,omitempty"`
}

LiveProgram is a show on a channel; times are Unix seconds.

type LiveSource added in v0.2.0

type LiveSource struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	PlaylistURL string      `json:"playlistUrl,omitempty"`
	IPTVOrg     *LiveFilter `json:"iptvOrg,omitempty"`
	GuideURL    string      `json:"guideUrl,omitempty"`
	CreatedAt   int64       `json:"createdAt"`
	RefreshedAt int64       `json:"refreshedAt,omitempty"`
	Error       string      `json:"error,omitempty"`
	GuideAt     int64       `json:"guideAt,omitempty"`
	GuideError  string      `json:"guideError,omitempty"`
	// Counts of its channels: all of them, those whose streams don't
	// answer, and those an admin hid.
	Channels int `json:"channels"`
	Broken   int `json:"broken"`
	Hidden   int `json:"hidden"`
	Programs int `json:"programs"` // shows in the guide from now on
}

LiveSource is a playlist of channels.

type Local added in v0.2.4

type Local struct {
	Title    string
	Year     int
	Overview string
	Genres   []string
	Rating   float64
	Poster   string // a local path or a web address
	Backdrop string
	// Cast, Guests and Crew are the people the file credits. A person
	// whose TMDB id the file doesn't name gets an id of their own, below
	// zero (see LocalPersonID).
	Cast, Guests, Crew []Credit
	// TMDBID pins the match, when the file says which title it is.
	TMDBID int64
	// Hash identifies the file's contents; ApplyLocal does nothing when
	// it's what was applied last.
	Hash string
}

Local is what a file next to the media says about a title.

type Match added in v0.2.0

type Match struct {
	TMDBID int64 `json:"tmdbId,omitempty"`
	// Locked means an admin picked or cleared the match by hand.
	Locked bool `json:"locked"`
}

Match is a movie's or show's online match as it stands.

type Metadata

type Metadata struct {
	TMDBID int64
	MBID   string // MusicBrainz id, for artists and albums
	// Title is only applied to episodes whose file names carry none, named
	// "Episode 4" or, for daily shows, "Mar 15, 2024".
	Title    string
	Overview string
	Year     int
	Rating   float64
	Poster   string // URL
	Backdrop string // URL
	// Genres of a movie or show; nil when the provider doesn't say.
	Genres []string
	// Facts are labelled lines from a plugin; nil keeps what the item has.
	Facts []Fact
}

Metadata is what an online provider knows about an item.

type MoveProgress added in v0.2.7

type MoveProgress func(table string, done, total int64)

MoveProgress hears how far a move is: rows copied out of all of them.

type MoveReport added in v0.2.7

type MoveReport struct {
	From   string        `json:"from"`
	To     string        `json:"to"`
	Tables []TableCount  `json:"tables"`
	Rows   int64         `json:"rows"`
	Took   time.Duration `json:"took"`
}

MoveReport is what a move copied.

type MovedFrom added in v0.2.7

type MovedFrom struct {
	From string `json:"from"`
	At   int64  `json:"at"` // seconds
	Rows int64  `json:"rows"`
}

MovedFrom is what the new database says about where it came from.

type Notification added in v0.2.3

type Notification struct {
	ID     string `json:"id"`
	UserID int64  `json:"-"`
	Source string `json:"-"`
	Event  string `json:"event"`
	Level  string `json:"level"`
	Title  string `json:"title"`
	Body   string `json:"body,omitempty"`
	Kind   string `json:"kind,omitempty"` // movie or show
	TMDBID int    `json:"tmdbId,omitempty"`
	TVDBID int    `json:"tvdbId,omitempty"`
	Poster string `json:"poster,omitempty"`
	// ItemID is the title in the library, once it's there. It's worked
	// out when listed, not stored.
	ItemID int64 `json:"itemId,omitempty"`
	// CreatedAt is when it last came; FirstAt, when it first did, and
	// Repeats how many times, for one that came more than once.
	CreatedAt int64 `json:"createdAt"`
	FirstAt   int64 `json:"firstAt,omitempty"`
	Repeats   int   `json:"repeats,omitempty"`
	Read      bool  `json:"read"`
	// contains filtered or unexported fields
}

type Options added in v0.2.0

type Options struct {
	// BeforeMigrate runs when an existing database is about to be changed
	// to a newer schema, from version from to version to, so it can be
	// backed up first. An error stops the start.
	BeforeMigrate func(s *Store, from, to int) error
	// Wait is how long to keep trying a PostgreSQL server that doesn't
	// answer yet, such as one starting at the same time as Matinee. Zero
	// tries once; a negative wait keeps trying until it answers, unless it
	// says the password, user or database is wrong.
	Wait time.Duration
	// Waiting is told each time the database didn't answer and when the
	// next try is.
	Waiting func(err error, next time.Duration)
}

Options change how Open opens the database.

type Person

type Person struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	HasPhoto   bool   `json:"hasPhoto"`
	Biography  string `json:"biography,omitempty"`
	Birthday   string `json:"birthday,omitempty"` // YYYY-MM-DD
	Deathday   string `json:"deathday,omitempty"`
	Birthplace string `json:"birthplace,omitempty"`
	KnownFor   string `json:"knownFor,omitempty"` // a department, e.g. Acting or Directing

	Photo  string `json:"-"`
	InfoAt int64  `json:"-"` // when the biography was last looked up; 0 if never
}

Person is someone in the cast or crew of titles in the library.

type PersonInfo

type PersonInfo struct {
	Biography, Birthday, Deathday, Birthplace, KnownFor string
	Photo                                               string // URL
}

PersonInfo is a person's biography from a provider.

type PersonTitle

type PersonTitle struct {
	Item  Item     `json:"item"`
	Roles []string `json:"roles"`
}

PersonTitle is a title in the library someone is in, with their parts in it.

type Place added in v0.2.4

type Place struct {
	Season, Episode         int
	TMDBSeason, TMDBEpisode int
}

Place is where an episode goes: the season and episode it's shown as, and where it's found online.

type Playlist added in v0.1.7

type Playlist struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Count      int    `json:"count"`      // songs the viewer can play
	DurationMs int64  `json:"durationMs"` // of those songs
	// AlbumIDs are the first few different albums on it, for its cover.
	AlbumIDs  []int64 `json:"albumIds"`
	CreatedAt int64   `json:"createdAt"` // milliseconds
	UpdatedAt int64   `json:"updatedAt"` // milliseconds
}

type PlaylistEntry added in v0.1.7

type PlaylistEntry struct {
	EntryID string `json:"entryId"`
	Item
}

PlaylistEntry is a song in its place on a playlist.

type PluginKey added in v0.1.1

type PluginKey struct {
	Key       string `json:"key"`
	Size      int64  `json:"size"`
	UpdatedAt int64  `json:"updatedAt"` // milliseconds
}

PluginKey is one thing a plugin's player keeps for a person, such as a saved game.

type PodcastDownloads added in v0.1.13

type PodcastDownloads struct {
	Auto bool `json:"autoDownload"`
	Keep int  `json:"keep"`
}

PodcastDownloads is what a person's phones keep of a show they follow: with Auto on, each phone downloads the show's newest episodes by itself, the Keep newest of them, and lets go of ones that fall out of that or get played.

type PodcastEpisode added in v0.1.7

type PodcastEpisode struct {
	GUID        string
	Title       string
	Description string
	URL         string
	MimeType    string
	Size        int64
	Published   time.Time
	DurationMs  int64
	Season      int
	Number      int
	Image       string
	Link        string
	Kind        string // full, trailer or bonus
}

PodcastEpisode is one episode as a feed lists it.

type PodcastFeed added in v0.1.7

type PodcastFeed struct {
	ID           int64  `json:"id"`
	LibraryID    int64  `json:"libraryId"`
	Title        string `json:"title"`
	URL          string `json:"feedUrl"`
	Link         string `json:"link,omitempty"`
	ETag         string `json:"-"`
	LastModified string `json:"-"`
	RefreshedAt  int64  `json:"refreshedAt"` // Unix seconds; 0 before the first
	Error        string `json:"error,omitempty"`
}

PodcastFeed is where a show's feed is and how its last refresh went.

type PodcastInfo added in v0.1.7

type PodcastInfo struct {
	Title       string
	Description string
	Author      string
	Link        string
	Image       string
	Language    string
	Categories  []string
}

PodcastInfo is what a feed says about its show.

type Profile

type Profile struct {
	User
	// Libraries maps library ids to LibraryAll or LibraryRated; only
	// meaningful for kids profiles.
	Libraries map[int64]string `json:"libraries"`
}

Profile is a profile as admins manage it.

type ProfileChanges

type ProfileChanges struct {
	Name      *string
	Avatar    *string
	KidsLevel *int
	// PINHash replaces the PIN; "" removes it.
	PINHash   *string
	Libraries map[int64]string
}

ProfileChanges are what an admin sets on a profile. Nil fields stay as they are.

type ProgressEvent

type ProgressEvent struct {
	ItemID     int64 `json:"itemId"`
	PositionMs int64 `json:"positionMs"`
	Played     bool  `json:"played"`
	At         int64 `json:"at"`
}

ProgressEvent is a change to watch progress that a device made, possibly while offline, at the time At (unix seconds).

type RecordLabel added in v0.1.15

type RecordLabel struct {
	Name    string `json:"name"`
	Albums  int    `json:"albums"`
	Artists int    `json:"artists"`
	// Covers are up to four of its albums with covers, newest first, for
	// a label's tile.
	Covers []Item `json:"covers"`
}

RecordLabel is a label albums in a music library came out on.

type Request

type Request struct {
	ID               string `json:"id"`
	Kind             string `json:"kind"` // movie or show
	TMDBID           int    `json:"tmdbId,omitempty"`
	TVDBID           int    `json:"tvdbId,omitempty"`
	Title            string `json:"title"`
	Year             int    `json:"year,omitempty"`
	Poster           string `json:"poster,omitempty"`
	QualityProfileID int    `json:"qualityProfileId,omitempty"` // 0 uses the admin's default
	State            string `json:"state"`
	Error            string `json:"error,omitempty"`
	UserID           int64  `json:"userId"`
	Username         string `json:"username"`
	CreatedAt        int64  `json:"createdAt"`
	UpdatedAt        int64  `json:"updatedAt"`
	// Ask is what a request with Box Office is for, beyond adding a title:
	// AskEdition (another edition of a movie in a library, Edition, to
	// replace its copy or go alongside it, Mode), AskBetter (a better
	// copy) or AskReplace (another copy, the one there being bad: Reason
	// says why). "" is a title to add. Season and Episode name the episode
	// of a show that a better or replacement copy is for.
	Ask     string `json:"ask,omitempty"`
	Edition string `json:"edition,omitempty"`
	Mode    string `json:"mode,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Season  int    `json:"seasonNumber,omitempty"`
	Episode int    `json:"episodeNumber,omitempty"`
	// BoxOfficeID is the request's id on Box Office's Requests page, for
	// one filed there; 0 for one Matinee decides itself.
	BoxOfficeID int64 `json:"boxOfficeId,omitempty"`
	// Problem is the problem reported (an Issue's kind) that an
	// AskReplace is for, and Language the language (ISO 639-1) the sound
	// should be in, for the wrong language.
	Problem  string `json:"problem,omitempty"`
	Language string `json:"language,omitempty"`
	// FileName is the name of the file reported, for a Problem.
	FileName string `json:"-"`
}

type SavedCollection

type SavedCollection struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Kind string `json:"kind"` // smart or manual
	// OwnerID is who made it; nil for a shared collection.
	OwnerID *int64 `json:"ownerId,omitempty"`
	Shared  bool   `json:"shared"`
	// Filter picks a smart collection's titles; nil for a manual one.
	Filter *ItemFilter `json:"filter,omitempty"`
	// Sort is one of CollectionSorts, or empty for the collection's own order.
	Sort  string `json:"sort,omitempty"`
	Order string `json:"order,omitempty"` // asc or desc; empty is the sort's natural one
	// PinHome shows the collection as a row on Home, PinLibrary as a row on
	// that library's page.
	PinHome    bool   `json:"pinHome"`
	PinLibrary *int64 `json:"pinLibrary,omitempty"`
	// Starter names a built-in collection, such as "recent".
	Starter   string `json:"starter,omitempty"`
	CreatedAt int64  `json:"createdAt"` // milliseconds
	UpdatedAt int64  `json:"updatedAt"` // milliseconds
}

type Session

type Session struct {
	ID         string `json:"id"`
	DeviceName string `json:"deviceName"`
	Platform   string `json:"platform"`
	CreatedAt  int64  `json:"createdAt"`
	LastSeenAt int64  `json:"lastSeenAt"`
	Current    bool   `json:"current"`
}

Session is a signed-in device as its owner sees it. ID is derived from the token, so the token itself never leaves the device that holds it.

type ShowToPlace added in v0.2.4

type ShowToPlace struct {
	ID     int64
	TMDBID int64
	Order  string
}

ShowToPlace is a matched show with episodes to put in seasons.

type Station added in v0.1.15

type Station struct {
	Name     string
	URL      string // the stream
	Homepage string
	Image    string // a logo on the internet, or ""
	Genres   []string
	// Home lets the server reach the stream on the home network, which it
	// otherwise refuses (see stream.Remote). Only for stations an admin adds.
	Home bool
}

Station is what's needed to add a radio station.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(dsn string) (*Store, error)

Open connects to the database. A postgres:// URL uses PostgreSQL, which suits Kubernetes and network storage; anything else is a SQLite file path (":memory:" in tests).

func OpenWith added in v0.2.0

func OpenWith(dsn string, o Options) (*Store, error)

OpenWith is Open with options.

func (*Store) AbsoluteEpisodes added in v0.2.4

func (s *Store) AbsoluteEpisodes(ctx context.Context, showID int64) ([]AbsoluteEpisode, error)

AbsoluteEpisodes lists a show's episodes named by absolute number.

func (*Store) AbsoluteNumber added in v0.2.4

func (s *Store) AbsoluteNumber(ctx context.Context, id int64) (int, error)

AbsoluteNumber returns the number an episode's file is named by from the show's first, 0 when it's named otherwise.

func (*Store) AcceptInvite added in v0.1.10

func (s *Store) AcceptInvite(ctx context.Context, code, username, passwordHash string) (User, error)

AcceptInvite makes a friend account from an invite, with the invite's libraries. The invite can't be used again.

func (*Store) AddFoundSubtitle added in v0.1.10

func (s *Store) AddFoundSubtitle(ctx context.Context, f FoundSubtitle) (FoundSubtitle, error)

AddFoundSubtitle keeps a subtitle found for a video, and returns it with its id. A file from the same source for the same video is kept once.

func (*Store) AddLiveSource added in v0.2.0

func (s *Store) AddLiveSource(ctx context.Context, src LiveSource) (string, error)

AddLiveSource saves a new source, with no channels yet.

func (*Store) AddNotification added in v0.2.3

func (s *Store) AddNotification(ctx context.Context, n Notification) (Notification, Added, error)

AddNotification saves a notification for a person. It's left out when they have one from the same source already, so servers that read the same feed tell them once, and it's added to the one they have when it's the same again (see groupKey).

func (*Store) AddShareStall added in v0.2.4

func (s *Store) AddShareStall(ctx context.Context, id int64, key string, within time.Duration) (int, error)

AddShareStall counts one more stall while reading item id's file, whose version is key, and returns the count. A new key, or a last stall longer ago than within, starts the count over.

func (*Store) AddStarterCollections

func (s *Store) AddStarterCollections(ctx context.Context) error

AddStarterCollections adds the built-in collections the first time it runs.

func (*Store) AddStation added in v0.1.15

func (s *Store) AddStation(ctx context.Context, libraryID int64, st Station) (int64, error)

AddStation adds a radio station to a music library.

func (*Store) AddToCollection

func (s *Store) AddToCollection(ctx context.Context, collectionID string, itemID int64) error

AddToCollection puts an item at the end of a manual collection. Adding it again keeps its place.

func (*Store) AddToPlaylist added in v0.1.7

func (s *Store) AddToPlaylist(ctx context.Context, id string, itemIDs []int64) ([]string, error)

AddToPlaylist puts songs at the end of a playlist, in the order given, and returns their entry ids.

func (*Store) AddToWatchList

func (s *Store) AddToWatchList(ctx context.Context, userID, itemID int64) error

AddToWatchList saves an item to a user's watch list. Adding it again keeps its place.

func (*Store) AlbumTags added in v0.1.7

func (s *Store) AlbumTags(ctx context.Context, id int64) (release, group string, err error)

AlbumTags returns the MusicBrainz release and release group ids an album's files are tagged with, "" for ones they don't have.

func (*Store) AlbumsToReadLabel added in v0.1.15

func (s *Store) AlbumsToReadLabel(ctx context.Context, libraryID int64) ([]AlbumToRead, error)

AlbumsToReadLabel lists a library's albums whose files haven't been read for a record label, such as albums scanned before Matinee kept labels, with one file of each.

func (*Store) AlbumsToReadTags added in v0.1.7

func (s *Store) AlbumsToReadTags(ctx context.Context, libraryID int64) ([]ArtlessContainer, error)

AlbumsToReadTags lists a library's albums without a cover whose files' tags haven't been read for MusicBrainz ids, such as albums scanned before Matinee kept them, with their files' paths.

func (*Store) AlbumsWithFiles added in v0.1.7

func (s *Store) AlbumsWithFiles(ctx context.Context, libraryID int64) ([]AlbumFiles, error)

AlbumsWithFiles lists a music library's albums with their tracks' paths.

func (*Store) AllDownloads

func (s *Store) AllDownloads(ctx context.Context) ([]Download, error)

AllDownloads lists every user's downloads, for admins.

func (*Store) AnalysisCounts

func (s *Store) AnalysisCounts(ctx context.Context, version int) (total, done, unreadable int, err error)

AnalysisCounts says how many files there are, how many are analyzed as they are now by this version, and how many of those couldn't be read.

func (*Store) AnalysisFiles

func (s *Store) AnalysisFiles(ctx context.Context, afterID int64, limit int) ([]AnalysisFile, error)

AnalysisFiles lists files with ids above afterID, in id order, so a pass over the library can stop and pick up where it was.

func (*Store) ApplyDetails

func (s *Store) ApplyDetails(ctx context.Context, id int64, u DetailsUpdate) error

ApplyDetails replaces an item's details, credits and terms.

func (*Store) ApplyEpisodeDetails

func (s *Store) ApplyEpisodeDetails(ctx context.Context, id int64, u DetailsUpdate) error

ApplyEpisodeDetails stores an episode's air date, guest stars and crew, which arrive with its season's.

func (*Store) ApplyLocal added in v0.2.4

func (s *Store) ApplyLocal(ctx context.Context, id int64, l *Local) error

ApplyLocal stores what a file next to the media says about an item, or, with l nil, forgets that the file said anything (it's gone). Fields an admin locked stay as they are. A TMDB id the file names becomes the item's match, looked up again, unless an admin picked the match.

func (*Store) ApplyMetadata

func (s *Store) ApplyMetadata(ctx context.Context, id int64, m *Metadata) error

ApplyMetadata stores a provider match (nil for no match) without overwriting local artwork or the year from the file name. Artwork from an earlier lookup gives way to the new match's.

func (*Store) AutoDownloadEpisodes added in v0.1.13

func (s *Store) AutoDownloadEpisodes(ctx context.Context, userID int64) ([]Item, error)

AutoDownloadEpisodes lists the episodes a person's phones should have of the shows they download by themselves: of each show's Keep newest episodes (trailers aside), the ones they haven't played, and any episode they're part-way through even if it's older, so it isn't taken away mid-listen. Newest first.

func (*Store) BackfillRatingLevels

func (s *Store) BackfillRatingLevels(ctx context.Context, level func(cert string) int) (int, error)

BackfillRatingLevels fills in rating levels for titles whose details were looked up before levels were kept. level turns a certification into one.

func (*Store) Backup added in v0.2.0

func (s *Store) Backup(ctx context.Context, path string) error

Backup copies the whole database to path, a file that mustn't exist yet, while it stays in use (SQLite's VACUUM INTO).

func (*Store) Book added in v0.1.2

func (s *Store) Book(ctx context.Context, userID, id int64) (Book, error)

Book returns a book with its parts and chapters, for the given person. A part's id finds its book.

func (*Store) BoxOfficeRequests added in v0.2.4

func (s *Store) BoxOfficeRequests(ctx context.Context, kind string) ([]Request, error)

BoxOfficeRequests are the requests of a kind filed with Box Office that are still waiting there.

func (*Store) BoxSet

func (s *Store) BoxSet(ctx context.Context, userID, id int64) (BoxSet, error)

BoxSet returns one box set, or ErrNotFound when the library has none of it.

func (*Store) BoxSets

func (s *Store) BoxSets(ctx context.Context, userID int64) ([]BoxSet, error)

BoxSets lists the box sets with two or more titles in the library the user can see, by name.

func (*Store) CheckMoveTarget added in v0.2.7

func (s *Store) CheckMoveTarget(ctx context.Context, dsn string) error

CheckMoveTarget says whether dsn is somewhere Matinee can move this database to: it answers, isn't this database, and has none of Matinee's data yet. A SQLite file that doesn't exist yet is fine; it's made.

func (*Store) Children

func (s *Store) Children(ctx context.Context, userID, parentID int64) ([]Item, error)

Children lists seasons of a show, episodes of a season, albums of an artist, tracks of an album, books of an author, parts of a book or episodes of a podcast.

func (*Store) ChosenImage added in v0.1.7

func (s *Store) ChosenImage(ctx context.Context, id int64) (ChosenImage, error)

ChosenImage returns the cover an admin picked for an item.

func (*Store) ClearChosenImage added in v0.1.7

func (s *Store) ClearChosenImage(ctx context.Context, id int64) error

ClearChosenImage forgets the cover an admin picked, leaving the item to find one in its folder, its files or online, as if it had never had one: the next scan and lookup fill it in.

func (*Store) ClearEndCredits added in v0.1.13

func (s *Store) ClearEndCredits(ctx context.Context, itemID int64) error

ClearEndCredits has the detector look at a video, and its season, again.

func (*Store) ClearIntro added in v0.1.10

func (s *Store) ClearIntro(ctx context.Context, itemID int64) error

ClearIntro has the detector look at an episode, and its season, again.

func (*Store) ClearMediaKey

func (s *Store) ClearMediaKey(ctx context.Context, id int64) error

ClearMediaKey has a file analyzed again soon.

func (*Store) ClearRating added in v0.1.9

func (s *Store) ClearRating(ctx context.Context, userID, itemID int64) error

ClearRating forgets someone's rating of an item.

func (*Store) ClearShareStalls added in v0.2.4

func (s *Store) ClearShareStalls(ctx context.Context, id int64) error

ClearShareStalls forgets item id's stalls, for Analyze again.

func (*Store) ClearThumbnails added in v0.1.11

func (s *Store) ClearThumbnails(ctx context.Context, itemID int64) error

ClearThumbnails has a video's pictures made again.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Collection

func (s *Store) Collection(ctx context.Context, id string) (SavedCollection, error)

Collection returns one collection, whoever it belongs to.

func (*Store) CollectionItems

func (s *Store) CollectionItems(ctx context.Context, userID, collectionID int64) ([]Item, error)

CollectionItems lists the library's titles in a collection, oldest first.

func (*Store) Collections

func (s *Store) Collections(ctx context.Context, userID int64) ([]SavedCollection, error)

Collections lists the shared collections and the user's own, shared first.

func (*Store) ContainersWithoutLocalArt added in v0.1.3

func (s *Store) ContainersWithoutLocalArt(ctx context.Context, libraryID int64, kind string) ([]ArtlessContainer, error)

ContainersWithoutLocalArt lists a library's items of kind (album or book) whose cover is missing or comes from online, with their files' paths.

func (*Store) ContinueListening added in v0.1.2

func (s *Store) ContinueListening(ctx context.Context, userID int64, limit int) ([]Item, error)

ContinueListening lists books and podcast episodes someone started and didn't finish, the latest first, leaving out the ones they took off the row.

func (*Store) ContinueWatching

func (s *Store) ContinueWatching(ctx context.Context, userID int64, limit int) ([]Item, error)

ContinueWatching lists videos the user started but didn't finish, leaving out the ones they took off the row.

func (*Store) CountUsers

func (s *Store) CountUsers(ctx context.Context) (int, error)

func (*Store) Counts added in v0.2.3

func (s *Store) Counts(ctx context.Context) (Counts, error)

func (*Store) CreateCollection

func (s *Store) CreateCollection(ctx context.Context, c SavedCollection) (SavedCollection, error)

CreateCollection saves a new collection; ID and times are filled in.

func (*Store) CreateHomeSession

func (s *Store) CreateHomeSession(ctx context.Context, guestID, profileID int64, ttl time.Duration, dev Device) (string, error)

CreateHomeSession starts a session for a device at home that picked one of the guest account's profiles. It only works from the home network.

func (*Store) CreateInvite added in v0.1.10

func (s *Store) CreateInvite(ctx context.Context, createdBy int64, name string, libraries []int64, expiresAt int64) (Invite, error)

CreateInvite makes an invite that lasts until expiresAt (Unix seconds).

func (*Store) CreateIssue

func (s *Store) CreateIssue(ctx context.Context, x Issue) (Issue, error)

func (*Store) CreateLibrary

func (s *Store) CreateLibrary(ctx context.Context, name, kind string, paths []string) (Library, error)

func (*Store) CreatePlaylist added in v0.1.7

func (s *Store) CreatePlaylist(ctx context.Context, userID int64, name string) (Playlist, error)

CreatePlaylist makes an empty playlist.

func (*Store) CreatePodcast added in v0.1.7

func (s *Store) CreatePodcast(ctx context.Context, libraryID int64, feedURL string, info PodcastInfo) (int64, error)

CreatePodcast adds a show to a library.

func (*Store) CreateProfile

func (s *Store) CreateProfile(ctx context.Context, accountID int64, c ProfileChanges) (Profile, error)

CreateProfile adds a profile to an account.

func (*Store) CreateRequest

func (s *Store) CreateRequest(ctx context.Context, r Request) (Request, error)

CreateRequest saves a new request, pending unless it says otherwise (as one Box Office decided at once does).

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, userID int64, ttl time.Duration, dev Device) (string, error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, username, passwordHash string, admin bool) (User, error)

func (*Store) CreditsVideos added in v0.1.13

func (s *Store) CreditsVideos(ctx context.Context, afterGroup int64, limit int) ([]CreditsVideo, error)

CreditsVideos lists video episodes and movies of groups with ids above afterGroup, by group and by episode number within one, with whatever the detector found before. It stops after the group that takes it past limit videos, so a season is never split.

func (*Store) DecideDeviceCode

func (s *Store) DecideDeviceCode(ctx context.Context, userCode string, userID int64, approve bool) error

DecideDeviceCode approves a code for a user, or declines it.

func (*Store) DeleteCollection

func (s *Store) DeleteCollection(ctx context.Context, id string) error

func (*Store) DeleteDownload

func (s *Store) DeleteDownload(ctx context.Context, userID int64, id string) (Download, error)

DeleteDownload removes a download and returns it, so its file can be cleaned up if nothing else uses it. Admins (userID 0) can remove anyone's.

func (*Store) DeleteInvite added in v0.1.10

func (s *Store) DeleteInvite(ctx context.Context, code string) error

DeleteInvite takes an invite back. Accounts already made from it stay.

func (*Store) DeleteItem added in v0.1.7

func (s *Store) DeleteItem(ctx context.Context, id int64) error

DeleteItem removes an item and everything under it, such as a show and its episodes.

func (*Store) DeleteLibrary

func (s *Store) DeleteLibrary(ctx context.Context, id int64) error

func (*Store) DeleteLiveSource added in v0.2.0

func (s *Store) DeleteLiveSource(ctx context.Context, id string) error

DeleteLiveSource removes a source with its channels and guide.

func (*Store) DeleteNotifications added in v0.2.3

func (s *Store) DeleteNotifications(ctx context.Context, users []int64, ids []string) error

DeleteNotifications clears the given people's notifications: those with the ids given, or all of them when ids is empty.

func (*Store) DeleteOtherSessions

func (s *Store) DeleteOtherSessions(ctx context.Context, userID int64, keep string) error

DeleteOtherSessions signs a user out everywhere but the session keep ("" signs them out everywhere). Those devices' downloads go with them.

func (*Store) DeletePlaylist added in v0.1.7

func (s *Store) DeletePlaylist(ctx context.Context, userID int64, id string) error

func (*Store) DeletePluginStorage added in v0.1.1

func (s *Store) DeletePluginStorage(ctx context.Context, pluginID string) error

DeletePluginStorage forgets everything a plugin kept, when it's removed.

func (*Store) DeletePluginValue added in v0.1.1

func (s *Store) DeletePluginValue(ctx context.Context, pluginID string, userID int64, key string) error

DeletePluginValue forgets one key.

func (*Store) DeleteProfile

func (s *Store) DeleteProfile(ctx context.Context, id int64) error

DeleteProfile removes a profile with its progress and watch list.

func (*Store) DeleteRequest

func (s *Store) DeleteRequest(ctx context.Context, id string) error

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, token string) error

DeleteSession signs a device out. Its downloads go with it.

func (*Store) DeleteSessionByID

func (s *Store) DeleteSessionByID(ctx context.Context, userID int64, id string) error

DeleteSessionByID signs one of a user's devices out.

func (*Store) DeleteSetting added in v0.2.7

func (s *Store) DeleteSetting(ctx context.Context, key string) error

DeleteSetting removes a setting.

func (*Store) DeleteStation added in v0.1.15

func (s *Store) DeleteStation(ctx context.Context, id int64) error

DeleteStation removes a station, and what people played of it.

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, userID int64) error

DeleteUser removes an account and everything that belongs to it: sessions, watch history, watch list, downloads, requests and settings. The last admin can't be removed.

func (*Store) DownloadFailed

func (s *Store) DownloadFailed(ctx context.Context, file, msg string, maxAttempts int) error

DownloadFailed records a failed attempt for every download being prepared from file. Until maxAttempts it queues them again after a growing wait.

func (*Store) DownloadFiles

func (s *Store) DownloadFiles(ctx context.Context) (map[string]bool, error)

DownloadFiles lists every prepared file a download refers to.

func (*Store) DownloadPrepared

func (s *Store) DownloadPrepared(ctx context.Context, file string, size int64, sha256, md5 string, sourceMtime int64) error

DownloadPrepared marks every download being prepared from file as ready. For an original, sourceMtime is the mtime the checksum is for (0 otherwise).

func (*Store) Downloads

func (s *Store) Downloads(ctx context.Context, userID int64, deviceID string) ([]Download, error)

Downloads lists a user's downloads, for one device or (deviceID "") all of them.

func (*Store) EditDetails added in v0.2.4

func (s *Store) EditDetails(ctx context.Context, id int64, e Edit) error

EditDetails sets the fields of e on an item and locks them, so no lookup or scan changes them again.

func (*Store) EndCredits added in v0.1.13

func (s *Store) EndCredits(ctx context.Context, itemID int64, version int) (startMs, endMs int64, source string, ok bool, err error)

EndCredits returns where a video's end credits are, as the detector found them in the file as it is now. endMs is 0 when they run to the end. ok is false when it found none or hasn't looked.

func (*Store) EndCreditsCounts added in v0.1.13

func (s *Store) EndCreditsCounts(ctx context.Context, version int) (total, done, found int, err error)

EndCreditsCounts says how many video episodes and movies there are, how many of them the detector has looked at as they are now, and in how many it found end credits.

func (*Store) EnsureContainer

func (s *Store) EnsureContainer(ctx context.Context, libraryID int64, parentID *int64, kind, title string, index, year *int) (int64, error)

EnsureContainer finds or creates a show, season, artist or album and returns its id.

func (*Store) EnsureShow added in v0.2.4

func (s *Store) EnsureShow(ctx context.Context, libraryID int64, title string, year int, tmdbID int64) (int64, error)

EnsureShow finds or creates a TV show by its title, keeping apart shows that share a name but not a year or a TMDB id, as "Doctor Who (1963)" and "Doctor Who (2005)" do. year and tmdbID are what the show's folder name says, 0 when it says nothing. A show whose year or id isn't known yet takes the first folder that names one.

func (*Store) EpisodeInfoOf added in v0.1.7

func (s *Store) EpisodeInfoOf(ctx context.Context, id int64) (EpisodeInfo, error)

EpisodeInfoOf returns an episode's link and type.

func (*Store) EpisodeOrder added in v0.2.4

func (s *Store) EpisodeOrder(ctx context.Context, showID int64) (order string, absolute bool, err error)

EpisodeOrder returns a show's episode order, and whether it has any episodes named by absolute number, for which the order matters.

func (*Store) EpisodePlace added in v0.2.4

func (s *Store) EpisodePlace(ctx context.Context, id int64) (absolute, placed bool, tmdbSeason, tmdbEpisode int, err error)

EpisodePlace says how an episode is looked up online: absolute is true for one named by absolute number, placed once it was put in its season by its show's order, and tmdbSeason and tmdbEpisode are where it's found online when that's not where it's shown (0 otherwise).

func (*Store) ExpireFinishedDownloads

func (s *Store) ExpireFinishedDownloads(ctx context.Context, age time.Duration) ([]string, error)

ExpireFinishedDownloads finds converted files that every device using them has had for longer than age, and marks those downloads expired so the files can be deleted. Originals are never deleted, so they're left alone.

func (*Store) FileInUse

func (s *Store) FileInUse(ctx context.Context, file string) (bool, error)

FileInUse says whether any download still needs a prepared file.

func (*Store) FileKey added in v0.2.4

func (s *Store) FileKey(ctx context.Context, itemID int64) (string, error)

FileKey says which file an item has, to notice another taking its place: its path, size and modification time. "" for an item without a file.

func (*Store) FileRefs added in v0.1.9

func (s *Store) FileRefs(ctx context.Context) ([]FileRef, error)

FileRefs lists every file in every library.

func (*Store) FileStat

func (s *Store) FileStat(ctx context.Context, path string) (id, size, mtime int64, err error)

FileStat returns the stored size and mtime for a file path, or ErrNotFound.

func (*Store) FileUnder

func (s *Store) FileUnder(ctx context.Context, id int64) (string, error)

FileUnder returns the path of one file under a show or season, so callers can find the folder it lives in. It returns "" when there's none.

func (*Store) FilterItems

func (s *Store) FilterItems(ctx context.Context, userID int64, f ItemFilter) ([]Item, error)

FilterItems lists the titles the filter picks, for the given person.

func (*Store) FilterLetters added in v0.2.4

func (s *Store) FilterLetters(ctx context.Context, userID int64, f ItemFilter) ([]Letter, error)

FilterLetters says where each letter starts in the list FilterItems gives for the same filter. Only a title sort runs in letter order, so other sorts get no letters.

func (*Store) FilterOptions

func (s *Store) FilterOptions(ctx context.Context, libraryID int64) (FilterOptions, error)

FilterOptions lists what a library's top level can be filtered by.

func (*Store) FilterPeople

func (s *Store) FilterPeople(ctx context.Context, libraryID int64, role, q string, limit int) ([]FilterPerson, error)

FilterPeople lists people credited in a library's titles (or their episodes), in the most titles first. role is cast, director or empty for any; q, when given, matches the start of any word of their name.

func (*Store) FinishDownload

func (s *Store) FinishDownload(ctx context.Context, userID int64, id string) error

FinishDownload records that the device has the whole file and checked it.

func (*Store) FinishMove added in v0.2.7

func (s *Store) FinishMove(ctx context.Context, from, to string, report MoveReport) error

FinishMove switches over once the copy is in the new database (to): the old database (s) notes where it went, and the new one where it came from.

func (*Store) FixingIssues added in v0.2.4

func (s *Store) FixingIssues(ctx context.Context) ([]Issue, error)

FixingIssues are the open issues Box Office was asked to fix.

func (*Store) Follow added in v0.1.7

func (s *Store) Follow(ctx context.Context, userID, podcastID int64) error

Follow adds a show to the ones a person follows, whose new episodes they see on Home.

func (*Store) FollowedDownloads added in v0.1.13

func (s *Store) FollowedDownloads(ctx context.Context, userID int64) (map[int64]PodcastDownloads, error)

FollowedDownloads returns a person's downloads for every show they follow, by show.

func (*Store) FollowedPodcasts added in v0.1.7

func (s *Store) FollowedPodcasts(ctx context.Context, userID int64) ([]Item, error)

FollowedPodcasts lists the shows a person follows, the one with the newest episode first.

func (*Store) Follows added in v0.1.7

func (s *Store) Follows(ctx context.Context, userID, podcastID int64) (bool, error)

Follows says whether a person follows a show.

func (*Store) ForgetTrackChoices added in v0.2.4

func (s *Store) ForgetTrackChoices(ctx context.Context, userID int64, itemIDs ...int64) error

ForgetTrackChoices forgets a person's picks for these items.

func (*Store) FoundSubtitle added in v0.1.10

func (s *Store) FoundSubtitle(ctx context.Context, itemID int64, id string) (FoundSubtitle, error)

FoundSubtitle returns one subtitle found for a video, with its file.

func (*Store) FoundSubtitles added in v0.1.10

func (s *Store) FoundSubtitles(ctx context.Context, itemID int64) ([]FoundSubtitle, error)

FoundSubtitles lists the subtitles found for a video, oldest first, without their files.

func (*Store) FriendLibraries added in v0.1.10

func (s *Store) FriendLibraries(ctx context.Context) (map[int64][]int64, error)

FriendLibraries maps each friend account to the libraries it sees.

func (*Store) GameVersions added in v0.2.7

func (s *Store) GameVersions(ctx context.Context, libraryID int64) ([]GameVersion, error)

GameVersions lists a library's game files.

func (*Store) GaplessAlbums added in v0.1.13

func (s *Store) GaplessAlbums(ctx context.Context, after int64, limit int) ([]GaplessAlbum, error)

GaplessAlbums lists the albums with ids above after, with their songs, stopping once it has limit albums.

func (*Store) GaplessTracks added in v0.1.13

func (s *Store) GaplessTracks(ctx context.Context, userID int64, ids []int64) (tracks []Item, ok bool, err error)

GaplessTracks returns the songs to play as one stream, in the order given, as the user may see them. Every id must be a song on the same album; ok is false otherwise.

func (*Store) GenreCounts

func (s *Store) GenreCounts(ctx context.Context, userID int64) (map[string]int, error)

GenreCounts says how many movies the user can see in each genre. Home's genre rows are movies only: a show in among them reads as a mistake.

func (*Store) GroupParts added in v0.2.4

func (s *Store) GroupParts(ctx context.Context, libraryID int64, partKey func(path string) (key string, part int)) (changed int, err error)

GroupParts makes the files of a library's movies that are parts of one movie into it, and makes files that no longer are movies of their own. partKey says which movie a file is a part of (files with the same key are one movie) and which part it is; key is "" for a file that isn't a part. A movie needs at least two different parts.

func (*Store) GroupVersions added in v0.2.1

func (s *Store) GroupVersions(ctx context.Context, libraryID int64, edition func(path string) string) (VersionChanges, error)

GroupVersions makes files of the same movie or episode in a library versions of one item, and splits off files that no longer are (after a fixed match, say). Two movie files are the same movie when they're matched to the same one online, or when neither is and their titles and years agree; episodes are the same episode of the same season of the same show. edition reads a file's edition from its path; GroupVersions keeps each file's up to date.

The item that stays the title is one that already is, or else the oldest file. When files that were titles of their own become versions, what people did with them moves to the title.

func (*Store) Health added in v0.1.11

func (s *Store) Health(ctx context.Context) (DatabaseInfo, error)

Health describes the database: which one, how big, how quick.

func (*Store) HideFromContinueWatching

func (s *Store) HideFromContinueWatching(ctx context.Context, userID, itemID int64) error

HideFromContinueWatching takes an item off the user's Continue Watching row. Its place is kept, so its page still offers to resume, and playing it again brings it back.

func (*Store) HolidayItems added in v0.1.1

func (s *Store) HolidayItems(ctx context.Context, userID int64, m HolidayMatch, limit int) ([]Item, error)

HolidayItems lists the movies the user can see that match, best rated first. Holiday rows are movies only, like Home's genre rows.

func (*Store) HomeGuest

func (s *Store) HomeGuest(ctx context.Context) (User, error)

HomeGuest is the account devices on the home network use when they haven't signed in, created the first time one does. Everyone at home shares it, so they share its watch progress and watch list too. It can't sign in, isn't listed with the other accounts, and isn't an admin.

func (*Store) InGenre

func (s *Store) InGenre(ctx context.Context, userID int64, genre string, limit int) ([]Item, error)

InGenre lists the movies in a genre, best rated first, for Home's genre rows. Libraries filter shows by genre themselves (see ItemFilter).

func (*Store) InGenreExcept added in v0.1.1

func (s *Store) InGenreExcept(ctx context.Context, userID int64, genre string, m HolidayMatch, limit int) ([]Item, error)

InGenreExcept lists movies in a genre that don't match m, best rated first, to fill out a holiday's row.

func (*Store) Intro added in v0.1.10

func (s *Store) Intro(ctx context.Context, itemID int64, version int) (startMs, endMs int64, ok bool, err error)

Intro returns where an episode's intro is, as the detector found it in the file as it is now. ok is false when it found none or hasn't looked.

func (*Store) IntroCounts added in v0.1.10

func (s *Store) IntroCounts(ctx context.Context, version int) (total, done, found int, err error)

IntroCounts says how many video episodes there are, how many of them the detector has looked at as they are now, and in how many it found an intro.

func (*Store) IntroEpisodes added in v0.1.10

func (s *Store) IntroEpisodes(ctx context.Context, afterSeason int64, limit int) ([]IntroEpisode, error)

IntroEpisodes lists the video episodes of seasons with ids above afterSeason, grouped by season in id order and by episode number within one, with whatever the detector found before. It stops after the season that takes it past limit episodes, so a season is never split.

func (*Store) InviteByCode added in v0.1.10

func (s *Store) InviteByCode(ctx context.Context, code string) (Invite, error)

InviteByCode finds an invite that can still be used.

func (*Store) Invites added in v0.1.10

func (s *Store) Invites(ctx context.Context) ([]Invite, error)

Invites lists invites, newest first. Used and expired ones stay listed for a while so admins can see what happened to them.

func (*Store) Issue

func (s *Store) Issue(ctx context.Context, id string) (Issue, error)

func (*Store) Issues

func (s *Store) Issues(ctx context.Context, userID int64, limit int) ([]Issue, error)

Issues lists reported problems, open ones first, then the newest. userID 0 lists everyone's.

func (*Store) Item

func (s *Store) Item(ctx context.Context, userID, id int64) (Item, error)

Item returns one item with the user's progress, or ErrNotFound when it's not for them (see visibleToMe). User 0 sees everything.

func (*Store) ItemCollections

func (s *Store) ItemCollections(ctx context.Context, itemID int64) ([]string, error)

ItemCollections lists the IDs of the manual collections holding an item.

func (*Store) ItemCredits

func (s *Store) ItemCredits(ctx context.Context, id int64) (Credits, error)

ItemCredits returns an item's cast, guest stars and crew in billing order.

func (*Store) ItemDetails

func (s *Store) ItemDetails(ctx context.Context, id int64) (*Details, error)

ItemDetails returns what ApplyDetails stored for an item, or nil.

func (*Store) ItemMatch added in v0.2.0

func (s *Store) ItemMatch(ctx context.Context, id int64) (Match, error)

ItemMatch returns an item's online match.

func (*Store) ItemThumbnails added in v0.1.11

func (s *Store) ItemThumbnails(ctx context.Context, itemID int64, version int) (t Thumbnails, ok bool, err error)

ItemThumbnails returns a video's pictures, made of the file as it is now by this version of the generator. ok is false when there are none.

func (*Store) Labels added in v0.1.15

func (s *Store) Labels(ctx context.Context, userID, libraryID int64) ([]RecordLabel, error)

Labels lists the record labels of a music library's albums, by name.

func (*Store) Libraries

func (s *Store) Libraries(ctx context.Context) ([]Library, error)

func (*Store) Library

func (s *Store) Library(ctx context.Context, id int64) (Library, error)

func (*Store) LibraryCounts added in v0.1.1

func (s *Store) LibraryCounts(ctx context.Context) (map[int64]LibraryCount, error)

LibraryCounts counts every library's titles and files.

func (*Store) LibraryFiles added in v0.2.0

func (s *Store) LibraryFiles(ctx context.Context, libraryID int64) ([]LibraryFile, error)

LibraryFiles lists a library's files with their match keys.

func (*Store) LibraryMatch

func (s *Store) LibraryMatch(ctx context.Context, kind string, tmdbID int, title string, year int) (int64, error)

LibraryMatch finds a movie or show in the libraries, by TMDB id or, for items looked up without TMDB, by title and year. It returns 0 when there's none.

func (*Store) LibraryVisible

func (s *Store) LibraryVisible(ctx context.Context, u User, libraryID int64) (bool, error)

LibraryVisible reports whether a user may see a library at all.

func (*Store) LiveChannel added in v0.2.0

func (s *Store) LiveChannel(ctx context.Context, id string) (LiveChannel, error)

LiveChannel is one channel.

func (*Store) LiveChannels added in v0.2.0

func (s *Store) LiveChannels(ctx context.Context, sourceID string, all bool) ([]LiveChannel, error)

LiveChannels lists channels in their sources' order. Without all, only the ones that play and aren't hidden; with sourceID, only that source's.

func (*Store) LiveChannelsToCheck added in v0.2.0

func (s *Store) LiveChannelsToCheck(ctx context.Context, before int64, limit int) ([]LiveChannel, error)

LiveChannelsToCheck are the channels checked longest ago, none since before.

func (*Store) LivePrograms added in v0.2.0

func (s *Store) LivePrograms(ctx context.Context, from, to int64, channels []string) ([]LiveProgram, error)

LivePrograms lists what's on between from and to (Unix seconds), on the given channels or, with none, on every channel.

func (*Store) LiveSource added in v0.2.0

func (s *Store) LiveSource(ctx context.Context, id string) (LiveSource, error)

LiveSource is one source.

func (*Store) LiveSources added in v0.2.0

func (s *Store) LiveSources(ctx context.Context) ([]LiveSource, error)

LiveSources lists the sources, oldest first.

func (*Store) LocalHash added in v0.2.4

func (s *Store) LocalHash(ctx context.Context, id int64) (string, error)

LocalHash returns the hash of the file last applied to an item, "" for none.

func (*Store) LockedFields added in v0.2.4

func (s *Store) LockedFields(ctx context.Context, id int64) ([]string, error)

LockedFields lists the fields of an item an admin set by hand.

func (*Store) LookUpAgain added in v0.2.0

func (s *Store) LookUpAgain(ctx context.Context, id int64) error

LookUpAgain makes an item wait for an online lookup again, as if it were new, unless an admin locked its match.

func (*Store) MBID added in v0.1.7

func (s *Store) MBID(ctx context.Context, id int64) (string, error)

MBID returns the MusicBrainz id an artist or album was matched to, "" for none.

func (*Store) ManualItems

func (s *Store) ManualItems(ctx context.Context, userID int64, collectionID string) ([]Item, error)

ManualItems lists a manual collection's titles in the order they were added.

func (*Store) MarkDetails

func (s *Store) MarkDetails(ctx context.Context, id int64) error

MarkDetails records that an item's details were looked up and nothing was found, so it isn't asked for again until the next refresh.

func (*Store) MarkPlaced added in v0.2.4

func (s *Store) MarkPlaced(ctx context.Context, id int64, order string) error

MarkPlaced records that a show's episode was left where the scan put it, as when the show has no such episode online.

func (*Store) MarkPodcastPlayed added in v0.1.7

func (s *Store) MarkPodcastPlayed(ctx context.Context, userID, podcastID int64, played bool) error

MarkPodcastPlayed marks every episode of a show played for a person, or unplayed, which also forgets where they were in each.

func (*Store) MediaInfo

func (s *Store) MediaInfo(ctx context.Context, id int64, version int) (info string, current, ok bool, err error)

MediaInfo returns a file's analysis as JSON, and whether it still matches the file. ok is false when it was never analyzed.

func (*Store) MergeAlbums added in v0.1.7

func (s *Store) MergeAlbums(ctx context.Context, into, artistID int64, from []int64) error

MergeAlbums moves the tracks of the albums in from onto album into, files into under the artist artistID, and removes what that leaves empty. Each track keeps the name of the artist it was filed under as its own artist, unless that is the album's artist. into keeps its cover, or takes the first of theirs if it has none.

func (*Store) MergeBookProgress added in v0.1.6

func (s *Store) MergeBookProgress(ctx context.Context, userID int64, e ProgressEvent) (bool, error)

MergeBookProgress is SetBookProgress for a place recorded offline: it applies unless the book's place changed more recently (see MergeProgress), and reports whether it did.

func (*Store) MergeProgress

func (s *Store) MergeProgress(ctx context.Context, userID int64, e ProgressEvent) (bool, error)

MergeProgress applies a change unless the item's progress changed more recently, so watching on another device in the meantime isn't undone. It reports whether the change was applied.

func (*Store) MergeRating added in v0.1.9

func (s *Store) MergeRating(ctx context.Context, userID, itemID int64, rating int, at int64) (bool, error)

MergeRating saves a rating made at a Unix time, unless the person rated the item more recently, and reports whether it did.

func (*Store) MetadataLanguages added in v0.1.1

func (s *Store) MetadataLanguages(ctx context.Context) ([]string, error)

MetadataLanguages lists the languages besides English that people use: picked by a profile or asked for by a device.

func (*Store) MoveFile added in v0.2.0

func (s *Store) MoveFile(ctx context.Context, keep, from int64) error

MoveFile gives item keep the file of item from, then deletes from. keep is a file that went missing and from the file that took its place, so keep's id, and with it everyone's watch history, ratings, lists and downloads, stays. Anything people already did with from (it may have been around for a little while) is kept too, unless keep has its own; for progress the newer wins. What's worked out from the file itself, such as intro markers and seek bar pictures, is redone in the background when the file is different (see MediaKey).

func (*Store) MoveTo added in v0.2.7

func (s *Store) MoveTo(ctx context.Context, dsn string, progress MoveProgress) (MoveReport, error)

MoveTo copies this database to the one at dsn, which must be empty, and checks every table has the same number of rows in both. The tables are made by Matinee's own schema and migrations, in one transaction with the copy, so a move that fails leaves nothing behind. This database isn't changed. Nothing else should write to it meanwhile: what's written during the copy isn't in it (the server moves at start, before anything else uses the database, and the command asks for the server to be stopped).

func (*Store) MovedEpisodes added in v0.2.4

func (s *Store) MovedEpisodes(ctx context.Context, seasonID int64) (map[int64]bool, error)

MovedEpisodes lists the episodes of a season that are found online somewhere other than where they're shown.

func (*Store) Narrators added in v0.1.2

func (s *Store) Narrators(ctx context.Context, userID, libraryID int64) ([]BookGroup, error)

Narrators lists everyone who narrates a book of the library, by name.

func (*Store) NeedsDetails

func (s *Store) NeedsDetails(ctx context.Context, libraryID, olderThan int64) ([]Item, error)

NeedsDetails lists a library's matched movies, shows and seasons whose details were never fetched or were fetched before olderThan (Unix seconds).

func (*Store) NeedsGenres

func (s *Store) NeedsGenres(ctx context.Context, libraryID int64) ([]Item, error)

NeedsGenres lists a library's matched movies and shows whose genres weren't looked up, such as ones matched before Matinee kept genres.

func (*Store) NeedsMetadata

func (s *Store) NeedsMetadata(ctx context.Context, libraryID int64, kinds []string) ([]Item, error)

NeedsMetadata lists a library's items of the given kinds not yet looked up online, or albums and books without a cover looked up over artRetry ago, shows before seasons and episodes so those can use the show's match, and items without artwork before those looked up again.

func (*Store) NeedsSeasonTranslations added in v0.1.1

func (s *Store) NeedsSeasonTranslations(ctx context.Context, libraryID int64, lang string) ([]Item, error)

NeedsSeasonTranslations lists a library's seasons of matched shows that, or one of whose episodes, have no row in a language yet. Seasons are looked up one language at a time, with their episodes, so only in the languages people use.

func (*Store) NeedsTranslations added in v0.1.1

func (s *Store) NeedsTranslations(ctx context.Context, libraryID, olderThan int64) ([]Item, error)

NeedsTranslations lists a library's matched movies and shows whose translations were never fetched or were fetched before olderThan (Unix seconds).

func (*Store) NewEpisodes added in v0.1.7

func (s *Store) NewEpisodes(ctx context.Context, userID, since int64, limit int) ([]Item, error)

NewEpisodes lists episodes of the shows a person follows that came out since the given time (Unix seconds) and that they haven't started, the newest first. Trailers are left out.

func (*Store) NewReleases

func (s *Store) NewReleases(ctx context.Context, userID int64, sinceYear, limit int) ([]Item, error)

NewReleases lists movies and shows from the given year on, newest first.

func (*Store) NextDownload

func (s *Store) NextDownload(ctx context.Context) (Download, error)

NextDownload claims the oldest queued download whose retry time has come, marking it and every other download of the same file as preparing.

func (*Store) NextEpisode

func (s *Store) NextEpisode(ctx context.Context, userID int64, ep Item) (Item, error)

NextEpisode is the episode after the given one: the next in its season, else the first of the following season. Specials (season 0) only lead to other specials, and regular seasons never lead into specials. It returns ErrNotFound after a show's last episode, or for anything that isn't an episode. Only episodes the user may see count (see visibleToMe). An audiobook's part leads to the book's next part, for players that play a book a part at a time.

func (*Store) NextPodcastEpisode added in v0.1.13

func (s *Store) NextPodcastEpisode(ctx context.Context, userID int64, ep Item, since int64) (Item, error)

NextPodcastEpisode is what plays after an episode ends: the next episode of the same show the person hasn't played, in the order they came out, else the newest unstarted episode of another show they follow that came out since the given time (Unix seconds). Trailers never play on by themselves. It returns ErrNotFound when there's nothing.

func (*Store) NoteLanguageSeen added in v0.1.1

func (s *Store) NoteLanguageSeen(ctx context.Context, lang string) (bool, error)

NoteLanguageSeen records that a device asked for a language, and reports whether it was new.

func (*Store) Notifications added in v0.2.3

func (s *Store) Notifications(ctx context.Context, users []int64, limit int) ([]Notification, int, error)

Notifications lists the newest notifications for the given people (a profile sees its own and its account's), and how many are unread.

func (*Store) NotifyMe added in v0.2.3

func (s *Store) NotifyMe(ctx context.Context, userID int64, kind string, tmdbID, tvdbID int, on bool) error

NotifyMe asks for a person to be told when a title on its way arrives, as the people who asked for it are. kind is movie or show.

func (*Store) NotifyMeTitles added in v0.2.3

func (s *Store) NotifyMeTitles(ctx context.Context, userID int64) (map[string]bool, error)

NotifyMeTitles are the titles a person asked to be told about, as "kind:tmdb:tvdb" keys.

func (*Store) OpenIssue added in v0.2.4

func (s *Store) OpenIssue(ctx context.Context, itemID int64) (bool, error)

OpenIssue reports whether an item has a problem reported that isn't resolved yet.

func (*Store) OpenRequest

func (s *Store) OpenRequest(ctx context.Context, kind string, id int) (Request, error)

OpenRequest finds a pending or approved request for a title, by TMDB id for movies or TVDB id for shows, so it isn't asked for twice.

func (*Store) OpenRequestTMDB added in v0.2.3

func (s *Store) OpenRequestTMDB(ctx context.Context, kind string, tmdbID int) (Request, error)

OpenRequestTMDB is like OpenRequest, by TMDB id for shows too.

func (*Store) OrderPlaylist added in v0.1.7

func (s *Store) OrderPlaylist(ctx context.Context, id string, entryIDs []string) error

OrderPlaylist puts a playlist's entries in the order given. Entries left out, such as songs the viewer can't see, follow in the order they had. Ids that aren't on the playlist are ignored.

func (*Store) PairedDeviceCode added in v0.1.13

func (s *Store) PairedDeviceCode(ctx context.Context, pair string) (DeviceCode, error)

PairedDeviceCode finds the code a TV asked for with a pairing secret. The TV showed the secret in a QR code; the phone that scanned it told the TV which server to use (over the home network, never through anyone else's server) and now looks for the TV's code here, to approve it without anyone typing it. Codes asked for again with the same secret replace older ones, so the newest wins.

func (*Store) PendingDeviceCode

func (s *Store) PendingDeviceCode(ctx context.Context, userCode string) (DeviceCode, error)

PendingDeviceCode looks up a code someone typed, for the "sign in this device?" screen.

func (*Store) Person

func (s *Store) Person(ctx context.Context, id int64) (Person, error)

func (*Store) PersonTitles

func (s *Store) PersonTitles(ctx context.Context, userID, personID int64) ([]PersonTitle, error)

PersonTitles lists the movies and shows in the library a person is in, newest first. Parts in single episodes count toward their show.

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

Ping checks the database is reachable, for readiness probes.

func (*Store) PlaceEpisode added in v0.2.4

func (s *Store) PlaceEpisode(ctx context.Context, libraryID, showID, id int64, p Place, order string) (moved bool, err error)

PlaceEpisode puts an episode named by absolute number in its season by the show's order. It's looked up online again when its place changed.

func (*Store) Playlist added in v0.1.7

func (s *Store) Playlist(ctx context.Context, userID int64, id string) (Playlist, error)

Playlist returns one of someone's playlists, or ErrNotFound when they have none with that id.

func (*Store) PlaylistEntries added in v0.1.7

func (s *Store) PlaylistEntries(ctx context.Context, userID int64, id string) ([]PlaylistEntry, error)

PlaylistEntries lists a playlist's songs in order, leaving out any the viewer may not play.

func (*Store) Playlists added in v0.1.7

func (s *Store) Playlists(ctx context.Context, userID int64) ([]Playlist, error)

Playlists lists someone's playlists, the most recently changed first.

func (*Store) PluginKeys added in v0.1.1

func (s *Store) PluginKeys(ctx context.Context, pluginID string, userID int64, prefix string) (keys []PluginKey, total int64, err error)

PluginKeys lists a user's keys that start with prefix, newest first, and how much the plugin keeps for them in all.

func (*Store) PluginValue added in v0.1.1

func (s *Store) PluginValue(ctx context.Context, pluginID string, userID int64, key string) ([]byte, error)

PluginValue returns what a plugin keeps under key for a user.

func (*Store) PodcastByFeed added in v0.1.7

func (s *Store) PodcastByFeed(ctx context.Context, libraryID int64, feedURL string) (int64, error)

PodcastByFeed finds a library's show by its feed's address.

func (*Store) PodcastDownloadsOf added in v0.1.13

func (s *Store) PodcastDownloadsOf(ctx context.Context, userID, podcastID int64) (PodcastDownloads, error)

PodcastDownloadsOf returns a person's downloads for a show; the defaults (off, keep 3) when they don't follow it.

func (*Store) PodcastFeedOf added in v0.1.7

func (s *Store) PodcastFeedOf(ctx context.Context, id int64) (PodcastFeed, error)

PodcastFeedOf returns a show's feed.

func (*Store) PodcastFeeds added in v0.1.7

func (s *Store) PodcastFeeds(ctx context.Context, libraryID int64) ([]PodcastFeed, error)

PodcastFeeds lists a library's shows' feeds, by name.

func (*Store) PodcastRefreshed added in v0.1.7

func (s *Store) PodcastRefreshed(ctx context.Context, id int64, feedURL, etag, lastModified, problem string) error

PodcastRefreshed records a refresh of a show's feed: where the feed is now, what to send to ask only for changes next time, and what went wrong ("" for nothing).

func (*Store) PodcastsByFeed added in v0.1.7

func (s *Store) PodcastsByFeed(ctx context.Context, feedURLs []string) (map[string]int64, error)

PodcastsByFeed finds the shows any library has for these feed addresses, by address.

func (*Store) Profile

func (s *Store) Profile(ctx context.Context, id int64) (Profile, error)

Profile returns one profile.

func (*Store) Profiles

func (s *Store) Profiles(ctx context.Context, accountID int64) ([]Profile, error)

Profiles lists an account's profiles, in the order they were made.

func (*Store) PruneEmpty added in v0.2.4

func (s *Store) PruneEmpty(ctx context.Context, libraryID int64) error

PruneEmpty deletes a library's shows, seasons, artists and albums left with nothing in them, such as a show whose episodes a scan filed under another show.

func (*Store) PruneLivePrograms added in v0.2.0

func (s *Store) PruneLivePrograms(ctx context.Context, before int64) error

PruneLivePrograms drops shows that ended before then.

func (*Store) PutDownload

func (s *Store) PutDownload(ctx context.Context, d Download) (Download, error)

PutDownload asks for an item on a device. A device has at most one download per item, so asking again is safe: the same request returns the existing download (and retries it if it failed or expired), and a different quality replaces it.

func (*Store) PutEpisode added in v0.1.7

func (s *Store) PutEpisode(ctx context.Context, libraryID, podcastID int64, e PodcastEpisode) (id int64, added bool, err error)

PutEpisode adds an episode to a show, or brings one it has in line with the feed, keeping everyone's place in it. added is true for a new one.

func (*Store) ReadNotifications added in v0.2.3

func (s *Store) ReadNotifications(ctx context.Context, users []int64, ids []string) error

ReadNotifications marks the given people's notifications read: those with the ids given, or all of them when ids is empty.

func (*Store) RecentlyAdded

func (s *Store) RecentlyAdded(ctx context.Context, userID int64, limit int) ([]Item, error)

RecentlyAdded lists the newest movies, albums, books and shows. A show counts as new when an episode is, so a fresh season doesn't fill the row with episodes.

func (*Store) RecentlyAddedOf added in v0.2.3

func (s *Store) RecentlyAddedOf(ctx context.Context, userID int64, kind string, limit int) ([]Item, error)

RecentlyAddedOf lists the newest titles of one kind (see RecentlyAddedKinds). Shows count as new when an episode is, as in RecentlyAdded.

func (*Store) RecentlyWatched added in v0.1.1

func (s *Store) RecentlyWatched(ctx context.Context, userID int64, limit int) ([]Watched, error)

RecentlyWatched lists the movies and shows with a TMDB id that the user played lately, newest first. Watching an episode counts for its show.

func (*Store) RecordLiveCheck added in v0.2.0

func (s *Store) RecordLiveCheck(ctx context.Context, id string, ok bool) error

RecordLiveCheck saves how a check of a channel's stream went. A channel that fails LiveBrokenAfter in a row is broken until one works again.

func (*Store) RedeemDeviceCode

func (s *Store) RedeemDeviceCode(ctx context.Context, deviceCode string) (int64, Device, error)

RedeemDeviceCode is the device's poll. Once the code is approved it returns the user and device, exactly once; the caller starts the session. Otherwise it returns ErrCodePending, ErrCodeDenied or ErrCodeExpired.

func (*Store) Related

func (s *Store) Related(ctx context.Context, userID int64, it Item) ([]Item, error)

Related lists titles in the library like the given movie or show, best first: ones TMDB recommends, ones by the same director or creator, with the same leads, keywords and genres. Members of its collection are left out; see CollectionItems.

func (*Store) RelatedN added in v0.1.1

func (s *Store) RelatedN(ctx context.Context, userID int64, it Item, limit int) ([]Item, error)

RelatedN is Related with up to limit titles.

func (*Store) RemoveFiles added in v0.2.0

func (s *Store) RemoveFiles(ctx context.Context, libraryID int64, ids []int64) error

RemoveFiles deletes these files, then any containers of the library left empty.

func (*Store) RemoveFoundSubtitle added in v0.1.10

func (s *Store) RemoveFoundSubtitle(ctx context.Context, itemID int64, id string) error

RemoveFoundSubtitle forgets a subtitle found for a video.

func (*Store) RemoveFromCollection

func (s *Store) RemoveFromCollection(ctx context.Context, collectionID string, itemID int64) error

func (*Store) RemoveFromPlaylist added in v0.1.7

func (s *Store) RemoveFromPlaylist(ctx context.Context, id string, entryIDs []string) error

RemoveFromPlaylist takes entries off a playlist.

func (*Store) RemoveFromWatchList

func (s *Store) RemoveFromWatchList(ctx context.Context, userID, itemID int64) error

func (*Store) RemoveSubtitleSync added in v0.2.1

func (s *Store) RemoveSubtitleSync(ctx context.Context, itemID int64, track string) error

RemoveSubtitleSync forgets a track's sync.

func (*Store) RenamePlaylist added in v0.1.7

func (s *Store) RenamePlaylist(ctx context.Context, userID int64, id, name string) error

RenamePlaylist changes a playlist's name.

func (*Store) RenameStation added in v0.1.15

func (s *Store) RenameStation(ctx context.Context, id int64, name string) error

RenameStation changes a station's name.

func (*Store) Request

func (s *Store) Request(ctx context.Context, id string) (Request, error)

func (*Store) Requesters added in v0.2.3

func (s *Store) Requesters(ctx context.Context, kind string, tmdbID, tvdbID int) ([]int64, error)

Requesters lists who asked for a title that's been approved (or is waiting, in case an admin added it in Box Office themselves), and who asked to be told when it arrives: by TMDB id for movies, by TVDB or TMDB id for shows.

func (*Store) Requests

func (s *Store) Requests(ctx context.Context, userID int64, limit int) ([]Request, error)

Requests lists requests, pending ones first, then the newest. userID 0 lists everyone's.

func (*Store) RequeueDownload

func (s *Store) RequeueDownload(ctx context.Context, d Download) error

RequeueDownload prepares a ready download again, as when its file went missing or changed.

func (*Store) RequeueInterrupted

func (s *Store) RequeueInterrupted(ctx context.Context) error

RequeueInterrupted puts downloads that were being prepared when the server stopped back in the queue.

func (*Store) ResetArtLookups added in v0.1.3

func (s *Store) ResetArtLookups(ctx context.Context, libraryID int64) (int64, error)

ResetArtLookups has the next scan of a music or audiobook library look online again (and, for albums, read their files' tags again) for every artist, album, author and book without a picture from its own files, including ones that couldn't be matched before. The online pictures they have stay until a lookup finds another. It returns how many items it reset.

func (*Store) ResolveIssue

func (s *Store) ResolveIssue(ctx context.Context, id, resolution string) error

func (*Store) SQLite added in v0.2.0

func (s *Store) SQLite() bool

SQLite says whether the database is a SQLite file (which Backup copies).

func (*Store) SaveLiveChannels added in v0.2.0

func (s *Store) SaveLiveChannels(ctx context.Context, sourceID string, chans []LiveChannel) error

SaveLiveChannels replaces a source's channels with what its playlist lists now. Channels it still lists keep their id, whether an admin hid them, and how their checks went.

func (*Store) SaveLiveGuide added in v0.2.0

func (s *Store) SaveLiveGuide(ctx context.Context, sourceID string, programs []LiveProgram, guideErr string) error

SaveLiveGuide replaces what's on a source's channels from now on, and says the guide was read (or why it couldn't be, keeping the old one).

func (*Store) Search

func (s *Store) Search(ctx context.Context, userID int64, q string, limit int) ([]Item, error)

Search matches titles by word prefix, e.g. "star wa" finds "Star Wars", and the movies and shows of cast members matched the same way, e.g. "keanu" finds what Keanu Reeves is in. Titles named like the search come first.

func (*Store) SearchPeople added in v0.2.4

func (s *Store) SearchPeople(ctx context.Context, userID int64, q string, limit int) ([]FilterPerson, error)

SearchPeople finds cast members of titles the user may see by name, as Search does, in the most titles first. Guest parts count toward their show.

func (*Store) Series added in v0.1.2

func (s *Store) Series(ctx context.Context, userID, libraryID int64) ([]BookGroup, error)

Series lists a library's series by name.

func (*Store) SessionDeviceName added in v0.1.1

func (s *Store) SessionDeviceName(ctx context.Context, token string) (string, error)

SessionDeviceName is the name of the device a session token belongs to.

func (*Store) SessionUser

func (s *Store) SessionUser(ctx context.Context, token string) (u User, homeOnly bool, err error)

SessionUser returns who a session watches as: the profile it picked, or else its account. homeOnly is true for sessions that only work at home.

func (*Store) Sessions

func (s *Store) Sessions(ctx context.Context, userID int64, current string) ([]Session, error)

Sessions lists a user's signed-in devices, most recently used first. current is the token of the request asking, which is marked.

func (*Store) SetAdmin

func (s *Store) SetAdmin(ctx context.Context, userID int64, admin bool) error

SetAdmin makes an account an admin or not. The last admin stays one.

func (*Store) SetAlbumLabel added in v0.1.15

func (s *Store) SetAlbumLabel(ctx context.Context, id int64, label string) error

SetAlbumLabel keeps the record label an album's files name, and notes that its files were read for one. An empty label leaves any label the album has. A label already in the library under another spelling, such as ANJUNADEEP for Anjunadeep, keeps the library's spelling, so both albums land on one label page.

func (*Store) SetAlbumTags added in v0.1.7

func (s *Store) SetAlbumTags(ctx context.Context, id int64, release, group string) error

SetAlbumTags records the MusicBrainz ids read from an album's files, "" for none, and that they have been read. An album without a cover is looked up again when its files name an album they didn't before.

func (*Store) SetArt

func (s *Store) SetArt(ctx context.Context, id int64, poster, backdrop string) error

SetArt records artwork found on disk. Local art wins over anything fetched online, since a file next to the media is the user's own choice, and a cover an admin picked wins over both.

func (*Store) SetBookInfo added in v0.1.2

func (s *Store) SetBookInfo(ctx context.Context, id int64, b BookInfo) error

SetBookInfo records what a book's files say about it. What a file leaves out keeps what the book had.

func (*Store) SetBookProgress added in v0.1.2

func (s *Store) SetBookProgress(ctx context.Context, userID, bookID, positionMs int64, played bool) error

SetBookProgress saves where someone is in a book. Its parts count as played when the book is finished, and as not played again when it isn't, so filters such as unwatched treat books like albums.

func (*Store) SetChosenImage added in v0.1.7

func (s *Store) SetChosenImage(ctx context.Context, id int64, img ChosenImage) error

SetChosenImage makes img the item's cover.

func (*Store) SetDownloadProgress

func (s *Store) SetDownloadProgress(ctx context.Context, file string, permille int) error

SetDownloadProgress updates every download being prepared from file.

func (*Store) SetEndCredits added in v0.1.13

func (s *Store) SetEndCredits(ctx context.Context, itemID, startMs, endMs int64, source, key string) error

SetEndCredits records what the detector found in one video: where its credits start and end (0 for the end of the file) and how it knows, or zeros for none.

func (*Store) SetEpisodeDuration added in v0.1.7

func (s *Store) SetEpisodeDuration(ctx context.Context, id, ms int64) error

SetEpisodeDuration records how long an episode really is, once a player knows: feeds often leave it out or get it wrong.

func (*Store) SetEpisodeOrder added in v0.2.4

func (s *Store) SetEpisodeOrder(ctx context.Context, showID int64, order string) error

SetEpisodeOrder sets the order a show's absolute-numbered episodes are put in seasons by; they're put in again on the next lookup.

func (*Store) SetFriend added in v0.1.10

func (s *Store) SetFriend(ctx context.Context, userID int64, friend bool, libraries []int64) error

SetFriend makes an account a friend with the given libraries, or (with friend false) a household account that sees everything again.

func (*Store) SetGameVersion added in v0.2.7

func (s *Store) SetGameVersion(ctx context.Context, id, of int64, edition string) error

SetGameVersion makes a game file a version of another (of 0 makes it a title of its own) and names its edition. A game that was a title of its own brings its history (saves aside, which stay with each file) to the title it joins, as a movie's versions do.

func (*Store) SetGapless added in v0.1.13

func (s *Store) SetGapless(ctx context.Context, albumID int64, on *bool) error

SetGapless saves the household's choice for an album: on, off, or nil to leave it to Matinee.

func (*Store) SetGaplessFound added in v0.1.13

func (s *Store) SetGaplessFound(ctx context.Context, albumID int64, found bool, key string) error

SetGaplessFound records what the detector found for an album's files.

func (*Store) SetGenres

func (s *Store) SetGenres(ctx context.Context, id int64, genres []string) error

SetGenres records a movie's or show's genres (none is an empty list).

func (*Store) SetIntro added in v0.1.10

func (s *Store) SetIntro(ctx context.Context, itemID, startMs, endMs int64, key string) error

SetIntro records what the detector found in one episode: where its intro starts and ends, or zeros for none.

func (*Store) SetIssueRequest added in v0.2.4

func (s *Store) SetIssueRequest(ctx context.Context, id, requestID string) error

SetIssueRequest links an issue to the request for another copy sent to Box Office for it.

func (*Store) SetLiveChannelHidden added in v0.2.0

func (s *Store) SetLiveChannelHidden(ctx context.Context, id string, hidden bool) error

SetLiveChannelHidden hides a channel from everyone, or shows it again.

func (*Store) SetLiveSourceError added in v0.2.0

func (s *Store) SetLiveSourceError(ctx context.Context, id, msg string) error

SetLiveSourceError saves why a source's refresh failed, leaving its channels as they were.

func (*Store) SetMatch added in v0.2.0

func (s *Store) SetMatch(ctx context.Context, id int64, m *Metadata, locked bool) error

SetMatch replaces a movie's or show's online match with m, or with none when m is nil. Everything the old match brought (description, rating, genres, artwork found online, cast and crew, translations) goes first, while local artwork and a cover an admin picked stay. A show's seasons and episodes are looked up again under the new match. locked says the match was picked by hand, so lookups leave it alone from now on.

func (*Store) SetMediaInfo

func (s *Store) SetMediaInfo(ctx context.Context, id int64, size, mtime int64, info string, tags []string, key string) (bool, error)

SetMediaInfo stores a file's analysis, unless the file changed since it was looked at (the scanner got there first), in which case it reports false.

func (*Store) SetMetadataKinds

func (s *Store) SetMetadataKinds(kinds ...string)

SetMetadataKinds says which item kinds an online provider looks up, so those items can show as pending until their lookup is done.

func (*Store) SetMetadataMode added in v0.2.4

func (s *Store) SetMetadataMode(ctx context.Context, libraryID int64, mode string) error

SetMetadataMode sets where a library's details come from first.

func (*Store) SetPassword

func (s *Store) SetPassword(ctx context.Context, userID int64, passwordHash string) error

func (*Store) SetPersonInfo

func (s *Store) SetPersonInfo(ctx context.Context, id int64, in PersonInfo) error

func (*Store) SetPluginValue added in v0.1.1

func (s *Store) SetPluginValue(ctx context.Context, pluginID string, userID int64, key string, value []byte) error

SetPluginValue keeps value under key for a user.

func (*Store) SetPodcastDownloads added in v0.1.13

func (s *Store) SetPodcastDownloads(ctx context.Context, userID, podcastID int64, d PodcastDownloads) error

SetPodcastDownloads changes a person's downloads for a show. Downloading a show's episodes follows it, so it's in their list and on Home too.

func (*Store) SetProgress

func (s *Store) SetProgress(ctx context.Context, userID, itemID, positionMs int64, played bool) error

SetProgress saves where the user is in an item. Any progress brings an item back to Continue Watching.

func (*Store) SetRating added in v0.1.9

func (s *Store) SetRating(ctx context.Context, userID, itemID int64, rating int) error

SetRating saves someone's rating of an item.

func (*Store) SetSchemaVersionForTest added in v0.2.0

func (s *Store) SetSchemaVersionForTest(ctx context.Context, v int) error

SetSchemaVersionForTest pretends the database has an older schema, for tests of what happens before an upgrade. Its migrations run again.

func (*Store) SetSeasonTranslations added in v0.1.1

func (s *Store) SetSeasonTranslations(ctx context.Context, seasonID int64, lang string, season Translation, episodes map[int64]Translation) error

SetSeasonTranslations keeps a season's and its episodes' text in one language. Each gets a row even without a translation, so it isn't looked up again.

func (*Store) SetSessionProfile

func (s *Store) SetSessionProfile(ctx context.Context, token string, profileID int64) error

SetSessionProfile switches the profile a session watches as; 0 goes back to the account itself.

func (*Store) SetSetting

func (s *Store) SetSetting(ctx context.Context, key, value string) error

func (*Store) SetSubtitleStreams

func (s *Store) SetSubtitleStreams(ctx context.Context, id int64, streams string) error

SetSubtitleStreams records a file's embedded subtitle streams as JSON.

func (*Store) SetSubtitleSync added in v0.2.1

func (s *Store) SetSubtitleSync(ctx context.Context, v SubtitleSync) error

SetSubtitleSync keeps what lining up a track found, replacing what was there.

func (*Store) SetThumbnails added in v0.1.11

func (s *Store) SetThumbnails(ctx context.Context, itemID int64, t Thumbnails, key string) error

SetThumbnails records the pictures made of a video; a zero Count says the file couldn't be read, so it isn't tried again until it changes.

func (*Store) SetTrackChoice added in v0.2.4

func (s *Store) SetTrackChoice(ctx context.Context, userID, itemID int64, c TrackChoice, setAudio, setSubtitle bool) error

SetTrackChoice keeps a person's picks for an item. setAudio and setSubtitle say which of c's halves to change; the other stays.

func (*Store) SetTranslations added in v0.1.1

func (s *Store) SetTranslations(ctx context.Context, id int64, tr map[string]Translation) error

SetTranslations replaces a movie's or show's translations, by language.

func (*Store) SetUserLanguage added in v0.1.1

func (s *Store) SetUserLanguage(ctx context.Context, userID int64, lang string) error

SetUserLanguage keeps the language a profile picked; "" follows the device.

func (*Store) Setting

func (s *Store) Setting(ctx context.Context, key string) (string, error)

Setting returns a server-wide setting, or "" when it was never set.

func (*Store) ShowsToPlace added in v0.2.4

func (s *Store) ShowsToPlace(ctx context.Context, libraryID int64) ([]ShowToPlace, error)

ShowsToPlace lists a library's matched shows that have episodes named by absolute number not yet put in seasons by the show's order.

func (*Store) Similar

func (s *Store) Similar(ctx context.Context, userID int64, show Item) (Item, error)

Similar picks a title to suggest after a show's last episode: the most related show the user hasn't finished, else the most related title.

func (*Store) StalePodcasts added in v0.1.7

func (s *Store) StalePodcasts(ctx context.Context, before int64) ([]PodcastFeed, error)

StalePodcasts lists every show last refreshed before the given time (Unix seconds), the longest waiting first.

func (*Store) StartDeviceCode

func (s *Store) StartDeviceCode(ctx context.Context, dev Device, ttl time.Duration, pair string) (DeviceCode, error)

StartDeviceCode makes a code for a device to show. pair is the secret a TV showed in a QR code for a phone to set it up with, or "" (see PairedDeviceCode).

func (*Store) StationStream added in v0.2.3

func (s *Store) StationStream(ctx context.Context, id int64) (string, bool, error)

StationStream is a station's stream and whether it's on the home network (Station.Home), or ErrNotFound for anything else.

func (*Store) StationStreams added in v0.1.15

func (s *Store) StationStreams(ctx context.Context, libraryID int64) (map[string]int64, error)

StationStreams maps each stream in a music library to its station, to mark what's added already in directory results.

func (*Store) StationURL added in v0.1.15

func (s *Store) StationURL(ctx context.Context, id int64) (string, error)

StationURL is a station's stream, or ErrNotFound for anything else.

func (*Store) Stations added in v0.1.15

func (s *Store) Stations(ctx context.Context, userID, libraryID int64) ([]Item, error)

Stations lists a music library's radio stations by name.

func (*Store) SubtitleStreams

func (s *Store) SubtitleStreams(ctx context.Context, id int64) (streams string, ok bool, err error)

SubtitleStreams returns a file's embedded subtitle streams as stored by the scanner, as JSON. ok is false for files scanned before Matinee looked for them.

func (*Store) SubtitleSyncFor added in v0.2.1

func (s *Store) SubtitleSyncFor(ctx context.Context, itemID int64, track string) (SubtitleSync, error)

SubtitleSyncFor returns one track's sync.

func (*Store) SubtitleSyncs added in v0.2.1

func (s *Store) SubtitleSyncs(ctx context.Context, itemID int64) ([]SubtitleSync, error)

SubtitleSyncs lists a video's subtitle syncs.

func (*Store) SumBookLengths added in v0.1.2

func (s *Store) SumBookLengths(ctx context.Context, libraryID int64) error

SumBookLengths gives each book of a library the length of all its parts.

func (*Store) ThumbnailCounts added in v0.1.11

func (s *Store) ThumbnailCounts(ctx context.Context, version int) (total, done int, err error)

ThumbnailCounts says how many videos there are, and how many have pictures made of them as they are now (or couldn't be read).

func (*Store) ThumbnailFile added in v0.1.11

func (s *Store) ThumbnailFile(ctx context.Context, id int64) (ThumbnailFile, error)

ThumbnailFile returns one video, for making its pictures on demand.

func (*Store) ThumbnailFiles added in v0.1.11

func (s *Store) ThumbnailFiles(ctx context.Context, afterID int64, limit int) ([]ThumbnailFile, error)

ThumbnailFiles lists videos with ids above afterID, in id order, with what was made of them before.

func (*Store) ThumbnailIDs added in v0.1.11

func (s *Store) ThumbnailIDs(ctx context.Context) (map[int64]bool, error)

ThumbnailIDs lists the videos pictures were made of, to clear away the files of videos that are gone.

func (*Store) TopLevel

func (s *Store) TopLevel(ctx context.Context, userID, libraryID int64) ([]Item, error)

TopLevel lists a library's root items: movies, shows or artists.

func (*Store) TrackChoiceFor added in v0.2.4

func (s *Store) TrackChoiceFor(ctx context.Context, userID, itemID int64) (TrackChoice, error)

TrackChoiceFor returns a person's picks for an item, or ErrNotFound.

func (*Store) Tracks added in v0.1.1

func (s *Store) Tracks(ctx context.Context, userID, id int64) ([]Item, error)

Tracks lists every track under an artist or album, in order: albums oldest first, then by disc and track. For a track, it's its album's.

func (*Store) TranslatedTagline added in v0.1.1

func (s *Store) TranslatedTagline(ctx context.Context, id int64) (string, error)

TranslatedTagline returns an item's tagline in the context's language, or "" when it has none.

func (*Store) Unfollow added in v0.1.7

func (s *Store) Unfollow(ctx context.Context, userID, podcastID int64) error

func (*Store) UnlockDetails added in v0.2.4

func (s *Store) UnlockDetails(ctx context.Context, id int64) error

UnlockDetails lets lookups and scans set an item's details again, and has it looked up again (unless its match is locked) and its file details read again.

func (*Store) UnplayedEpisodes added in v0.1.7

func (s *Store) UnplayedEpisodes(ctx context.Context, userID int64, podcastIDs []int64) (map[int64]int, error)

UnplayedEpisodes counts each of the given shows' episodes a person hasn't played, by show.

func (*Store) UnreadableVideos added in v0.2.4

func (s *Store) UnreadableVideos(ctx context.Context, version, limit int) ([]UnreadableVideo, int, error)

UnreadableVideos lists the videos, as they are now, that couldn't be read for their seek bar pictures, by title, at most limit of them, and how many there are in all.

func (*Store) UpdateCollection

func (s *Store) UpdateCollection(ctx context.Context, c SavedCollection) (SavedCollection, error)

UpdateCollection saves a collection's name, filter, order and pins. Its kind and owner stay as they are.

func (*Store) UpdateLiveSource added in v0.2.0

func (s *Store) UpdateLiveSource(ctx context.Context, src LiveSource) error

UpdateLiveSource changes a source's name, playlist, pick and guide.

func (*Store) UpdatePodcast added in v0.1.7

func (s *Store) UpdatePodcast(ctx context.Context, id int64, info PodcastInfo) error

UpdatePodcast keeps a show's details in line with its feed. A show renamed to the name of another in the library keeps its old name.

func (*Store) UpdateProfile

func (s *Store) UpdateProfile(ctx context.Context, id int64, c ProfileChanges) error

UpdateProfile changes a profile, or the PIN and avatar of an account.

func (*Store) UpdateRequest

func (s *Store) UpdateRequest(ctx context.Context, id, state, errMsg string, qualityProfileID int) error

UpdateRequest records a decision on a request.

func (*Store) UpsertFile

func (s *Store) UpsertFile(ctx context.Context, it Item) (int64, error)

UpsertFile inserts or updates a playable item keyed by its path. The scanner only calls it for new or changed files, so an update drops what the background analysis knew about the old file.

func (*Store) UserByID

func (s *Store) UserByID(ctx context.Context, id int64) (User, error)

UserByID returns an account people sign in to: not the guest account, and not a profile.

func (*Store) UserByName

func (s *Store) UserByName(ctx context.Context, username string) (User, error)

func (*Store) UserDownload

func (s *Store) UserDownload(ctx context.Context, userID int64, id string) (Download, error)

UserDownload finds one of a user's downloads.

func (*Store) UserLanguage added in v0.1.1

func (s *Store) UserLanguage(ctx context.Context, userID int64) (string, error)

UserLanguage returns the language a profile picked, or "" to follow the device.

func (*Store) Users

func (s *Store) Users(ctx context.Context) ([]User, error)

Users lists the accounts people sign in with, leaving out the home network's guest account and profiles.

func (*Store) Versions added in v0.2.1

func (s *Store) Versions(ctx context.Context, userID, id int64) ([]Item, error)

Versions lists the files of an item's title, the title first and then the rest from the biggest picture down, each with the user's progress (which is the title's). An item with no other versions lists only itself.

func (*Store) Viewer

func (s *Store) Viewer(ctx context.Context, id int64) (User, error)

Viewer returns anyone who can watch: an account, the guest account or a profile.

func (*Store) Viewers added in v0.1.9

func (s *Store) Viewers(ctx context.Context) ([]User, error)

Viewers lists everyone with their own watch history: accounts and every profile, the home network's included, but not the home network's account itself. A profile's AccountID says whose it is.

func (*Store) Waiting

func (s *Store) Waiting(ctx context.Context) (requests, issues int, err error)

Waiting counts pending requests and open issues, for admins' badge. Issues Box Office is fixing, or whose fix is a pending request, don't count.

func (*Store) WatchList

func (s *Store) WatchList(ctx context.Context, userID int64, limit int) ([]Item, error)

WatchList lists the items a user saved to watch later, newest first.

type SubtitleSync added in v0.2.1

type SubtitleSync struct {
	ItemID    int64
	Track     string
	Key       string
	State     string
	OffsetMs  int64
	Rate      float64
	Score     float64
	Reference string
	Auto      bool
	UpdatedAt int64
}

SubtitleSync is what lining up one subtitle track found.

type TableCount added in v0.2.7

type TableCount struct {
	Table string `json:"table"`
	Rows  int64  `json:"rows"`
}

TableCount is how many rows a table has.

type Term

type Term struct {
	Kind string // genre, keyword, collection or rec
	Term string
}

Term is something titles have in common, for finding related titles: a genre, keyword, collection or recommendation.

type ThumbnailFile added in v0.1.11

type ThumbnailFile struct {
	ID         int64
	Title      string
	Path       string
	Size       int64
	Mtime      int64
	DurationMs int64
	// MediaInfo is the media analysis' JSON, which says whether the video
	// is HDR (see probe.MediaInfo); "" before it's analyzed.
	MediaInfo string
	Key       string // file_key as stored, "" when never made
	Count     int    // pictures made as stored; 0 when none or unreadable
}

ThumbnailFile is a video the thumbnail generator may make pictures of.

type Thumbnails added in v0.1.11

type Thumbnails struct {
	IntervalMs int64 `json:"intervalMs"`
	Width      int   `json:"width"`
	Height     int   `json:"height"`
	Columns    int   `json:"columns"`
	Rows       int   `json:"rows"`
	Count      int   `json:"count"`
	MadeAt     int64 `json:"-"` // Unix seconds
}

Thumbnails is how a video's preview pictures are laid out: Count pictures, one every IntervalMs from the start, Width by Height each, in sheets of Columns by Rows, left to right and then down.

func (Thumbnails) Sheets added in v0.1.11

func (t Thumbnails) Sheets() int

Sheets is how many sheet images there are.

type TrackChoice added in v0.2.4

type TrackChoice struct {
	Audio            int    `json:"audio"`
	AudioLanguage    string `json:"audioLanguage,omitempty"`
	AudioKind        string `json:"audioKind,omitempty"` // commentary, descriptive
	Subtitle         string `json:"subtitle,omitempty"`
	SubtitleLanguage string `json:"subtitleLanguage,omitempty"`
	SubtitleKind     string `json:"subtitleKind,omitempty"` // forced, sdh
	UpdatedAt        int64  `json:"updatedAt"`
}

TrackChoice is what a person picked. Audio is -1 and Subtitle "" for what they didn't pick; Subtitle "off" is subtitles turned off.

type Translation added in v0.1.1

type Translation struct {
	Title    string
	Overview string
	Tagline  string
}

Translation is an item's text in one language. Empty fields have no translation.

type UnreadableVideo added in v0.2.4

type UnreadableVideo struct {
	ID    int64
	Title string
	Path  string
}

UnreadableVideo is a video the seek bar's pictures couldn't be made of, as it is now: most likely a damaged file.

type User

type User struct {
	ID       int64  `json:"id"`
	Username string `json:"username"` // a profile's name, for profiles
	IsAdmin  bool   `json:"isAdmin"`
	// Guest is the home network's shared account (see HomeGuest), or one of its profiles.
	Guest bool `json:"guest,omitempty"`
	// AccountID is the account a profile belongs to; 0 for accounts.
	AccountID int64 `json:"accountId,omitempty"`
	// KidsLevel limits a kids profile to titles rated up to it (see the
	// rating package); 0 for everyone else.
	KidsLevel int    `json:"kidsLevel,omitempty"`
	Avatar    string `json:"avatar,omitempty"` // a colour name the apps know, such as coral
	HasPIN    bool   `json:"hasPin,omitempty"`
	// Friend is an account made from an invite, or one of its profiles: it
	// sees only the libraries it was given (see friends.go).
	Friend bool `json:"friend,omitempty"`
	// contains filtered or unexported fields
}

func (User) Account

func (u User) Account() int64

Account is the id of the account a user is, or belongs to as a profile.

func (User) PINHash

func (u User) PINHash() string

func (User) PasswordHash

func (u User) PasswordHash() string

type VersionChanges added in v0.2.1

type VersionChanges struct {
	Grouped, Split, Editions int
}

VersionChanges is what GroupVersions did.

type Watched added in v0.1.1

type Watched struct {
	ItemID int64
	Kind   string // movie or show
	Title  string
	TMDBID int
}

Watched is a movie or show someone played lately, for recommendations.

Directories

Path Synopsis
Package storetest opens a throwaway database for tests: in-memory SQLite by default, or a fresh PostgreSQL database when MATINEE_TEST_DATABASE_URL is set.
Package storetest opens a throwaway database for tests: in-memory SQLite by default, or a fresh PostgreSQL database when MATINEE_TEST_DATABASE_URL is set.

Jump to

Keyboard shortcuts

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