Help us shape the future of Go! Take the 2026 Go Developer Survey

trackprefs

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package trackprefs persists viewer stream policy and show-specific choices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Language string `json:"language"`
	Forced   bool   `json:"forced"`
	SDH      bool   `json:"sdh"`
	Off      bool   `json:"off"`
}

type Options

type Options struct {
	ShowName func(context.Context, int64) string
}

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
	Loudness          bool     `json:"loudness"`
	NightMode         bool     `json:"nightMode"`
	DialogueBoost     bool     `json:"dialogueBoost"`
}

User zero is the owner-configured fallback policy; positive IDs are overrides.

func Default

func Default() Rules

func (Rules) AudioFilters

func (r Rules) AudioFilters(channels int) []string

AudioFilters returns only known ffmpeg filters; arbitrary client strings never enter the command.

func (Rules) Validate

func (r Rules) Validate() error

type SavedChoice

type SavedChoice struct {
	ShowID    int64  `json:"showId"`
	ShowTitle string `json:"showTitle,omitempty"`
	Kind      string `json:"kind"`
	Choice    Choice `json:"choice"`
	UpdatedAt int64  `json:"updatedAt"`
}

type Selection

type Selection struct {
	Audio    int
	Subtitle int
}

type Service

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

func New

func New(db *sql.DB, opts ...Options) *Service

func (*Service) DeleteRules

func (s *Service) DeleteRules(ctx context.Context, user int64) error

func (*Service) Forget

func (s *Service) Forget(ctx context.Context, user, show int64) error

func (*Service) GetRules

func (s *Service) GetRules(ctx context.Context, user int64) (Rules, error)

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves /{userID} and /{userID}/shows/{showID} (DELETE). Mount behind the admin owner's authentication and CSRF middleware.

func (*Service) Memory

func (s *Service) Memory(ctx context.Context, user int64) ([]SavedChoice, error)

func (*Service) PutRules

func (s *Service) PutRules(ctx context.Context, user int64, r Rules) error

func (*Service) Remember

func (s *Service) Remember(ctx context.Context, user int64, key core.RatingKey, kind string, track *core.StreamInfo) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL