provider

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 7 Imported by: 0

README

go-plex-metadata-provider

A Go library for building custom Plex metadata providers. Currently only movie libraries are supported.

Installation

go get codeberg.org/jyggen/go-plex-metadata-provider

Usage

Basic Provider
p := provider.New("myprovider", "My Provider")
h := provider.NewHandler(p)
http.Handle("/", h)
With Match and Metadata Features
p := provider.New("myprovider", "My Provider",
    provider.WithMatchFeatureEnabled(func(ctx context.Context, req provider.MatchRequest, h provider.RequestHeader) ([]provider.Metadata, error) {
        return []provider.Metadata{{
            RatingKey: "123",
            Type:      "movie",
        }}, nil
    }),
    provider.WithMetadataFeatureEnabled(func(ctx context.Context, id string, h provider.RequestHeader) (*provider.Metadata, error) {
        return &provider.Metadata{
            RatingKey: id,
            Type:      "movie",
        }, nil
    }),
)

h := provider.NewHandler(p)
http.Handle("/", h)

Documentation

Index

Constants

View Source
const (
	TypeMovie = iota + 1
	TypeShow
	TypeSeason
	TypeEpisode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Feature

type Feature struct {
	Type string `json:"type"`
	Key  string `json:"key"`
}

type Handler

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

func NewHandler

func NewHandler(p *Provider) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Image

type Image struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type MatchFunc

type MatchFunc func(context.Context, MatchRequest, RequestHeader) ([]Metadata, error)

type MatchRequest

type MatchRequest struct {
	Type             int    `json:"type"`
	Title            string `json:"title"`
	ParentTitle      string `json:"parentTitle"`
	GrandParentTitle string `json:"grandparentTitle"`
	IncludeChildren  bool   `json:"includeChildren"`
	EpisodeOrder     string `json:"episodeOrder"`
	Year             int    `json:"year"`
	GUID             string `json:"guid"`
	Index            int    `json:"index"`
	ParentIndex      int    `json:"parentIndex"`
	Filename         string `json:"filename"`
	Date             string `json:"date"`
	Manual           bool   `json:"manual"`
	IncludeAdult     bool   `json:"includeAdult"`
}

type MediaContainer

type MediaContainer struct {
	Offset     int        `json:"offset"`
	TotalSize  int        `json:"totalSize"`
	Identifier string     `json:"identifier"`
	Size       int        `json:"size"`
	Metadata   []Metadata `json:"Metadata"`
}

type MediaProvider

type MediaProvider struct {
	Identifier string    `json:"identifier"`
	Title      string    `json:"title"`
	Version    string    `json:"version"`
	Types      []Types   `json:"Types"`
	Feature    []Feature `json:"Feature"`
}

type MediaProviderResponse

type MediaProviderResponse struct {
	MediaProvider MediaProvider `json:"MediaProvider"`
}

type Metadata

type Metadata struct {
	Art       string  `json:"art"`
	GUID      string  `json:"guid"`
	Image     []Image `json:"Image,omitempty"`
	Key       string  `json:"key"`
	RatingKey string  `json:"ratingKey"`
	Thumb     string  `json:"thumb,omitempty"`
	Type      string  `json:"type"`
}

type MetadataFunc

type MetadataFunc func(context.Context, string, RequestHeader) (*Metadata, error)

type MetadataResponse

type MetadataResponse struct {
	MediaContainer MediaContainer `json:"MediaContainer"`
}

type Option

type Option func(p *Provider)

func WithLogger

func WithLogger(l *slog.Logger) Option

func WithMatchFeatureEnabled

func WithMatchFeatureEnabled(f MatchFunc) Option

func WithMaxBodySize

func WithMaxBodySize(n uint64) Option

func WithMetadataFeatureEnabled

func WithMetadataFeatureEnabled(f MetadataFunc) Option

func WithVersion

func WithVersion(v string) Option

type Provider

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

func New

func New(identifier, title string, options ...Option) *Provider

func (*Provider) MediaProvider

func (p *Provider) MediaProvider() MediaProvider

type RequestHeader

type RequestHeader struct {
	ContainerSize  string
	ContainerStart string
	Country        string
	Language       string
}

type Scheme

type Scheme struct {
	Scheme string `json:"scheme"`
}

type Types

type Types struct {
	Type   int      `json:"type"`
	Scheme []Scheme `json:"Scheme"`
}

Jump to

Keyboard shortcuts

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