ratings

package
v0.2.22 Latest Latest
Warning

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

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

Documentation

Overview

Package ratings caches licensed, owner-keyed rating data. Values preserve their source scale; Plex's main rating fields alone use the 0–10 scale.

Index

Constants

View Source
const Redacted = "[configured]"

Variables

This section is empty.

Functions

This section is empty.

Types

type Badge

type Badge struct {
	Source string  `json:"source"`
	Value  float64 `json:"value"`
	Scale  float64 `json:"scale"`
	Votes  int64   `json:"votes,omitempty"`
}

func (Badge) PlexImage

func (b Badge) PlexImage() string

PlexImage returns only icons understood by official Plex clients. Other providers remain explicitly named poster badges; they never impersonate IMDb.

func (Badge) PlexValue

func (b Badge) PlexValue() float64

type Options

type Options struct {
	Client         *http.Client
	OMDbBaseURL    string
	MDBListBaseURL string
	Now            func() time.Time
	// Sealer protects the stored API key, bound to its provider; nil
	// stores it as given.
	Sealer config.FieldSealer
}

type Service

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

func New

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

func (*Service) Cached

func (s *Service) Cached(ctx context.Context, t *core.Title) ([]Badge, error)

Cached never performs network I/O; safe for metadata and hub rendering.

func (*Service) MigrateSecrets added in v0.2.4

func (s *Service) MigrateSecrets(ctx context.Context) (int, error)

MigrateSecrets seals an API key stored in plaintext; it returns 1 when it rewrote the settings. The row is replaced only if unchanged since read, and a key that does not open is left untouched.

func (*Service) Prune

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

Prune deletes rating rows older than the maximum cache interval. It is meant to be called periodically.

func (*Service) Queue

func (s *Service) Queue(t core.Title)

Queue is bounded, deduplicated and nonblocking; Run owns the network worker.

func (*Service) Refresh

func (s *Service) Refresh(ctx context.Context, t *core.Title) ([]Badge, error)

func (*Service) Router

func (s *Service) Router(cat core.Catalog) http.Handler

Router is owner-only; a catalog is supplied for explicit cache warming.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

func (*Service) SaveSettings

func (s *Service) SaveSettings(ctx context.Context, v Settings) error

func (*Service) Settings

func (s *Service) Settings(ctx context.Context) (Settings, error)

func (*Service) WithSettingsSnapshot added in v0.2.6

func (s *Service) WithSettingsSnapshot(ctx context.Context) context.Context

WithSettingsSnapshot reads settings once for a bounded render. It avoids a database round trip per tile without keeping settings stale across requests.

type Settings

type Settings struct {
	Enabled    bool   `json:"enabled"`
	Provider   string `json:"provider"`
	APIKey     string `json:"apiKey"`
	Critic     string `json:"critic"`
	Audience   string `json:"audience"`
	CacheHours int    `json:"cacheHours"`
}

Jump to

Keyboard shortcuts

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