Documentation
¶
Overview ¶
Package trackprefs persists viewer stream policy and show-specific choices.
Index ¶
- func AudioOrder(audio []string, server, original string, preferOriginal bool) []string
- func LimitBitrate(existing, preference int) int
- type Choice
- type Options
- type PlexLayer
- type Rules
- type SavedChoice
- type Scope
- type ScopedRules
- type Selection
- type Service
- func (s *Service) DeleteRules(ctx context.Context, user int64) error
- func (s *Service) DeleteScopedField(ctx context.Context, user int64, scope, id, field string) error
- func (s *Service) Forget(ctx context.Context, user, show int64) error
- func (s *Service) GetRules(ctx context.Context, user int64) (Rules, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) HasViewerRules(ctx context.Context, user int64) (bool, error)
- func (s *Service) Memory(ctx context.Context, user int64) ([]SavedChoice, error)
- func (s *Service) PutRules(ctx context.Context, user int64, r Rules) error
- func (s *Service) PutScoped(ctx context.Context, user int64, scope, id string, value ScopedRules) error
- func (s *Service) Remember(ctx context.Context, user int64, key core.RatingKey, kind string, ...) error
- func (s *Service) ScopedRules(ctx context.Context, user int64, scope Scope) (Rules, bool, error)
- func (s *Service) ScopedRulesWithSources(ctx context.Context, user int64, scope Scope) (Rules, map[string]string, error)
- func (s *Service) Select(ctx context.Context, user int64, key core.RatingKey, info core.MediaInfo, ...) (Selection, error)
- func (s *Service) SelectScoped(ctx context.Context, user int64, key core.RatingKey, info core.MediaInfo, ...) (Selection, bool, error)
- func (s *Service) SetAppearance(ctx context.Context, user int64, raw json.RawMessage) error
- func (s *Service) SetAudioPreferences(ctx context.Context, user int64, languages []string) error
- func (s *Service) SetBitratePreference(ctx context.Context, user int64, kbps int) error
- func (s *Service) SetHeightPreference(ctx context.Context, user int64, height int, quality string) error
- func (s *Service) SetSubtitleLanguage(ctx context.Context, user int64, languages []string) error
- func (s *Service) SetSubtitleMode(ctx context.Context, user int64, mode string) error
- func (s *Service) SetSubtitlePreferences(ctx context.Context, user int64, languages []string, mode string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AudioOrder ¶ added in v0.3.0
AudioOrder is the audio preference for one playback. audio is the viewer's list, or user 0's list when the viewer saved none. PreferOriginal ranks the title original first. Otherwise the order is that list, the catalog language, then the title original. pick uses the file default flag only when none of these match.
func LimitBitrate ¶ added in v0.3.0
Types ¶
type Options ¶
type Options struct {
ShowName func(context.Context, int64) string
// SyncLanguages mirrors a viewer's ordered audio and subtitle lists onto
// auth_users.audio_languages and auth_users.subtitle_languages, for code
// that reads them from the user record. It runs after every write of the
// viewer's rules, with empty lists when the rules are deleted. User 0 is
// the shared default and is not an account row.
SyncLanguages func(ctx context.Context, user int64, audio, subtitles []string) error
// ServerLanguage is the catalog metadata language (config catalog.language,
// for example en-US). It is not the console locale.
ServerLanguage func() string
// PlexLayer is the viewer's cached plex.tv account settings. It sits
// under the viewer's own row and user 0. A missing callback skips it.
PlexLayer func(context.Context, int64) (PlexLayer, bool)
}
type PlexLayer ¶ added in v0.3.0
type PlexLayer struct {
AudioLanguage string
AutoSelectAudio bool
SubtitleLanguage string
SubtitleMode string // Ether names: off, foreign-only, always
}
PlexLayer is the default language layer from a plex.tv account.
type Rules ¶
type Rules struct {
AudioLanguages []string `json:"audioLanguages"`
SubtitleLanguages []string `json:"subtitleLanguages"`
PreferOriginal bool `json:"preferOriginal"`
SubtitleMode string `json:"subtitleMode"` // off, forced-only, foreign-only, always
SubtitleStyle string `json:"subtitleStyle"` // normal, sdh, forced
SubtitleAppearance json.RawMessage `json:"subtitleAppearance,omitempty"`
Loudness bool `json:"loudness"`
NightMode bool `json:"nightMode"`
DialogueBoost bool `json:"dialogueBoost"`
MaxBitrateKbps int `json:"maxBitrateKbps,omitempty"` // 0 means no viewer preference
MaxHeight int `json:"maxHeight,omitempty"`
PreferredQuality string `json:"preferredQuality,omitempty"`
}
User zero is the owner-configured fallback policy; positive IDs are overrides.
func (Rules) AudioFilters ¶
AudioFilters returns only known ffmpeg filters; arbitrary client strings never enter the command.
type SavedChoice ¶
type Scope ¶ added in v0.3.0
type Scope struct{ Device, Series, Library string }
Scope identifies the authenticated device and the title's series and library.
type ScopedRules ¶ added in v0.3.0
type ScopedRules struct {
AudioLanguages *[]string `json:"audioLanguages,omitempty"`
SubtitleLanguages *[]string `json:"subtitleLanguages,omitempty"`
SubtitleMode *string `json:"subtitleMode,omitempty"`
SubtitleAppearance *json.RawMessage `json:"subtitleAppearance,omitempty"`
MaxBitrateKbps *int `json:"maxBitrateKbps,omitempty"`
MaxHeight *int `json:"maxHeight,omitempty"`
PreferredQuality *string `json:"preferredQuality,omitempty"`
}
ScopedRules only changes fields explicitly supplied; nil means inherit.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) DeleteScopedField ¶ added in v0.3.0
DeleteScopedField clears one override without disturbing concurrent writes to the other fields in the same scope.
func (*Service) Handler ¶
Handler serves /{userID} and /{userID}/shows/{showID} (DELETE). Mount behind the admin owner's authentication and CSRF middleware.
func (*Service) HasViewerRules ¶ added in v0.3.0
HasViewerRules reports whether this viewer stored their own rules. GetRules also falls back to user 0, the shared default, which is not a change this viewer made.
func (*Service) ScopedRules ¶ added in v0.3.0
ScopedRules returns the effective rules and whether any override applied. Each field inherits independently, with device taking highest precedence.
func (*Service) ScopedRulesWithSources ¶ added in v0.3.0
func (s *Service) ScopedRulesWithSources(ctx context.Context, user int64, scope Scope) (Rules, map[string]string, error)
ScopedRulesWithSources also identifies the winning scoped override for each field.
func (*Service) Select ¶
func (s *Service) Select(ctx context.Context, user int64, key core.RatingKey, info core.MediaInfo, original string) (Selection, error)
Select returns positions in MediaInfo.Streams, never ffprobe indices.
func (*Service) SelectScoped ¶ added in v0.3.0
func (s *Service) SelectScoped(ctx context.Context, user int64, key core.RatingKey, info core.MediaInfo, original string, scope Scope) (Selection, bool, error)
SelectScoped falls back to Select unchanged when no scoped preference applies.
func (*Service) SetAppearance ¶ added in v0.3.0
func (*Service) SetAudioPreferences ¶ added in v0.3.0
func (*Service) SetBitratePreference ¶ added in v0.3.0
func (*Service) SetHeightPreference ¶ added in v0.3.0
func (*Service) SetSubtitleLanguage ¶ added in v0.3.0
func (*Service) SetSubtitleMode ¶ added in v0.3.0
func (*Service) SetSubtitlePreferences ¶ added in v0.3.0
func (s *Service) SetSubtitlePreferences(ctx context.Context, user int64, languages []string, mode string) error
SetSubtitlePreferences updates only subtitle fields, preserving concurrent audio and other rule changes. The compare-and-swap is shared across nodes.