Documentation
¶
Overview ¶
Package plexguid maps verified external identities through Plex's metadata provider. It never invents plex:// IDs or grants Plex account entitlements.
Index ¶
- Variables
- func ClientIdentifier(plexClientID, machineID string) string
- type Options
- type Service
- func (s *Service) Cached(ctx context.Context, k core.RatingKey) string
- func (s *Service) CachedMany(ctx context.Context, keys []core.RatingKey) map[core.RatingKey]string
- func (s *Service) ClientIdentifier() string
- func (s *Service) Close()
- func (s *Service) ExactKey(ctx context.Context, guid string) (core.RatingKey, error)
- func (s *Service) Lookup(ctx context.Context, guid string) (core.RatingKey, error)
- func (s *Service) Resolve(ctx context.Context, k core.RatingKey) (string, error)
- func (s *Service) ResolveBounded(ctx context.Context, k core.RatingKey, wait time.Duration) string
- func (s *Service) Schedule(keys ...core.RatingKey)
- func (s *Service) VerifiedRange(ctx context.Context, after, below core.RatingKey, limit int) ([]Verified, error)
- func (s *Service) Wait()
- type Verified
Constants ¶
This section is empty.
Variables ¶
var ErrAmbiguous = errors.New("plexguid: ambiguous identity")
ErrAmbiguous is returned when one Plex GUID is stored for more than one local title, or the stored title's kind does not match the GUID kind.
Functions ¶
func ClientIdentifier ¶ added in v0.3.0
ClientIdentifier is the X-Plex-Client-Identifier sent to Plex's metadata and discover providers: the install's Plex client id (minted on first run), else the server's machine identifier, else a fresh random id, so installs never share one fixed identifier.
Types ¶
type Options ¶
type Options struct {
HTTP *http.Client
// ClientIdentifier is the per-install X-Plex-Client-Identifier.
ClientIdentifier func() string
BaseURL string
Token func() string
Background bool
// Namesakes reports whether the catalogue holds another title of the same
// type that shares this key's normalized name and a near year. A legacy
// mapping (stored before identity records existed) on a title with a
// namesake cannot be trusted: the guid may name the other work. It is an
// optional dependency, injected by the app so this package never imports
// the catalogue. Nil disables the check.
Namesakes func(context.Context, core.RatingKey) (bool, error)
// EnsureTitle warms the local catalogue row for a rating key discovered
// via reverse GUID lookup so identity verification has the local title and
// release year even when the title has never been opened before.
EnsureTitle func(context.Context, core.RatingKey) error
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Cached ¶
Cached returns only current proofs and queues older ones without network I/O.
func (*Service) CachedMany ¶
CachedMany batch-loads cached non-empty plex:// GUIDs for keys without network activity.
func (*Service) ClientIdentifier ¶ added in v0.3.0
ClientIdentifier returns the per-install X-Plex-Client-Identifier used by s.
func (*Service) ExactKey ¶ added in v0.2.57
ExactKey returns the single local title already stored for guid. It does not call Plex and it does not derive an episode from a show's TMDB id. A miss is core.ErrNotFound.
func (*Service) Lookup ¶ added in v0.2.45
Lookup reverses a verified Plex movie/show identity. It returns an identity, not a visibility decision: callers must load and authorize the title. A cold lookup accepts only an exact provider GUID with one TMDB identity.
func (*Service) ResolveBounded ¶
ResolveBounded returns a cached verified plex:// GUID immediately, or waits at most wait for one deduplicated detached resolution to finish. If wait expires first, the lookup continues in the background within the service lifecycle so subsequent opens hit the durable cache without blocking this response beyond wait.
func (*Service) Schedule ¶
Schedule queues keys for asynchronous plex:// GUID resolution when Background is enabled. Safe to call on hot render paths.
func (*Service) VerifiedRange ¶
func (s *Service) VerifiedRange(ctx context.Context, after, below core.RatingKey, limit int) ([]Verified, error)
VerifiedRange pages through stored, verified identities with after < key < below, in key order, at most limit at a time. It reads only the local tables (primary-key range scan) and never calls Plex. Season and episode identities are included only once their parentage is recorded, as Resolve requires.