Documentation
¶
Overview ¶
Package watchlist ingests authorized viewers' watchlists and lazily checks their release availability. It never adds content or writes to Plex/Trakt.
Index ¶
- func ExportKeys(ctx context.Context, db *sql.DB, userID int64) ([]core.RatingKey, error)
- func ImportTitleTx(ctx context.Context, tx *sql.Tx, userID int64, title core.Title, added int64) error
- type Item
- type Notifier
- type OnceNotifier
- type Options
- type Service
- func (s *Service) Check(ctx context.Context, u *core.User) error
- func (s *Service) Hubs(ctx context.Context, u *core.User, limit int) ([]core.Hub, error)
- func (s *Service) Items(ctx context.Context, u *core.User) ([]Item, error)
- func (s *Service) Remind(ctx context.Context, u *core.User, key core.RatingKey) error
- func (s *Service) Remove(ctx context.Context, userID int64, key core.RatingKey) error
- func (s *Service) Router() http.Handler
- func (s *Service) Run(ctx context.Context)
- func (s *Service) SaveSettings(ctx context.Context, v Settings) error
- func (s *Service) Settings(ctx context.Context) (Settings, error)
- func (s *Service) Sync(ctx context.Context, u *core.User) error
- type Settings
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportKeys ¶ added in v0.2.4
ExportKeys reads the live watchlist, including manual and synced sources. Multiple sources for one title produce one exported entry.
Types ¶
type OnceNotifier ¶ added in v0.2.48
OnceNotifier queues an alert at most once per key, however often it is called (notify.Service implements it). With it, an episode alert is queued exactly once even when a crash or error interrupts marking it sent. A plain Notifier is still supported but then at least once: such a retry repeats the alert, at most alertAttempts more times.
type Options ¶
type Options struct {
Logger *slog.Logger
Catalog core.Catalog
Resolver core.Resolver
Engine core.Engine
Trakt Source
Tokens func(context.Context, int64) (string, error)
Users func(context.Context) ([]core.User, error)
Allowed func(*core.User, *core.Title) bool
Notifier Notifier
Client *http.Client
PlexBaseURL string
Now func() time.Time
PrewarmBytes int64
// SyncInterval is how often Run passes over every viewer (30m).
SyncInterval time.Duration
// ResumeSchedule makes Run wait until SyncInterval has passed since the
// last pass recorded in the database (by any node) before its first
// pass, instead of passing at once. A cluster sets it because Run
// restarts on every leader handoff.
ResumeSchedule bool
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Check ¶
Check resolves only explicitly watched-for, released titles, never the whole catalogue. A healthy resolver result is required before marking available.
A show (or season) becomes available through its first released episode. After that, each newer regular episode is resolved once it airs and, when a healthy release exists, announced and prewarmed once (see newEpisode).
func (*Service) Run ¶
Run is cancelled by the app; individual viewers are isolated and bounded. Run passes over every viewer (watchlist sync and availability check) at once and then every SyncInterval; with ResumeSchedule the first pass waits out the interval since the last recorded pass.