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

plexmeta

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package plexmeta caches Plex metadata-provider details for Plex apps. TMDB stays the catalogue and the fallback. Viewer policy uses the safer (more mature) of the TMDB and Plex content ratings when this overlay is on; Plex apps still display Plex's own rating. Date-added stays the catalogue release/air date — Plex dates never change addedAt.

Index

Constants

View Source
const RemoteArt = "plex"

RemoteArt is the sentinel ApplyDisplay writes when Plex supplies artwork and TMDB has none, so convert can emit a thumb URL and images can fall back.

Variables

This section is empty.

Functions

func ApplyDisplay

func ApplyDisplay(t *core.Title, o Overlay)

ApplyDisplay copies present Plex fields onto t for the Plex convert path. Released and AddedAt stay on the caller — Plex dates must not change date-added. TMDB genres and person ids stay; Plex only enriches matching names so person pages and genre filters keep working.

func ImageHost

func ImageHost(host string) bool

ImageHost reports whether host is a Plex artwork CDN Ether may proxy.

func SaferRating

func SaferRating(tmdb, plex string) string

SaferRating is the more mature of two stored ratings. An unrated side is ignored so a missing Plex label does not hide a rated TMDB title; if both are unrated the TMDB value is kept.

Types

type Cached

type Cached struct {
	Overlay
	FetchedAt time.Time
	GUID      string
}

Cached is a stored overlay plus when it was fetched.

func (Cached) Stale

func (c Cached) Stale(now time.Time) bool

Stale reports that the row should be refreshed in the background.

type Options

type Options struct {
	HTTP *http.Client
	// ClientIdentifier is the per-install id shared with plexguid.
	ClientIdentifier func() string
	BaseURL          string
	Token            func() string
	// GUID returns a verified plex:// mapping; empty means skip the key.
	GUID func(context.Context, core.RatingKey) string
	// Enabled is the owner toggle and claimed check. Nil means off.
	Enabled    func() bool
	Background bool
	Now        func() time.Time
}

Options configure the background metadata cache.

type Overlay

type Overlay struct {
	ContentRating       string    `json:"contentRating,omitempty"`
	Year                int       `json:"year,omitempty"`
	AvailableAt         time.Time `json:"availableAt,omitempty"`
	Summary             string    `json:"summary,omitempty"`
	Tagline             string    `json:"tagline,omitempty"`
	Studio              string    `json:"studio,omitempty"`
	ThumbURL            string    `json:"thumbUrl,omitempty"`
	ArtURL              string    `json:"artUrl,omitempty"`
	Rating              float64   `json:"rating,omitempty"`
	AudienceRating      float64   `json:"audienceRating,omitempty"`
	RatingImage         string    `json:"ratingImage,omitempty"`
	AudienceRatingImage string    `json:"audienceRatingImage,omitempty"`
	Genres              []string  `json:"genres,omitempty"`
	Cast                []Person  `json:"cast,omitempty"`
	Directors           []Person  `json:"directors,omitempty"`
	Writers             []Person  `json:"writers,omitempty"`
}

Overlay is one title's cached Plex metadata. Empty fields mean "keep TMDB".

func (Overlay) Empty

func (o Overlay) Empty() bool

Empty reports a cache hit that carries no display fields (a recorded miss).

type Person

type Person struct {
	Name  string `json:"name,omitempty"`
	Role  string `json:"role,omitempty"`
	Thumb string `json:"thumb,omitempty"`
}

Person is a Plex Role/Director/Writer tag.

type RatingSQL

type RatingSQL struct{}

RatingSQL is the catalogue SQL helper for Plex viewer limits. Catalog calls HideExceeding instead of naming plexmeta_titles itself.

func (RatingSQL) HideExceeding

func (RatingSQL) HideExceeding(keyColumn string) string

HideExceeding is true unless a cached overlay for keyColumn exceeds the bound level AND that overlay's guid still matches the verified plex:// mapping. A remapped title is ignored so a stale adult rating cannot hide it.

type Service

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

Service caches Plex metadata-provider payloads. Reads never wait on Plex.

func New

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

func (*Service) Cached

func (s *Service) Cached(ctx context.Context, k core.RatingKey) (Cached, bool)

Cached is a primary-key lookup. It never talks to Plex.

func (*Service) CachedMany

func (s *Service) CachedMany(ctx context.Context, keys []core.RatingKey) map[core.RatingKey]Cached

CachedMany batch-loads overlays by rating key only.

func (*Service) Close

func (s *Service) Close()

func (*Service) Schedule

func (s *Service) Schedule(keys ...core.RatingKey)

Schedule queues keys that have a verified plex:// guid. Safe on request paths.

func (*Service) Wait

func (s *Service) Wait()

Wait blocks until queued background fetches finish.

Jump to

Keyboard shortcuts

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