plex

package module
v0.0.0-...-e51d4fc Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 13 Imported by: 0

README

go-plex

Golang Plex API Wrapper

Documentation

Index

Constants

View Source
const (
	APIBaseURL   = "https://plex.tv/api"
	APIBaseURLv2 = APIBaseURL + "/v2"
)

Variables

View Source
var DefaultAppOptions = [...]Option{
	Logger(log.Default()),
	Product("go-plex"),
	Client(http.Client{Timeout: 10 * time.Second}),
}

Functions

This section is empty.

Types

type App

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

func New

func New(clientIdentifier string, opts ...Option) *App

func (*App) AttachServer

func (a *App) AttachServer(server *Server)

func (*App) AttachUser

func (a *App) AttachUser(user *User)

func (*App) GeneratePin

func (a *App) GeneratePin() (*PinData, error)

func (*App) User

func (a *App) User(authToken string) (*User, error)

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Status  int    `json:"status"`
}

func (Error) Error

func (e Error) Error() string

type Library

type Library struct {
	AllowSync        bool              `json:"-" `
	Art              string            `json:"-" `
	Composite        string            `json:"-" `
	Filters          bool              `json:"-" `
	Refreshing       bool              `json:"-" `
	Thumb            string            `json:"-" `
	Key              int               `json:"key,string" `
	Type             string            `json:"type" `
	Title            string            `json:"title" `
	Agent            string            `json:"agent" `
	Scanner          string            `json:"scanner" `
	Language         string            `json:"-" `
	UUID             string            `json:"uuid" `
	UpdatedAt        int               `json:"-" `
	CreatedAt        int               `json:"-" `
	ScannedAt        int               `json:"-" `
	Content          bool              `json:"-" `
	Directory        bool              `json:"-" `
	ContentChangedAt int               `json:"-" `
	Hidden           int               `json:"-" `
	Location         []LibraryLocation `json:"-" `
	// contains filtered or unexported fields
}

func (*Library) Series

func (l *Library) Series(filter bool) ([]Series, error)

type LibraryLocation

type LibraryLocation struct {
	ID   int    `json:"id"`
	Path string `json:"path"`
}

type Location

type Location struct {
	Code         string `json:"code"`
	Country      string `json:"country"`
	City         string `json:"city"`
	TimeZone     string `json:"time_zone"`
	PostalCode   string `json:"postal_code"`
	Subdivisions string `json:"subdivisions"`
	Coordinates  string `json:"coordinates"`
}

type Metadata

type Metadata struct {
	Tag string `json:"tag"`
}

type Option

type Option = func(*Options)

func Client

func Client(client http.Client) Option

func Logger

func Logger(logger *log.Logger) Option

func Product

func Product(product string) Option

type Options

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

type PinData

type PinData struct {
	Errors           []Error   `json:"errors"`
	ID               int       `json:"id"`
	Code             string    `json:"code"`
	Product          string    `json:"product"`
	Trusted          bool      `json:"trusted"`
	ClientIdentifier string    `json:"clientIdentifier"`
	Location         Location  `json:"location"`
	ExpiresIn        int       `json:"expiresIn"`
	CreatedAt        time.Time `json:"createdAt"`
	ExpiresAt        time.Time `json:"expiresAt"`
	AuthToken        string    `json:"authToken"`
	NewRegistration  bool      `json:"newRegistration"`
	// contains filtered or unexported fields
}

Pin Endpoint

func (*PinData) AuthUrl

func (p *PinData) AuthUrl() (authAppURL string)

func (*PinData) Poll

func (p *PinData) Poll() (bool, error)

type Profile

type Profile struct {
	AutoSelectAudio              bool   `json:"autoSelectAudio"`
	DefaultAudioLanguage         string `json:"defaultAudioLanguage"`
	DefaultSubtitleLanguage      string `json:"defaultSubtitleLanguage"`
	AutoSelectSubtitle           int    `json:"autoSelectSubtitle"`
	DefaultSubtitleAccessibility int    `json:"defaultSubtitleAccessibility"`
	DefaultSubtitleForced        int    `json:"defaultSubtitleForced"`
}

type Series

type Series struct {
	RatingKey             int        `json:"ratingKey,string" `
	Key                   string     `json:"key" `
	SkipChildren          bool       `json:"skipChildren,omitempty" `
	GUID                  string     `json:"guid" `
	Studio                string     `json:"studio" `
	Type                  string     `json:"type" `
	Title                 string     `json:"title" `
	ContentRating         string     `json:"contentRating,omitempty" `
	Summary               string     `json:"summary" `
	Index                 int        `json:"index" `
	Rating                float64    `json:"rating,omitempty" `
	ViewCount             int        `json:"viewCount,omitempty" `
	LastViewedAt          int        `json:"lastViewedAt,omitempty" `
	Year                  int        `json:"year" `
	Thumb                 string     `json:"thumb" `
	Art                   string     `json:"art" `
	Banner                string     `json:"banner" `
	Theme                 string     `json:"theme,omitempty" `
	Duration              int        `json:"duration" `
	OriginallyAvailableAt string     `json:"originallyAvailableAt" `
	LeafCount             int        `json:"leafCount" `
	ViewedLeafCount       int        `json:"viewedLeafCount" `
	ChildCount            int        `json:"childCount" `
	AddedAt               int        `json:"addedAt" `
	UpdatedAt             int        `json:"updatedAt" `
	Genre                 []Metadata `json:"Genre" `
	Role                  []Metadata `json:"Role,omitempty" `
	TitleSort             string     `json:"titleSort,omitempty" `
	Collection            []Metadata `json:"Collection,omitempty" `
	// contains filtered or unexported fields
}

func (*Series) Scrobble

func (s *Series) Scrobble() error

type Server

type Server struct {
	XMLName           xml.Name      `xml:"Server" json:"-"`
	AccessToken       string        `xml:"accessToken,attr"`
	Address           string        `xml:"address,attr"`
	CreatedAt         UnixTimestamp `xml:"createdAt,attr" json:"-"`
	Host              string        `xml:"host,attr"`
	LocalAddresses    string        `xml:"localAddresses,attr"`
	MachineIdentifier string        `xml:"machineIdentifier,attr"`
	Name              string        `xml:"name,attr"`
	Owned             bool          `xml:"owned,attr"`
	Port              int           `xml:"port,attr"`
	Scheme            string        `xml:"scheme,attr"`
	Synced            bool          `xml:"synced,attr"`
	UpdatedAt         UnixTimestamp `xml:"updatedAt,attr" json:"-"`
	Version           string        `xml:"version,attr"`
	OwnerId           int           `xml:"ownerId,attr"`
	// contains filtered or unexported fields
}

func (*Server) Libraries

func (s *Server) Libraries() ([]Library, error)

func (*Server) Scrobble

func (s *Server) Scrobble(ratingKey int) error

func (*Server) URL

func (s *Server) URL() string

type Services

type Services struct {
	Identifier string `json:"identifier"`
	Endpoint   string `json:"endpoint"`
	Token      string `json:"token,omitempty"`
	Status     string `json:"status"`
	Secret     string `json:"secret,omitempty"`
}

type Subscription

type Subscription struct {
	Active         bool      `json:"active"`
	SubscribedAt   time.Time `json:"subscribedAt"`
	Status         string    `json:"status"`
	PaymentService string    `json:"paymentService"`
	Plan           string    `json:"plan"`
	Features       []string  `json:"features"`
}

type User

type User struct {
	ID                      int          `json:"id" `
	UUID                    string       `json:"uuid" `
	Username                string       `json:"username" `
	Title                   string       `json:"title" `
	Email                   string       `json:"email" `
	Locale                  string       `json:"locale" `
	Confirmed               bool         `json:"confirmed" `
	EmailOnlyAuth           bool         `json:"emailOnlyAuth" `
	HasPassword             bool         `json:"hasPassword" `
	Protected               bool         `json:"protected" `
	Thumb                   string       `json:"thumb" `
	AuthToken               string       `json:"authToken"`
	MailingListStatus       string       `json:"mailingListStatus" `
	MailingListActive       bool         `json:"mailingListActive" `
	ScrobbleTypes           string       `json:"scrobbleTypes" `
	Country                 string       `json:"country" `
	Pin                     string       `json:"pin"`
	Subscription            Subscription `json:"subscription" `
	SubscriptionDescription string       `json:"subscriptionDescription" `
	Restricted              bool         `json:"restricted" `
	Anonymous               interface{}  `json:"anonymous" `
	Home                    bool         `json:"home" `
	Guest                   bool         `json:"guest" `
	HomeSize                int          `json:"homeSize" `
	HomeAdmin               bool         `json:"homeAdmin" `
	MaxHomeSize             int          `json:"maxHomeSize" `
	CertificateVersion      int          `json:"certificateVersion" `
	RememberExpiresAt       int          `json:"rememberExpiresAt" `
	Profile                 Profile      `json:"profile" `
	Entitlements            []string     `json:"entitlements" `
	Roles                   []string     `json:"roles" `
	Services                []Services   `json:"services" `
	AdsConsent              interface{}  `json:"adsConsent" `
	AdsConsentSetAt         interface{}  `json:"adsConsentSetAt" `
	AdsConsentReminderAt    interface{}  `json:"adsConsentReminderAt" `
	ExperimentalFeatures    bool         `json:"experimentalFeatures" `
	TwoFactorEnabled        bool         `json:"twoFactorEnabled" `
	BackupCodesCreated      bool         `json:"backupCodesCreated"`
	// contains filtered or unexported fields
}

User endpoint

func (*User) Servers

func (u *User) Servers() ([]Server, error)

Jump to

Keyboard shortcuts

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