Documentation
¶
Overview ¶
Package store keeps all server state in a single SQLite database.
Index ¶
- Constants
- Variables
- func FormatUserCode(code string) string
- func LanguageFrom(ctx context.Context) string
- func MediaKey(version int, size, mtime int64) string
- func NormalizeUserCode(code string) string
- func SessionID(token string) string
- func SortTitle(title string) string
- func WithLanguage(ctx context.Context, language string) context.Context
- type AnalysisFile
- type Award
- type Book
- type BookChapter
- type BookGroup
- type BookInfo
- type BookPart
- type BoxSet
- type Collection
- type Credit
- type Credits
- type Details
- type DetailsUpdate
- type Device
- type DeviceCode
- type Download
- type Fact
- type FilterOptions
- type FilterPerson
- type FilterValue
- type HolidayMatch
- type Issue
- type Item
- type ItemFilter
- type Library
- type LibraryCount
- type Metadata
- type Person
- type PersonInfo
- type PersonTitle
- type PluginKey
- type Profile
- type ProfileChanges
- type ProgressEvent
- type Request
- type SavedCollection
- type Session
- type Store
- func (s *Store) AddStarterCollections(ctx context.Context) error
- func (s *Store) AddToCollection(ctx context.Context, collectionID string, itemID int64) error
- func (s *Store) AddToWatchList(ctx context.Context, userID, itemID int64) error
- func (s *Store) AllDownloads(ctx context.Context) ([]Download, error)
- func (s *Store) AnalysisCounts(ctx context.Context, version int) (total, done, unreadable int, err error)
- func (s *Store) AnalysisFiles(ctx context.Context, afterID int64, limit int) ([]AnalysisFile, error)
- func (s *Store) ApplyDetails(ctx context.Context, id int64, u DetailsUpdate) error
- func (s *Store) ApplyEpisodeDetails(ctx context.Context, id int64, u DetailsUpdate) error
- func (s *Store) ApplyMetadata(ctx context.Context, id int64, m *Metadata) error
- func (s *Store) BackfillRatingLevels(ctx context.Context, level func(cert string) int) (int, error)
- func (s *Store) Book(ctx context.Context, userID, id int64) (Book, error)
- func (s *Store) BoxSet(ctx context.Context, userID, id int64) (BoxSet, error)
- func (s *Store) BoxSets(ctx context.Context, userID int64) ([]BoxSet, error)
- func (s *Store) Children(ctx context.Context, userID, parentID int64) ([]Item, error)
- func (s *Store) ClearMediaKey(ctx context.Context, id int64) error
- func (s *Store) Close() error
- func (s *Store) Collection(ctx context.Context, id string) (SavedCollection, error)
- func (s *Store) CollectionItems(ctx context.Context, userID, collectionID int64) ([]Item, error)
- func (s *Store) Collections(ctx context.Context, userID int64) ([]SavedCollection, error)
- func (s *Store) ContinueListening(ctx context.Context, userID int64, limit int) ([]Item, error)
- func (s *Store) ContinueWatching(ctx context.Context, userID int64, limit int) ([]Item, error)
- func (s *Store) CountUsers(ctx context.Context) (int, error)
- func (s *Store) CreateCollection(ctx context.Context, c SavedCollection) (SavedCollection, error)
- func (s *Store) CreateHomeSession(ctx context.Context, guestID, profileID int64, ttl time.Duration, dev Device) (string, error)
- func (s *Store) CreateIssue(ctx context.Context, x Issue) (Issue, error)
- func (s *Store) CreateLibrary(ctx context.Context, name, kind string, paths []string) (Library, error)
- func (s *Store) CreateProfile(ctx context.Context, accountID int64, c ProfileChanges) (Profile, error)
- func (s *Store) CreateRequest(ctx context.Context, r Request) (Request, error)
- func (s *Store) CreateSession(ctx context.Context, userID int64, ttl time.Duration, dev Device) (string, error)
- func (s *Store) CreateUser(ctx context.Context, username, passwordHash string, admin bool) (User, error)
- func (s *Store) DecideDeviceCode(ctx context.Context, userCode string, userID int64, approve bool) error
- func (s *Store) DeleteCollection(ctx context.Context, id string) error
- func (s *Store) DeleteDownload(ctx context.Context, userID int64, id string) (Download, error)
- func (s *Store) DeleteLibrary(ctx context.Context, id int64) error
- func (s *Store) DeleteOtherSessions(ctx context.Context, userID int64, keep string) error
- func (s *Store) DeletePluginStorage(ctx context.Context, pluginID string) error
- func (s *Store) DeletePluginValue(ctx context.Context, pluginID string, userID int64, key string) error
- func (s *Store) DeleteProfile(ctx context.Context, id int64) error
- func (s *Store) DeleteRequest(ctx context.Context, id string) error
- func (s *Store) DeleteSession(ctx context.Context, token string) error
- func (s *Store) DeleteSessionByID(ctx context.Context, userID int64, id string) error
- func (s *Store) DeleteUser(ctx context.Context, userID int64) error
- func (s *Store) DownloadFailed(ctx context.Context, file, msg string, maxAttempts int) error
- func (s *Store) DownloadFiles(ctx context.Context) (map[string]bool, error)
- func (s *Store) DownloadPrepared(ctx context.Context, file string, size int64, sha256, md5 string, ...) error
- func (s *Store) Downloads(ctx context.Context, userID int64, deviceID string) ([]Download, error)
- func (s *Store) EnsureContainer(ctx context.Context, libraryID int64, parentID *int64, kind, title string, ...) (int64, error)
- func (s *Store) ExpireFinishedDownloads(ctx context.Context, age time.Duration) ([]string, error)
- func (s *Store) FileInUse(ctx context.Context, file string) (bool, error)
- func (s *Store) FileStat(ctx context.Context, path string) (id, size, mtime int64, err error)
- func (s *Store) FileUnder(ctx context.Context, id int64) (string, error)
- func (s *Store) FilterItems(ctx context.Context, userID int64, f ItemFilter) ([]Item, error)
- func (s *Store) FilterOptions(ctx context.Context, libraryID int64) (FilterOptions, error)
- func (s *Store) FilterPeople(ctx context.Context, libraryID int64, role, q string, limit int) ([]FilterPerson, error)
- func (s *Store) FinishDownload(ctx context.Context, userID int64, id string) error
- func (s *Store) GenreCounts(ctx context.Context, userID int64) (map[string]int, error)
- func (s *Store) HideFromContinueWatching(ctx context.Context, userID, itemID int64) error
- func (s *Store) HolidayItems(ctx context.Context, userID int64, m HolidayMatch, limit int) ([]Item, error)
- func (s *Store) HomeGuest(ctx context.Context) (User, error)
- func (s *Store) InGenre(ctx context.Context, userID int64, genre string, limit int) ([]Item, error)
- func (s *Store) InGenreExcept(ctx context.Context, userID int64, genre string, m HolidayMatch, limit int) ([]Item, error)
- func (s *Store) Issue(ctx context.Context, id string) (Issue, error)
- func (s *Store) Issues(ctx context.Context, userID int64, limit int) ([]Issue, error)
- func (s *Store) Item(ctx context.Context, userID, id int64) (Item, error)
- func (s *Store) ItemCollections(ctx context.Context, itemID int64) ([]string, error)
- func (s *Store) ItemCredits(ctx context.Context, id int64) (Credits, error)
- func (s *Store) ItemDetails(ctx context.Context, id int64) (*Details, error)
- func (s *Store) Libraries(ctx context.Context) ([]Library, error)
- func (s *Store) Library(ctx context.Context, id int64) (Library, error)
- func (s *Store) LibraryCounts(ctx context.Context) (map[int64]LibraryCount, error)
- func (s *Store) LibraryMatch(ctx context.Context, kind string, tmdbID int, title string, year int) (int64, error)
- func (s *Store) LibraryVisible(ctx context.Context, u User, libraryID int64) (bool, error)
- func (s *Store) ManualItems(ctx context.Context, userID int64, collectionID string) ([]Item, error)
- func (s *Store) MarkDetails(ctx context.Context, id int64) error
- func (s *Store) MediaInfo(ctx context.Context, id int64, version int) (info string, current, ok bool, err error)
- func (s *Store) MergeProgress(ctx context.Context, userID int64, e ProgressEvent) (bool, error)
- func (s *Store) MetadataLanguages(ctx context.Context) ([]string, error)
- func (s *Store) Narrators(ctx context.Context, userID, libraryID int64) ([]BookGroup, error)
- func (s *Store) NeedsDetails(ctx context.Context, libraryID, olderThan int64) ([]Item, error)
- func (s *Store) NeedsGenres(ctx context.Context, libraryID int64) ([]Item, error)
- func (s *Store) NeedsMetadata(ctx context.Context, libraryID int64, kinds []string) ([]Item, error)
- func (s *Store) NeedsSeasonTranslations(ctx context.Context, libraryID int64, lang string) ([]Item, error)
- func (s *Store) NeedsTranslations(ctx context.Context, libraryID, olderThan int64) ([]Item, error)
- func (s *Store) NewReleases(ctx context.Context, userID int64, sinceYear, limit int) ([]Item, error)
- func (s *Store) NextDownload(ctx context.Context) (Download, error)
- func (s *Store) NextEpisode(ctx context.Context, userID int64, ep Item) (Item, error)
- func (s *Store) NoteLanguageSeen(ctx context.Context, lang string) (bool, error)
- func (s *Store) OpenRequest(ctx context.Context, kind string, id int) (Request, error)
- func (s *Store) PendingDeviceCode(ctx context.Context, userCode string) (DeviceCode, error)
- func (s *Store) Person(ctx context.Context, id int64) (Person, error)
- func (s *Store) PersonTitles(ctx context.Context, userID, personID int64) ([]PersonTitle, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PluginKeys(ctx context.Context, pluginID string, userID int64, prefix string) (keys []PluginKey, total int64, err error)
- func (s *Store) PluginValue(ctx context.Context, pluginID string, userID int64, key string) ([]byte, error)
- func (s *Store) Profile(ctx context.Context, id int64) (Profile, error)
- func (s *Store) Profiles(ctx context.Context, accountID int64) ([]Profile, error)
- func (s *Store) PutDownload(ctx context.Context, d Download) (Download, error)
- func (s *Store) RecentlyAdded(ctx context.Context, userID int64, limit int) ([]Item, error)
- func (s *Store) RecentlyWatched(ctx context.Context, userID int64, limit int) ([]Watched, error)
- func (s *Store) RedeemDeviceCode(ctx context.Context, deviceCode string) (int64, Device, error)
- func (s *Store) Related(ctx context.Context, userID int64, it Item) ([]Item, error)
- func (s *Store) RelatedN(ctx context.Context, userID int64, it Item, limit int) ([]Item, error)
- func (s *Store) RemoveFromCollection(ctx context.Context, collectionID string, itemID int64) error
- func (s *Store) RemoveFromWatchList(ctx context.Context, userID, itemID int64) error
- func (s *Store) RemoveMissing(ctx context.Context, libraryID int64, seen func(path string) bool) (int, error)
- func (s *Store) Request(ctx context.Context, id string) (Request, error)
- func (s *Store) Requests(ctx context.Context, userID int64, limit int) ([]Request, error)
- func (s *Store) RequeueDownload(ctx context.Context, d Download) error
- func (s *Store) RequeueInterrupted(ctx context.Context) error
- func (s *Store) ResolveIssue(ctx context.Context, id, resolution string) error
- func (s *Store) Search(ctx context.Context, userID int64, q string, limit int) ([]Item, error)
- func (s *Store) Series(ctx context.Context, userID, libraryID int64) ([]BookGroup, error)
- func (s *Store) SessionDeviceName(ctx context.Context, token string) (string, error)
- func (s *Store) SessionUser(ctx context.Context, token string) (u User, homeOnly bool, err error)
- func (s *Store) Sessions(ctx context.Context, userID int64, current string) ([]Session, error)
- func (s *Store) SetAdmin(ctx context.Context, userID int64, admin bool) error
- func (s *Store) SetArt(ctx context.Context, id int64, poster, backdrop string) error
- func (s *Store) SetBookInfo(ctx context.Context, id int64, b BookInfo) error
- func (s *Store) SetBookProgress(ctx context.Context, userID, bookID, positionMs int64, played bool) error
- func (s *Store) SetDownloadProgress(ctx context.Context, file string, permille int) error
- func (s *Store) SetGenres(ctx context.Context, id int64, genres []string) error
- func (s *Store) SetMediaInfo(ctx context.Context, id int64, size, mtime int64, info string, tags []string, ...) (bool, error)
- func (s *Store) SetMetadataKinds(kinds ...string)
- func (s *Store) SetPassword(ctx context.Context, userID int64, passwordHash string) error
- func (s *Store) SetPersonInfo(ctx context.Context, id int64, in PersonInfo) error
- func (s *Store) SetPluginValue(ctx context.Context, pluginID string, userID int64, key string, value []byte) error
- func (s *Store) SetProgress(ctx context.Context, userID, itemID, positionMs int64, played bool) error
- func (s *Store) SetSeasonTranslations(ctx context.Context, seasonID int64, lang string, season Translation, ...) error
- func (s *Store) SetSessionProfile(ctx context.Context, token string, profileID int64) error
- func (s *Store) SetSetting(ctx context.Context, key, value string) error
- func (s *Store) SetSubtitleStreams(ctx context.Context, id int64, streams string) error
- func (s *Store) SetTranslations(ctx context.Context, id int64, tr map[string]Translation) error
- func (s *Store) SetUserLanguage(ctx context.Context, userID int64, lang string) error
- func (s *Store) Setting(ctx context.Context, key string) (string, error)
- func (s *Store) Similar(ctx context.Context, userID int64, show Item) (Item, error)
- func (s *Store) StartDeviceCode(ctx context.Context, dev Device, ttl time.Duration) (DeviceCode, error)
- func (s *Store) SubtitleStreams(ctx context.Context, id int64) (streams string, ok bool, err error)
- func (s *Store) SumBookLengths(ctx context.Context, libraryID int64) error
- func (s *Store) TopLevel(ctx context.Context, userID, libraryID int64) ([]Item, error)
- func (s *Store) Tracks(ctx context.Context, userID, id int64) ([]Item, error)
- func (s *Store) TranslatedTagline(ctx context.Context, id int64) (string, error)
- func (s *Store) UpdateCollection(ctx context.Context, c SavedCollection) (SavedCollection, error)
- func (s *Store) UpdateProfile(ctx context.Context, id int64, c ProfileChanges) error
- func (s *Store) UpdateRequest(ctx context.Context, id, state, errMsg string, qualityProfileID int) error
- func (s *Store) UpsertFile(ctx context.Context, it Item) (int64, error)
- func (s *Store) UserByID(ctx context.Context, id int64) (User, error)
- func (s *Store) UserByName(ctx context.Context, username string) (User, error)
- func (s *Store) UserDownload(ctx context.Context, userID int64, id string) (Download, error)
- func (s *Store) UserLanguage(ctx context.Context, userID int64) (string, error)
- func (s *Store) Users(ctx context.Context) ([]User, error)
- func (s *Store) Viewer(ctx context.Context, id int64) (User, error)
- func (s *Store) Waiting(ctx context.Context) (requests, issues int, err error)
- func (s *Store) WatchList(ctx context.Context, userID int64, limit int) ([]Item, error)
- type Term
- type Translation
- type User
- type Watched
Constants ¶
const ( CollectionSmart = "smart" CollectionManual = "manual" )
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.
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.
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.
const QualityOriginal = "original"
QualityOriginal downloads the file as it is, unconverted.
Variables ¶
var ( ErrCodeExpired = errors.New("code expired") ErrCodeDenied = errors.New("sign-in was declined") ErrCodePending = errors.New("waiting for approval") )
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.
var ErrLastAdmin = errors.New("the server needs at least one admin")
ErrLastAdmin means a change would leave the server with no admin.
var ErrNotFound = errors.New("not found")
var IssueKinds = []string{"video", "audio", "subtitles", "wrong", "other"}
Issue kinds.
var SortFields = []string{"title", "added", "released", "year", "rating", "runtime", "lastPlayed", "series"}
SortFields are the orders a filter can list titles in.
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.
var WatchedStates = []string{"unwatched", "inProgress", "watched", "notStarted", "started"}
WatchedStates are the values ItemFilter.Watched takes.
Functions ¶
func FormatUserCode ¶
FormatUserCode shows a user code as ABCD-EFGH.
func LanguageFrom ¶ added in v0.1.1
LanguageFrom returns the language WithLanguage set, or "".
func MediaKey ¶
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 NormalizeUserCode ¶
NormalizeUserCode accepts a typed code in any case, with or without the dash or spaces.
Types ¶
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 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
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 Collection ¶
Collection is a series of movies, such as a franchise's films.
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 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 DeviceCode ¶
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 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"`
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 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 and shows suit a holiday. A title matches when it has one of the TMDB keywords, or one of the words is in its title, its overview or (for a show) one of its episodes' titles. Words are matched without regard to case.
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"`
}
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"`
HasPoster bool `json:"hasPoster"`
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.
Artist string `json:"artist,omitempty"`
ArtistID *int64 `json:"artistId,omitempty"`
Album string `json:"album,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"`
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"`
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"`
// 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
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 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 Metadata ¶
type Metadata struct {
TMDBID int64
MBID string // MusicBrainz id, for artists and albums
Title string // only applied to episodes, whose file names rarely carry one
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 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 ¶
PersonTitle is a title in the library someone is in, with their parts in it.
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 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 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"`
}
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"`
// 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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
func Open ¶
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 (*Store) AddStarterCollections ¶
AddStarterCollections adds the built-in collections the first time it runs.
func (*Store) AddToCollection ¶
AddToCollection puts an item at the end of a manual collection. Adding it again keeps its place.
func (*Store) AddToWatchList ¶
AddToWatchList saves an item to a user's watch list. Adding it again keeps its place.
func (*Store) AllDownloads ¶
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 ¶
ApplyDetails replaces an item's details, credits and terms.
func (*Store) ApplyEpisodeDetails ¶
ApplyEpisodeDetails stores an episode's air date, guest stars and crew, which arrive with its season's.
func (*Store) ApplyMetadata ¶
ApplyMetadata stores a provider match (nil for no match) without overwriting local artwork or the year from the file name.
func (*Store) BackfillRatingLevels ¶
BackfillRatingLevels fills in rating levels for titles whose details were looked up before levels were kept. level turns a certification into one.
func (*Store) Book ¶ added in v0.1.2
Book returns a book with its parts and chapters, for the given person. A part's id finds its book.
func (*Store) BoxSets ¶
BoxSets lists the box sets with two or more titles in the library the user can see, by name.
func (*Store) Children ¶
Children lists seasons of a show, episodes of a season, albums of an artist, tracks of an album, books of an author or parts of a book.
func (*Store) ClearMediaKey ¶
ClearMediaKey has a file analyzed again soon.
func (*Store) Collection ¶
Collection returns one collection, whoever it belongs to.
func (*Store) CollectionItems ¶
CollectionItems lists the library's titles in a collection, oldest first.
func (*Store) Collections ¶
Collections lists the shared collections and the user's own, shared first.
func (*Store) ContinueListening ¶ added in v0.1.2
ContinueListening lists books someone started and didn't finish, the latest first, leaving out the ones they took off the row.
func (*Store) ContinueWatching ¶
ContinueWatching lists videos the user started but didn't finish, leaving out the ones they took off the row.
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) CreateIssue ¶
func (*Store) CreateLibrary ¶
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 ¶
CreateRequest saves a new request, pending.
func (*Store) CreateSession ¶
func (*Store) CreateUser ¶
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 (*Store) DeleteDownload ¶
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) DeleteOtherSessions ¶
DeleteOtherSessions signs a user out everywhere but the session keep ("" signs them out everywhere). Those devices' downloads go with them.
func (*Store) DeletePluginStorage ¶ added in v0.1.1
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 ¶
DeleteProfile removes a profile with its progress and watch list.
func (*Store) DeleteSession ¶
DeleteSession signs a device out. Its downloads go with it.
func (*Store) DeleteSessionByID ¶
DeleteSessionByID signs one of a user's devices out.
func (*Store) DeleteUser ¶
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 ¶
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 ¶
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 ¶
Downloads lists a user's downloads, for one device or (deviceID "") all of them.
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) ExpireFinishedDownloads ¶
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) FileStat ¶
FileStat returns the stored size and mtime for a file path, or ErrNotFound.
func (*Store) FileUnder ¶
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 ¶
FilterItems lists the titles the filter picks, for the given person.
func (*Store) FilterOptions ¶
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 ¶
FinishDownload records that the device has the whole file and checked it.
func (*Store) GenreCounts ¶
GenreCounts says how many movies and shows the user can see in each genre.
func (*Store) HideFromContinueWatching ¶
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 and shows the user can see that match, best rated first.
func (*Store) HomeGuest ¶
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) 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 and shows in a genre that don't match m, best rated first, to fill out a holiday's row.
func (*Store) Issues ¶
Issues lists reported problems, open ones first, then the newest. userID 0 lists everyone's.
func (*Store) Item ¶
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 ¶
ItemCollections lists the IDs of the manual collections holding an item.
func (*Store) ItemCredits ¶
ItemCredits returns an item's cast, guest stars and crew in billing order.
func (*Store) ItemDetails ¶
ItemDetails returns what ApplyDetails stored for an item, or nil.
func (*Store) LibraryCounts ¶ added in v0.1.1
LibraryCounts counts every library's titles and files.
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 ¶
LibraryVisible reports whether a user may see a library at all.
func (*Store) ManualItems ¶
ManualItems lists a manual collection's titles in the order they were added.
func (*Store) MarkDetails ¶
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) 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) MergeProgress ¶
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) MetadataLanguages ¶ added in v0.1.1
MetadataLanguages lists the languages besides English that people use: picked by a profile or asked for by a device.
func (*Store) Narrators ¶ added in v0.1.2
Narrators lists everyone who narrates a book of the library, by name.
func (*Store) NeedsDetails ¶
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 ¶
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 ¶
NeedsMetadata lists a library's items of the given kinds not yet looked up online, shows before seasons and episodes so those can use the show's match.
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
NeedsTranslations lists a library's matched movies and shows whose translations were never fetched or were fetched before olderThan (Unix seconds).
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 ¶
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 ¶
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) NoteLanguageSeen ¶ added in v0.1.1
NoteLanguageSeen records that a device asked for a language, and reports whether it was new.
func (*Store) OpenRequest ¶
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) PendingDeviceCode ¶
PendingDeviceCode looks up a code someone typed, for the "sign in this device?" screen.
func (*Store) PersonTitles ¶
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) 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) PutDownload ¶
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) RecentlyAdded ¶
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) RecentlyWatched ¶ added in v0.1.1
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) RedeemDeviceCode ¶
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 ¶
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) RemoveFromCollection ¶
func (*Store) RemoveFromWatchList ¶
func (*Store) RemoveMissing ¶
func (s *Store) RemoveMissing(ctx context.Context, libraryID int64, seen func(path string) bool) (int, error)
RemoveMissing deletes a library's files that the last scan didn't see, then any containers left empty.
func (*Store) Requests ¶
Requests lists requests, pending ones first, then the newest. userID 0 lists everyone's.
func (*Store) RequeueDownload ¶
RequeueDownload prepares a ready download again, as when its file went missing or changed.
func (*Store) RequeueInterrupted ¶
RequeueInterrupted puts downloads that were being prepared when the server stopped back in the queue.
func (*Store) ResolveIssue ¶
func (*Store) SessionDeviceName ¶ added in v0.1.1
SessionDeviceName is the name of the device a session token belongs to.
func (*Store) SessionUser ¶
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 ¶
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) SetArt ¶
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.
func (*Store) SetBookInfo ¶ added in v0.1.2
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) SetDownloadProgress ¶
SetDownloadProgress updates every download being prepared from file.
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 ¶
SetMetadataKinds says which item kinds an online provider looks up, so those items can show as pending until their lookup is done.
func (*Store) SetPassword ¶
func (*Store) SetPersonInfo ¶
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) 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) 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 ¶
SetSessionProfile switches the profile a session watches as; 0 goes back to the account itself.
func (*Store) SetSubtitleStreams ¶
SetSubtitleStreams records a file's embedded subtitle streams as JSON.
func (*Store) SetTranslations ¶ added in v0.1.1
SetTranslations replaces a movie's or show's translations, by language.
func (*Store) SetUserLanguage ¶ added in v0.1.1
SetUserLanguage keeps the language a profile picked; "" follows the device.
func (*Store) Similar ¶
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) StartDeviceCode ¶
func (s *Store) StartDeviceCode(ctx context.Context, dev Device, ttl time.Duration) (DeviceCode, error)
StartDeviceCode makes a code for a device to show.
func (*Store) SubtitleStreams ¶
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) SumBookLengths ¶ added in v0.1.2
SumBookLengths gives each book of a library the length of all its parts.
func (*Store) Tracks ¶ added in v0.1.1
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
TranslatedTagline returns an item's tagline in the context's language, or "" when it has none.
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) UpdateProfile ¶
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 ¶
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 ¶
UserByID returns an account people sign in to: not the guest account, and not a profile.
func (*Store) UserByName ¶
func (*Store) UserDownload ¶
UserDownload finds one of a user's downloads.
func (*Store) UserLanguage ¶ added in v0.1.1
UserLanguage returns the language a profile picked, or "" to follow the device.
func (*Store) Users ¶
Users lists the accounts people sign in with, leaving out the home network's guest account and profiles.
func (*Store) Viewer ¶
Viewer returns anyone who can watch: an account, the guest account or a profile.
type Term ¶
Term is something titles have in common, for finding related titles: a genre, keyword, collection or recommendation.
type Translation ¶ added in v0.1.1
Translation is an item's text in one language. Empty fields have no translation.
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"`
// contains filtered or unexported fields
}
func (User) PasswordHash ¶
Source Files
¶
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. |