plex

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package plex provides the methods the Notifiarr client uses to interface with Plex. This package also provides a web handler for incoming plex webhooks, and another two handlers for requests from Notifiarr.com to list sessions and kill a session. The purpose is to keep track of Plex viewers and send meaningful alerts to their respective Disord server about user behavior. ie. user started watching something, paused it, resumed it, and finished something. This package can be disabled by not providing a Plex Media Server URL or Token.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadStatus = fmt.Errorf("status code not 200")

ErrBadStatus is returned when plex returns an invalid status code.

View Source
var ErrNoURLToken = fmt.Errorf("token or URL for Plex missing")

ErrNoURLToken is returned when there is no token or URL.

Functions

func GetMediaTranscode

func GetMediaTranscode(medias []*Media) []string

GetMediaTranscode returns the transcode info in a format for an html template to consume.

Types

type Config

type Config struct {
	URL    string       `toml:"url" json:"url" xml:"url"`
	Token  string       `toml:"token" json:"token" xml:"token"`
	Client *http.Client `toml:"-" json:"-" xml:"-"`
}

type Country

type Country struct {
	Count  string `json:"count"`
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Tag    string `json:"tag"`
}

Country is part of a Plex Session.

type Director

type Director struct {
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Tag    string `json:"tag"`
}

Director is part of a Plex Session.

type Directory

type Directory struct {
	Count int    `json:"count"`
	Key   string `json:"key"`
	Title string `json:"title"`
}

Directory is part of the PMSInfo.

type GUID

type GUID struct {
	ID string `json:"id"`
}

GUID is a reusable type from the Section library.

type Genre

type Genre struct {
	Count  string `json:"count"`
	Filter string `json:"filter"`
	ID     int64  `json:"id"`
	Tag    string `json:"tag"`
}

Genre is part of a Plex Session.

type IncomingWebhook

type IncomingWebhook struct {
	Event   string  `json:"event"`
	User    bool    `json:"user"`
	Owner   bool    `json:"owner"`
	Rating  float64 `json:"rating"`
	Account struct {
		ID    int    `json:"id"`
		Thumb string `json:"thumb"`
		Title string `json:"title"`
	} `json:"Account"`
	Server struct {
		Title string `json:"title"`
		UUID  string `json:"uuid"`
	} `json:"Server"`
	Player struct {
		Local         bool   `json:"local"`
		PublicAddress string `json:"publicAddress"`
		Title         string `json:"title"`
		UUID          string `json:"uuid"`
	} `json:"Player"`
	Metadata WebhookMetadata `json:"Metadata"`
}

IncomingWebhook is the incoming webhook from a Plex Media Server.

type LibrarySection

type LibrarySection struct {
	AllowSync        bool   `json:"allowSync"`
	Art              string `json:"art"`
	Composite        string `json:"composite"`
	Filters          bool   `json:"filters"`
	Refreshing       bool   `json:"refreshing"`
	Thumb            string `json:"thumb"`
	Key              string `json:"key"` // this is the ID.
	Type             string `json:"type"`
	Title            string `json:"title"`
	Agent            string `json:"agent"`
	Scanner          string `json:"scanner"`
	Language         string `json:"language"`
	UUID             string `json:"uuid"`
	UpdatedAt        int    `json:"updatedAt"`
	CreatedAt        int    `json:"createdAt"`
	ScannedAt        int    `json:"scannedAt"`
	Content          bool   `json:"content"`
	Directory        bool   `json:"directory"`
	ContentChangedAt int    `json:"contentChangedAt"`
	Hidden           int    `json:"hidden"`
	Location         []struct {
		ID   int64  `json:"id"`
		Path string `json:"path"`
	} `json:"Location"`
}

LibrarySection is data about a library's section, ie movies, tv, music.

type Media

type Media struct {
	AspectRatio     string       `json:"aspectRatio"`
	AudioChannels   int          `json:"audioChannels"`
	AudioCodec      string       `json:"audioCodec"`
	AudioProfile    string       `json:"audioProfile"`
	Bitrate         float64      `json:"bitrate"`
	Container       string       `json:"container"`
	Duration        float64      `json:"duration"`
	Height          int64        `json:"height"`
	ID              string       `json:"id"`
	Protocol        string       `json:"protocol"`
	StreamingOptmzd bool         `json:"optimizedForStreaming"`
	VideoCodec      string       `json:"videoCodec"`
	VideoFrameRate  string       `json:"videoFrameRate"`
	VideoProfile    string       `json:"videoProfile"`
	VideoResolution string       `json:"videoResolution"`
	Width           int64        `json:"width"`
	Selected        bool         `json:"selected"`
	Part            []*MediaPart `json:"Part"`
}

Media is part of a Plex Session.

type MediaPart

type MediaPart struct {
	AudioProfile    string         `json:"audioProfile"`
	Bitrate         float64        `json:"bitrate"`
	Container       string         `json:"container"`
	Decision        string         `json:"decision"`
	Duration        float64        `json:"duration"`
	File            string         `json:"file"`
	Height          int64          `json:"height"`
	ID              string         `json:"id"`
	Indexes         string         `json:"indexes"`
	Key             string         `json:"key"`
	Protocol        string         `json:"protocol"`
	Selected        bool           `json:"selected"`
	Size            int64          `json:"size"`
	StreamingOptmzd bool           `json:"optimizedForStreaming"`
	VideoProfile    string         `json:"videoProfile"`
	Width           int64          `json:"width"`
	Stream          []*MediaStream `json:"Stream"`
}

MediaPart is part of a Plex Session.

type MediaSection

type MediaSection struct {
	Size                int    `json:"size"`
	AllowSync           bool   `json:"allowSync"`
	Identifier          string `json:"identifier"`
	LibrarySectionID    int    `json:"librarySectionID"`
	LibrarySectionTitle string `json:"librarySectionTitle"`
	LibrarySectionUUID  string `json:"librarySectionUUID"`
	MediaTagPrefix      string `json:"mediaTagPrefix"`
	MediaTagVersion     int    `json:"mediaTagVersion"`
	Metadata            []struct {
		RatingKey             string  `json:"ratingKey"`
		Key                   string  `json:"key"`
		ParentRatingKey       string  `json:"parentRatingKey,omitempty"`
		GrandparentRatingKey  string  `json:"grandparentRatingKey,omitempty"`
		GUID                  string  `json:"guid"`
		ParentGUID            string  `json:"parentGuid,omitempty"`
		GrandparentGUID       string  `json:"grandparentGuid,omitempty"`
		Type                  string  `json:"type"`
		Title                 string  `json:"title"`
		GrandparentKey        string  `json:"grandparentKey,omitempty"`
		ParentKey             string  `json:"parentKey,omitempty"`
		LibrarySectionTitle   string  `json:"librarySectionTitle"`
		LibrarySectionID      int     `json:"librarySectionID"`
		LibrarySectionKey     string  `json:"librarySectionKey"`
		GrandparentTitle      string  `json:"grandparentTitle,omitempty"`
		ParentTitle           string  `json:"parentTitle,omitempty"`
		ContentRating         string  `json:"contentRating"`
		Summary               string  `json:"summary"`
		Index                 int     `json:"index,omitempty"`
		ParentIndex           int     `json:"parentIndex,omitempty"`
		Rating                float64 `json:"rating,omitempty"`
		Year                  int     `json:"year,omitempty"`
		Thumb                 string  `json:"thumb"`
		Art                   string  `json:"art"`
		ParentThumb           string  `json:"parentThumb,omitempty"`
		GrandparentThumb      string  `json:"grandparentThumb,omitempty"`
		GrandparentArt        string  `json:"grandparentArt,omitempty"`
		GrandparentTheme      string  `json:"grandparentTheme,omitempty"`
		Duration              int     `json:"duration"`
		OriginallyAvailableAt string  `json:"originallyAvailableAt"`
		AddedAt               int     `json:"addedAt"`
		UpdatedAt             int     `json:"updatedAt"`
		Media                 []struct {
			ID                    int     `json:"id"`
			Duration              int     `json:"duration"`
			Bitrate               int     `json:"bitrate"`
			Width                 int     `json:"width"`
			Height                int     `json:"height"`
			AspectRatio           float64 `json:"aspectRatio"`
			AudioChannels         int     `json:"audioChannels"`
			AudioCodec            string  `json:"audioCodec"`
			VideoCodec            string  `json:"videoCodec"`
			VideoResolution       string  `json:"videoResolution"`
			Container             string  `json:"container"`
			VideoFrameRate        string  `json:"videoFrameRate"`
			OptimizedForStreaming int     `json:"optimizedForStreaming"`
			AudioProfile          string  `json:"audioProfile"`
			Has64BitOffsets       bool    `json:"has64bitOffsets"`
			VideoProfile          string  `json:"videoProfile"`
			Part                  []struct {
				ID                    int    `json:"id"`
				Key                   string `json:"key"`
				Duration              int    `json:"duration"`
				File                  string `json:"file"`
				Size                  int    `json:"size"`
				AudioProfile          string `json:"audioProfile"`
				Container             string `json:"container"`
				Indexes               string `json:"indexes"`
				VideoProfile          string `json:"videoProfile"`
				OptimizedForStreaming bool   `json:"optimizedForStreaming"`
				Has64BitOffsets       bool   `json:"has64bitOffsets"`
				Stream                []struct {
					ID                   int     `json:"id"`
					StreamType           int     `json:"streamType"`
					Codec                string  `json:"codec"`
					Index                int     `json:"index"`
					Bitrate              int     `json:"bitrate"`
					BitDepth             int     `json:"bitDepth,omitempty"`
					ChromaLocation       string  `json:"chromaLocation,omitempty"`
					ChromaSubsampling    string  `json:"chromaSubsampling,omitempty"`
					CodedHeight          int     `json:"codedHeight,omitempty"`
					CodedWidth           int     `json:"codedWidth,omitempty"`
					ColorRange           string  `json:"colorRange,omitempty"`
					ColorSpace           string  `json:"colorSpace,omitempty"`
					FrameRate            float64 `json:"frameRate,omitempty"`
					Height               int     `json:"height,omitempty"`
					Level                int     `json:"level,omitempty"`
					Profile              string  `json:"profile"`
					RefFrames            int     `json:"refFrames,omitempty"`
					StreamIdentifier     string  `json:"streamIdentifier"`
					Width                int     `json:"width,omitempty"`
					DisplayTitle         string  `json:"displayTitle"`
					ExtendedDisplayTitle string  `json:"extendedDisplayTitle"`
					Channels             int     `json:"channels,omitempty"`
					Language             string  `json:"language,omitempty"`
					LanguageCode         string  `json:"languageCode,omitempty"`
					AudioChannelLayout   string  `json:"audioChannelLayout,omitempty"`
					SamplingRate         int     `json:"samplingRate,omitempty"`
					Selected             bool    `json:"selected,omitempty"`
					HasScalingMatrix     bool    `json:"hasScalingMatrix,omitempty"`
					Default              bool    `json:"default"`
				} `json:"Stream"`
			} `json:"Part"`
		} `json:"Media"`
		TitleSort           string    `json:"titleSort,omitempty"`
		ViewOffset          int       `json:"viewOffset,omitempty"`
		LastViewedAt        int       `json:"lastViewedAt,omitempty"`
		ParentYear          int       `json:"parentYear,omitempty"`
		Studio              string    `json:"studio,omitempty"`
		AudienceRating      float64   `json:"audienceRating,omitempty"`
		ViewCount           int       `json:"viewCount,omitempty"`
		Tagline             string    `json:"tagline,omitempty"`
		AudienceRatingImage string    `json:"audienceRatingImage,omitempty"`
		ChapterSource       string    `json:"chapterSource,omitempty"`
		PrimaryExtraKey     string    `json:"primaryExtraKey,omitempty"`
		RatingImage         string    `json:"ratingImage,omitempty"`
		GuID                []*GUID   `json:"Guid,omitempty"`
		ExternalRating      []*Rating `json:"Rating,omitempty"`
	} `json:"Metadata"`
}

MediaSection is a plex response struct.

type MediaStream

type MediaStream struct {
	AudioChannelLayout string  `json:"audioChannelLayout,omitempty"`
	BitDepth           int     `json:"bitDepth,omitempty"`
	Bitrate            float64 `json:"bitrate"`
	BitrateMode        string  `json:"bitrateMode,omitempty"`
	Channels           int     `json:"channels,omitempty"`
	ChromaLocation     string  `json:"chromaLocation,omitempty"`
	ChromaSubsampling  string  `json:"chromaSubsampling,omitempty"`
	Codec              string  `json:"codec"`
	CodedHeight        int64   `json:"codedHeight,omitempty"`
	CodedWidth         int64   `json:"codedWidth,omitempty"`
	ColorPrimaries     string  `json:"colorPrimaries,omitempty"`
	ColorTrc           string  `json:"colorTrc,omitempty"`
	Decision           string  `json:"decision"`
	Default            bool    `json:"default,omitempty"`
	DisplayTitle       string  `json:"displayTitle"`
	ExtDisplayTitle    string  `json:"extendedDisplayTitle"`
	FrameRate          float64 `json:"frameRate,omitempty"`
	HasScalingMatrix   bool    `json:"hasScalingMatrix,omitempty"`
	Height             int64   `json:"height,omitempty"`
	ID                 string  `json:"id"`
	Index              int     `json:"index"`
	Language           string  `json:"language,omitempty"`
	LanguageCode       string  `json:"languageCode,omitempty"`
	Level              int     `json:"level,omitempty"`
	Location           string  `json:"location"`
	Profile            string  `json:"profile"`
	RefFrames          int     `json:"refFrames,omitempty"`
	SamplingRate       int     `json:"samplingRate,omitempty"`
	ScanType           string  `json:"scanType,omitempty"`
	Selected           bool    `json:"selected,omitempty"`
	StreamType         int     `json:"streamType"`
	Width              int64   `json:"width,omitempty"`
	LanguageTag        string  `json:"languageTag,omitempty"`
}

MediaStream is part of a Plex Session.

type PMSInfo

type PMSInfo struct {
	AllowCameraUpload             bool         `json:"allowCameraUpload"`
	AllowChannelAccess            bool         `json:"allowChannelAccess"`
	AllowSharing                  bool         `json:"allowSharing"`
	AllowSync                     bool         `json:"allowSync"`
	AllowTuners                   bool         `json:"allowTuners"`
	BackgroundProcessing          bool         `json:"backgroundProcessing"`
	Certificate                   bool         `json:"certificate"`
	CompanionProxy                bool         `json:"companionProxy"`
	CountryCode                   string       `json:"countryCode"`
	Diagnostics                   string       `json:"diagnostics"`
	Directory                     []*Directory `json:"Directory"`
	EventStream                   bool         `json:"eventStream"`
	FriendlyName                  string       `json:"friendlyName"`
	HubSearch                     bool         `json:"hubSearch"`
	ItemClusters                  bool         `json:"itemClusters"`
	LiveTV                        int64        `json:"livetv"`
	MachineIdentifier             string       `json:"machineIdentifier"`
	MaxUploadBitrate              int64        `json:"maxUploadBitrate"`
	MaxUploadBitrateReason        string       `json:"maxUploadBitrateReason"`
	MaxUploadBitrateReasonMessage string       `json:"maxUploadBitrateReasonMessage"`
	MediaProviders                bool         `json:"mediaProviders"`
	Multiuser                     bool         `json:"multiuser"`
	MyPlex                        bool         `json:"myPlex"`
	MyPlexMappingState            string       `json:"myPlexMappingState"`
	MyPlexSigninState             string       `json:"myPlexSigninState"`
	MyPlexSubscription            bool         `json:"myPlexSubscription"`
	MyPlexUsername                string       `json:"myPlexUsername"`
	OfflineTranscode              int64        `json:"offlineTranscode"`
	OwnerFeatures                 string       `json:"ownerFeatures"`
	PhotoAutoTag                  bool         `json:"photoAutoTag"`
	Platform                      string       `json:"platform"`
	PlatformVersion               string       `json:"platformVersion"`
	PluginHost                    bool         `json:"pluginHost"`
	PushNotifications             bool         `json:"pushNotifications"`
	ReadOnlyLibraries             bool         `json:"readOnlyLibraries"`
	RequestParametersInCookie     bool         `json:"requestParametersInCookie"`
	Size                          int64        `json:"size"`
	StreamingBrainABRVersion      int64        `json:"streamingBrainABRVersion"`
	StreamingBrainVersion         int64        `json:"streamingBrainVersion"`
	Sync                          bool         `json:"sync"`
	TranscoderActiveVideoSessions int64        `json:"transcoderActiveVideoSessions"`
	TranscoderAudio               bool         `json:"transcoderAudio"`
	TranscoderLyrics              bool         `json:"transcoderLyrics"`
	TranscoderPhoto               bool         `json:"transcoderPhoto"`
	TranscoderSubtitles           bool         `json:"transcoderSubtitles"`
	TranscoderVideo               bool         `json:"transcoderVideo"`
	TranscoderVideoBitrates       string       `json:"transcoderVideoBitrates"`
	TranscoderVideoQualities      string       `json:"transcoderVideoQualities"`
	TranscoderVideoResolutions    string       `json:"transcoderVideoResolutions"`
	UpdatedAt                     int64        `json:"updatedAt"`
	Updater                       bool         `json:"updater"`
	Version                       string       `json:"version"`
	VoiceSearch                   bool         `json:"voiceSearch"`

} // `json:"MediaContainer"`

PMSInfo is the `/` path on Plex.

type Player

type Player struct {
	Address     string    `json:"address"`
	Device      string    `json:"device"`
	MachineID   string    `json:"machineIdentifier"`
	Model       string    `json:"model"`
	Platform    string    `json:"platform"`
	PlatformVer string    `json:"platformVersion"`
	Product     string    `json:"product"`
	Profile     string    `json:"profile"`
	PublicAddr  string    `json:"remotePublicAddress"`
	State       string    `json:"state"`
	StateTime   structDur `json:"stateTime"` // this is not a plex item. We calculate this.
	Title       string    `json:"title"`
	UserID      int64     `json:"userID"`
	Vendor      string    `json:"vendor"`
	Version     string    `json:"version"`
	Relayed     bool      `json:"relayed"`
	Local       bool      `json:"local"`
	Secure      bool      `json:"secure"`
}

Player is part of a Plex Session.

type Producer

type Producer struct {
	Count  string `json:"count"`
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Tag    string `json:"tag"`
}

Producer is part of a Plex Session.

type Rating

type Rating struct {
	Image string      `json:"image"`
	Value interface{} `json:"value"`
	Type  string      `json:"type"`
}

Rating is part of Plex metadata.

type Role

type Role struct {
	Count  string `json:"count,omitempty"`
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Role   string `json:"role"`
	Tag    string `json:"tag"`
	Thumb  string `json:"thumb,omitempty"`
}

Role is part of a Plex Session.

type SectionDirectory

type SectionDirectory struct {
	Size      int               `json:"size"`
	AllowSync bool              `json:"allowSync"`
	Title1    string            `json:"title1"`
	Directory []*LibrarySection `json:"Directory"`
}

SectionDirectory contains the directory of sections.

type Server

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

Server is the Plex configuration from a config file. Without a URL or Token, nothing works and this package is unused.

func New

func New(config *Config) *Server

New turns a config into a server.

func (*Server) EmptyAllTrashWithContext

func (s *Server) EmptyAllTrashWithContext(ctx context.Context) error

EmptyAllTrashWithContext deletes the trash in all sections.

func (*Server) EmptyTrash

func (s *Server) EmptyTrash(sectionKey string) ([]byte, error)

EmptyTrash deletes (a section's) trash.

func (*Server) EmptyTrashWithContext

func (s *Server) EmptyTrashWithContext(ctx context.Context, libraryKey string) ([]byte, error)

EmptyTrashWithContext deletes (a section's) trash.

func (*Server) GetDirectory

func (s *Server) GetDirectory() (*SectionDirectory, error)

GetDirectory returns data about all the library sections.

func (*Server) GetDirectoryWithContext

func (s *Server) GetDirectoryWithContext(ctx context.Context) (*SectionDirectory, error)

GetDirectoryWithContext returns data about all the library sections.

func (*Server) GetInfo

func (s *Server) GetInfo(ctx context.Context) (*PMSInfo, error)

GetInfo retrieves Plex Server Info. This also sets the friendly name, so s.Name() works.

func (*Server) GetPlexSectionKey

func (s *Server) GetPlexSectionKey(keyPath string) (*MediaSection, error)

GetPlexSectionKey gets a section key from Plex based on a key path.

func (*Server) GetPlexSectionKeyWithContext

func (s *Server) GetPlexSectionKeyWithContext(ctx context.Context, keyPath string) (*MediaSection, error)

GetPlexSectionKey gets a section key from Plex based on a key path.

func (*Server) GetSessions

func (s *Server) GetSessions() (*Sessions, error)

GetSessions returns the Plex sessions in JSON format, no timeout.

func (*Server) GetSessionsWithContext

func (s *Server) GetSessionsWithContext(ctx context.Context) (*Sessions, error)

GetSessionsWithContext returns the Plex sessions in JSON format.

func (*Server) HandleDirectory

func (s *Server) HandleDirectory(r *http.Request) (int, interface{})

@Description Returns the Plex Library Directory. @Summary Retrieve the Plex Library Directory. @Tags Plex @Produce json @Success 200 {object} apps.Respond.apiResponse{message=SectionDirectory} "Plex Library Directory" @Failure 500 {object} apps.Respond.apiResponse{message=string} "Plex error" @Failure 404 {object} string "bad token or api key" @Router /api/plex/1/directory [get]

func (*Server) HandleEmptyTrash

func (s *Server) HandleEmptyTrash(r *http.Request) (int, interface{})

@Description Empties the Plex library trash for the provided library key. Get the library key from the Directory. @Summary Empty Plex Trash @Tags Plex @Produce json @Param libraryKey path string true "Plex Library Section Key" @Success 200 {object} apps.Respond.apiResponse{message=string} "ok" @Failure 500 {object} apps.Respond.apiResponse{message=string} "Plex error" @Failure 404 {object} string "bad token or api key" @Router /api/plex/1/emptytrash/{libraryKey} [get]

func (*Server) HandleKillSession

func (s *Server) HandleKillSession(r *http.Request) (int, interface{})

HandleKillSession provides a web handler to the notifiarr client allows notifiarr.com (via Discord request) to end a Plex session. @Description Kills a Plex session by ID and sends a message to the user. @Summary Kill a Plex session. @Tags Plex @Produce json @Param sessionId query string true "Plex session ID" @Param reason query string true "Reason the session is being terminated. Sent to the user." @Success 200 {object} apps.Respond.apiResponse{message=string} "success" @Failure 500 {object} apps.Respond.apiResponse{message=string} "Plex error" @Failure 404 {object} string "bad token or api key" @Router /api/plex/1/kill [get]

func (*Server) HandleMarkWatched

func (s *Server) HandleMarkWatched(r *http.Request) (int, interface{})

@Description Marks a movie or show or audio track as watched. @Summary Mark a Plex item as watched. @Tags Plex @Produce json @Param itemKey path string true "Plex Item Key" @Success 200 {object} apps.Respond.apiResponse{message=string} "ok" @Failure 500 {object} apps.Respond.apiResponse{message=string} "Plex error" @Failure 404 {object} string "bad token or api key" @Router /api/plex/1/markwatched/{itemKey} [get]

func (*Server) HandleSessions

func (s *Server) HandleSessions(r *http.Request) (int, interface{})

HandleSessions provides a web handler to the notifiarr client that returns the current Plex sessions. The handler satisfies apps.APIHandler, sorry. @Description Returns Plex sessions. @Summary Retrieve Plex sessions. @Tags Plex @Produce json @Success 200 {object} apps.Respond.apiResponse{message=Sessions} "contains app info included appStatus" @Failure 500 {object} apps.Respond.apiResponse{message=string} "Plex error" @Failure 404 {object} string "bad token or api key" @Router /api/plex/1/sessions [get]

func (*Server) KillSession

func (s *Server) KillSession(sessionID, reason string) ([]byte, error)

KillSession kills a Plex session.

func (*Server) KillSessionWithContext

func (s *Server) KillSessionWithContext(ctx context.Context, sessionID, reason string) ([]byte, error)

KillSessionWithContext kills a Plex session.

func (*Server) MarkPlayed

func (s *Server) MarkPlayed(key string) ([]byte, error)

MarkPlayed marks a video as played.

func (*Server) MarkPlayedWithContext

func (s *Server) MarkPlayedWithContext(ctx context.Context, key string) ([]byte, error)

MarkPlayedWithContext marks a video as played.

func (*Server) Name

func (s *Server) Name() string

Name returns the server name.

type Session

type Session struct {
	User                 User      `json:"User"`
	Player               Player    `json:"Player"`
	TranscodeSession     Transcode `json:"TranscodeSession"`
	Added                int64     `json:"addedAt"`
	Art                  string    `json:"art"`
	AudienceRating       float64   `json:"audienceRating"`
	AudienceRatingImg    string    `json:"audienceRatingImage"`
	ContentRating        string    `json:"contentRating"`
	Duration             float64   `json:"duration"`
	GUID                 string    `json:"guid"`
	GrandparentArt       string    `json:"grandparentArt"`
	GrandparentGUID      string    `json:"grandparentGuid"`
	GrandparentKey       string    `json:"grandparentKey"`
	GrandparentRatingKey string    `json:"grandparentRatingKey"`
	GrandparentTheme     string    `json:"grandparentTheme"`
	GrandparentThumb     string    `json:"grandparentThumb"`
	GrandparentTitle     string    `json:"grandparentTitle"`
	Index                int64     `json:"index"`
	Key                  string    `json:"key"`
	LastViewed           int64     `json:"lastViewedAt"`
	LibrarySectionID     string    `json:"librarySectionID"`
	LibrarySectionKey    string    `json:"librarySectionKey"`
	LibrarySectionTitle  string    `json:"librarySectionTitle"`
	OriginallyAvailable  string    `json:"originallyAvailableAt"`
	ParentGUID           string    `json:"parentGuid"`
	ParentIndex          int64     `json:"parentIndex"`
	ParentKey            string    `json:"parentKey"`
	ParentRatingKey      string    `json:"parentRatingKey"`
	ParentThumb          string    `json:"parentThumb"`
	ParentTitle          string    `json:"parentTitle"`
	PrimaryExtraKey      string    `json:"primaryExtraKey"`
	Rating               float64   `json:"rating"`
	RatingImage          string    `json:"ratingImage"`
	RatingKey            string    `json:"ratingKey"`
	SessionKey           string    `json:"sessionKey"`
	Studio               string    `json:"studio"`
	Summary              string    `json:"summary"`
	Thumb                string    `json:"thumb"`
	Title                string    `json:"title"`
	TitleSort            string    `json:"titleSort"`
	Type                 string    `json:"type"`
	Updated              int64     `json:"updatedAt"`
	ViewCount            int64     `json:"viewCount"`
	ViewOffset           float64   `json:"viewOffset"`
	Year                 int       `json:"year"`
	Session              struct {
		Bandwidth int64  `json:"bandwidth"`
		ID        string `json:"id"`
		Location  string `json:"location"`
	} `json:"Session"`
	GuID           []*GUID   `json:"Guid,omitempty"`
	Media          []*Media  `json:"Media,omitempty"`
	ExternalRating []*Rating `json:"Rating,omitempty"`
}

Session is a Plex json struct.

type Sessions

type Sessions struct {
	Name     string     `json:"server"`
	HostID   string     `json:"hostId"`
	Sessions []*Session `json:"sessions"`
}

Sessions is the config input data.

type Similar

type Similar struct {
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Tag    string `json:"tag"`
	Count  string `json:"count,omitempty"`
}

Similar is part of a Plex Session.

type Transcode

type Transcode struct {
	AudioChannels       int     `json:"audioChannels"`
	AudioCodec          string  `json:"audioCodec"`
	AudioDecision       string  `json:"audioDecision"`
	Container           string  `json:"container"`
	Context             string  `json:"context"`
	Duration            int64   `json:"duration"`
	Key                 string  `json:"key"`
	MaxOffsetAvailable  float64 `json:"maxOffsetAvailable"`
	MinOffsetAvailable  float64 `json:"minOffsetAvailable"`
	Progress            float64 `json:"progress"`
	Protocol            string  `json:"protocol"`
	Remaining           int64   `json:"remaining"`
	Size                int64   `json:"size"`
	SourceAudioCodec    string  `json:"sourceAudioCodec"`
	SourceVideoCodec    string  `json:"sourceVideoCodec"`
	Speed               float64 `json:"speed"`
	TimeStamp           float64 `json:"timeStamp"`
	VideoCodec          string  `json:"videoCodec"`
	VideoDecision       string  `json:"videoDecision"`
	Throttled           bool    `json:"throttled"`
	Complete            bool    `json:"complete"`
	XcodeHwFullPipeline bool    `json:"transcodeHwFullPipeline"`
	XcodeHwRequested    bool    `json:"transcodeHwRequested"`
}

Transcode is part of a Plex Session.

type User

type User struct {
	ID    string `json:"id"`
	Thumb string `json:"thumb"`
	Title string `json:"title"`
}

User is part of a Plex Session.

type WebhookMetadata

type WebhookMetadata struct {
	LibrarySectionType    string      `json:"librarySectionType"`
	RatingKey             string      `json:"ratingKey"`
	ParentRatingKey       string      `json:"parentRatingKey"`
	GrandparentRatingKey  string      `json:"grandparentRatingKey"`
	Key                   string      `json:"key"`
	GUID                  string      `json:"guid"`
	ParentGUID            string      `json:"parentGuid"`
	GrandparentGUID       string      `json:"grandparentGuid"`
	GuID                  []*GUID     `json:"Guid"`
	Studio                string      `json:"studio"`
	Type                  string      `json:"type"`
	GrandParentTitle      string      `json:"grandparentTitle"`
	GrandparentKey        string      `json:"grandparentKey"`
	ParentKey             string      `json:"parentKey"`
	ParentTitle           string      `json:"parentTitle"`
	ParentYear            int         `json:"parentYear"`
	ParentThumb           string      `json:"parentThumb"`
	GrandparentThumb      string      `json:"grandparentThumb"`
	GrandparentArt        string      `json:"grandparentArt"`
	GrandparentTheme      string      `json:"grandparentTheme"`
	ParentIndex           int64       `json:"parentIndex"`
	Index                 int64       `json:"index"`
	Title                 string      `json:"title"`
	TitleSort             string      `json:"titleSort"`
	LibrarySectionTitle   string      `json:"librarySectionTitle"`
	LibrarySectionID      interface{} `json:"librarySectionID"` // int (plex) or string (session tracker)
	LibrarySectionKey     string      `json:"librarySectionKey"`
	ContentRating         string      `json:"contentRating"`
	Summary               string      `json:"summary"`
	Rating                float64     `json:"rating"`
	ExternalRating        interface{} `json:"Rating,omitempty"` // bullshit.
	AudienceRating        float64     `json:"audienceRating"`
	ViewOffset            float64     `json:"viewOffset"`
	LastViewedAt          int64       `json:"lastViewedAt"`
	Year                  int         `json:"year"`
	Tagline               string      `json:"tagline"`
	Thumb                 string      `json:"thumb"`
	Art                   string      `json:"art"`
	Duration              float64     `json:"duration"`
	OriginallyAvailableAt string      `json:"originallyAvailableAt"`
	AddedAt               int64       `json:"addedAt"`
	UpdatedAt             int64       `json:"updatedAt"`
	AudienceRatingImage   string      `json:"audienceRatingImage"`
	PrimaryExtraKey       string      `json:"primaryExtraKey"`
	RatingImage           string      `json:"ratingImage"`
}

WebhookMetadata is part of an IncomingWebhook.

type Writer

type Writer struct {
	Filter string `json:"filter"`
	ID     string `json:"id"`
	Tag    string `json:"tag"`
}

Writer is part of a Plex Session.

Jump to

Keyboard shortcuts

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