Plex_Server_Library_ItemAbstract
abstract class Plex_Server_Library_ItemAbstract extends Plex_Server_Library_SectionAbstract implements Plex_Server_Library_ItemInterface
Base class that helps define a Plex library item with all the generic methods and member shared by all Plex library items.
Constants
| DEFAULT_ADDRESS |
The default address on which a Plex server listens. |
| DEFAULT_PORT |
The default port on which a Plex server listens. |
| ENDPOINT_CLIENT |
The Plex HTTP API endpoint for client listing. |
| ENDPOINT_LIBRARY |
URL endpoint for Plex server library. |
| ENDPOINT_SECTION |
URL endpoint for library sections. |
| ENDPOINT_RECENTLY_ADDED |
URL endpoint for a library's recently added items. |
| ENDPOINT_ON_DECK |
URL endpoint for a library's on deck items. |
| ENDPOINT_METADATA |
URL endpoint for single library items. |
| TYPE_MOVIE |
String that identifies a Plex library movie item type. |
| TYPE_ARTIST |
String that identifies a Plex library artist item type. |
| TYPE_ALBUM |
String that identifies a Plex library album item type. |
| TYPE_TRACK |
String that identifies a Plex library track item type. |
| TYPE_PHOTO |
String that identifies a Plex library photo item type. |
| TYPE_SHOW |
String that identifies a Plex library TV show item type. |
| TYPE_SEASON |
String that identifies a Plex library TV season item type. |
| TYPE_EPISODE |
String that identifies a Plex library episode item type. |
| ENDPOINT_CATEGORY_ALL |
Endpoint for retrieving all items for a section. |
| ENDPOINT_CATEGORY_UNWATCHED |
Endpoint for retrieving all unwatched items for a section. |
| ENDPOINT_CATEGORY_NEWEST |
Endpoint for retrieving the newest items for a section. |
| ENDPOINT_CATEGORY_RECENTLY_ADDED |
Endpoint for retrieving recently added items for a section. |
| ENDPOINT_CATEGORY_RECENTLY_VIEWED |
Endpoint for retrieving recently viewed items for a section. |
| ENDPOINT_CATEGORY_ON_DECK |
Endpoint for retrieving on deck items for a section. |
| ENDPOINT_CATEGORY_COLLECTION |
Endpoint for retrieving items for a section by collection. |
| ENDPOINT_CATEGORY_FIRST_CHARACTER |
Endpoint for retrieving items for a section by first character. |
| ENDPOINT_CATEGORY_GENRE |
Endpoint for retrieving items for a section by genre. |
| ENDPOINT_CATEGORY_YEAR |
Endpoint for retrieving items for a section by year. |
| ENDPOINT_CATEGORY_CONTENT_RATING |
Endpoint for retrieving shows by content rating. |
| ENDPOINT_SEARCH |
Endpoint for searching a section for items. |
| SEARCH_TYPE_MOVIE |
Parameter for searching movies. |
| SEARCH_TYPE_SHOW |
Parameter for searching television shows. |
| SEARCH_TYPE_EPISODE |
Parameter for searching television episodes. |
| SEARCH_TYPE_ARTIST |
Parameter for searching artists. |
| SEARCH_TYPE_TRACK |
Parameter for searching tracks. |
| ENDPOINT_CHILDREN |
Endpoint for listing the child items of a parent or grandparent item. |
| ENDPOINT_ALL_LEAVES |
Endpoint for listing all the grandchild items of an item. |
Properties
| protected string | $name | The name of the Plex machine on the network. | from Plex_MachineAbstract |
| protected string | $address | The IP address of the Plex machine on the network. | from Plex_MachineAbstract |
| protected integer | $port | The port on which the Plex machine is listening. Typically 32400 for servers and 3000 for clients. | from Plex_MachineAbstract |
| protected string | $token | The token of the Plex machine on the network. | from Plex_MachineAbstract |
| protected string | $art | Reference to the art section's art. | from Plex_Server_Library_SectionAbstract |
| protected boolean | $refreshing | Boolean saying whether or not the section is currently refreshing. | from Plex_Server_Library_SectionAbstract |
| protected string | $key | Key/path to specifically identify the the single item. | |
| protected string | $type | Type of the item. | |
| protected string | $title | Title of the item. | |
| protected string | $agent | The metadata agent for the section. | from Plex_Server_Library_SectionAbstract |
| protected string | $scanner | The type of scanner for the section. | from Plex_Server_Library_SectionAbstract |
| protected string | $language | The section's language. | from Plex_Server_Library_SectionAbstract |
| protected string | $uuid | Universally unique identifier for the section. | from Plex_Server_Library_SectionAbstract |
| protected DateTime | $updatedAt | Date the item was last updated. | |
| protected DateTime | $createdAt | Date the section was created. | from Plex_Server_Library_SectionAbstract |
| protected boolean | $allowSync | Whether or not the item is available for sync. | |
| protected integer | $librarySectionId | The ID of the library section to which the item belongs. | |
| protected integer | $ratingKey | Unique integer that represents an item and helps build its key string. | |
| protected string | $titleSort | Sorting title of the item. This is used if the item's title starts with "The," "An," or "A." | |
| protected string | $summary | Summary of the item. | |
| protected integer | $index | Index of the item. | |
| protected string | $thumb | Reference to the thumb of the item. | |
| protected DateTime | $addedAt | Date the item was added to the library. | |
| protected integer | $viewCount | The number of times the item has been viewed. | |
| protected Plex_Server_Library_Item_Media | $media | The media info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag[] | $genres | The genres info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag | $director | The director info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag | $writer | The writer info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag | $producer | The producer info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag | $country | The country info associated with a Plex item. | |
| protected Plex_Server_Library_Item_Tag[] | $roles | The roles info associated with a Plex item. |
Methods
Returns the base URL, which will be standard for all requests made to the Plex machine.
Typically the useful data returned by a Plex machine will containted in XML attributes. This allows a set of XML nodes to be passed and all the attribues extracted and returned as an associated array.
Utilizes php-curl to send a request to the passed URL and returns an XML document reprentation of the returned content.
Universal function so any method belonging to a child class of a Plex machine can discover which function called it. This is used mainly for some of our polymorphic requests as the calling function can tell us what type of item is being requested.
Sets up our Plex server using the minimum amount of data required to interact.
Returns all the available clients to which the Plex server has access indexed by the Plex client name.
Returns the Plex library belonging to the instantiated Plex server.
Generic way of building a url agains the Plex library.
Generic way of requesting Plex library items.
Given a function name, uses that name to decide what Plex library item item type with which the function is associated. This is useful when trying to polymorphically request items because we can use the calling function to abstractly identify what type of item with which we are dealing.
Returns an array of user defined Plex library sections that can be used to interact with the items contained within.
Returns a Plex library section by its given key. Here we simply run self::getSections() because the endpoint /library/sections/ID does not return full section data, it returns the categories below the section.
Returns a Plex library section by its given key or by a exact match on title. Here we simply run self::getSections() because the endpoint /library/sections/ID does not return full section data, it returns the categories below the section.
Returns the recently added items at the library level.
Sets an array of attributes, if they exist, to the corresponding class member.
Generic method for building a Plex library section endpoint.
Builds an endpoint to search a Plex library section.
Generic method allowing a child class to retrieve all items for its section.
Generic method allowing a child class to retrieve all unwatched items for its section.
Generic method allowing a child class to retrieve the newest items for its section.
Generic method allowing a child class to retrieve recently added items for its section. It is named slightly differently as it collided with the library method of the same name.
Generic method allowing a child class to retrieve the on deck items for its section. It is named slightly differently as it collided with the library method of the same name.
Generic method allowing a child class to retrieve recently viewed items for its section.
Generic method allowing a child class to retrieve recently viewed items for its section.
Generic method allowing a child class to retrieve items by first character from its section.
Generic method allowing a child class to retrieve items by genre from its section.
Generic method allowing a child class to retrieve items by four digit year from its section
Override of the section version of this method so we can apply slightly different rules when retrieving single children and grandchildren at the item level.
Returns a list with first letter of title, key and size for the child class's section. We use makeCall directly here, because we want to return just the raw array of caracters and not do any post processing on it.
Returns a list of alphanumeric of first letter for the child class's section.
Returns a list of collections for the child class's section. We use makeCall directly here, because we want to return just the raw array of collections and not do any post processing on it.
Returns the genres info of the item.
Static factory method used to instantiate child item classes by their type.
Sets a reference to the section's art.
Tells whether the section is currently in the process of refreshing.
Sets whether the section is currently in the process of refreshing.
Returns the key of the item.
Sets the key of the item.
Returns the type of the item.
Sets the type of the item.
Returns the title of the item.
Sets the title of the item.
Sets the section's scanner
Sets the section's language.
Returns the section's universally unique identifier.
Sets the section's universally unique identifier.
Returns the time at which the item was last updated.
Sets the time at which the item was last updated.
Returns the time at which the section was created.
Sets the time at which the section was last created.
Returns a single item by its index.
Builds an endpoint for an item to retrieve its children and grandchildren items.
Builds an endpoint for an item to retrieve all of its grandchildren.
Build a url with access to the thumbnail image.
Says whether or not the item is available for sync.
Sets whether or not the item is available for sync.
Return library section ID to which the item belongs.
Sets the library section ID to which the item belongs.
Returns the rating key of the item.
Sets the rating key of the item.
Returns the sort title of the item.
Sets the sort title of the item.
Returns the summary of the item.
Sets the summary of the item.
Returns the index of the item.
Sets the index of the item.
Returns the thumb reference of the item.
Sets the thumb reference of the item.
Returns the time at which the item was added.
Sets the time at which the item was added.
Sets the number of times the item has been viewed.
Returns the number of times the item has been viewed.
Returns the media info of the item.
Sets the media info of the item.
Sets the genres info of the item.
Returns the director info of the item.
Sets the director info of the item.
Returns the writer info of the item.
Sets the writer info of the item.
Returns the producer info of the item.
Sets the producer info of the item.
Returns the country info of the item.
Sets the country info of the item.
Returns the roles info of the item.
Sets the roles info of the item.
Details
in Plex_MachineAbstract at line 78
protected string
getBaseUrl()
Returns the base URL, which will be standard for all requests made to the Plex machine.
in Plex_MachineAbstract at line 102
protected array
xmlAttributesToArray(SimpleXMLElement $xml, integer $pass = 0)
Typically the useful data returned by a Plex machine will containted in XML attributes. This allows a set of XML nodes to be passed and all the attribues extracted and returned as an associated array.
in Plex_MachineAbstract at line 149
protected array
makeCall(string $url)
Utilizes php-curl to send a request to the passed URL and returns an XML document reprentation of the returned content.
in Plex_MachineAbstract at line 196
protected string
getCallingFunction(integer $depth = 2)
Universal function so any method belonging to a child class of a Plex machine can discover which function called it. This is used mainly for some of our polymorphic requests as the calling function can tell us what type of item is being requested.
in Plex_Server at line 75
void
__construct(string $name, string $address, integer $port, string $token)
Sets up our Plex server using the minimum amount of data required to interact.
in Plex_Server at line 99
Plex_Client[]
getClients()
Returns all the available clients to which the Plex server has access indexed by the Plex client name.
in Plex_Server at line 138
Plex_Server_Library
getLibrary()
Returns the Plex library belonging to the instantiated Plex server.
in Plex_Server at line 155
string
getName()
Returns the Plex server's name.
in Plex_Server at line 167
string
getAddress()
Returns the Plex server's IP address.
in Plex_Server at line 179
integer
getPort()
Returns the port on which the Plex server listens.
in Plex_Server at line 191
string
getToken()
Returns the token on which the Plex machine listens.
in Plex_Server_Library at line 123
protected string
buildUrl(string $endpoint)
Generic way of building a url agains the Plex library.
in Plex_Server_Library at line 160
protected mixed[]
getItems(string $endpoint)
Generic way of requesting Plex library items.
in Plex_Server_Library at line 204
string
functionToType($function)
Given a function name, uses that name to decide what Plex library item item type with which the function is associated. This is useful when trying to polymorphically request items because we can use the calling function to abstractly identify what type of item with which we are dealing.
in Plex_Server_Library at line 240
mixed[]
getSections()
Returns an array of user defined Plex library sections that can be used to interact with the items contained within.
in Plex_Server_Library at line 280
mixed
getSectionByKey(integer $key)
deprecated
deprecated
Returns a Plex library section by its given key. Here we simply run self::getSections() because the endpoint /library/sections/ID does not return full section data, it returns the categories below the section.
in Plex_Server_Library at line 311
mixed
getSection(integer|string $polymorphicData)
Returns a Plex library section by its given key or by a exact match on title. Here we simply run self::getSections() because the endpoint /library/sections/ID does not return full section data, it returns the categories below the section.
in Plex_Server_Library at line 343
mixed[]
getRecentlyAddedItems()
Returns the recently added items at the library level.
in Plex_Server_Library at line 356
mixed[]
getOnDeckItems()
Returns the on deck items at the library level.
at line 205
void
setAttributes(array $attribute)
Sets an array of attributes, if they exist, to the corresponding class member.
in Plex_Server_Library_SectionAbstract at line 266
protected string
buildEndpoint(string $endpoint)
Generic method for building a Plex library section endpoint.
in Plex_Server_Library_SectionAbstract at line 288
protected string
buildSearchEndpoint(integer $type, string $query)
Builds an endpoint to search a Plex library section.
in Plex_Server_Library_SectionAbstract at line 313
protected Plex_Server_Library_ItemAbstract[]
getAllItems()
Generic method allowing a child class to retrieve all items for its section.
in Plex_Server_Library_SectionAbstract at line 330
protected
getUnwatchedItems()
Generic method allowing a child class to retrieve all unwatched items for its section.
in Plex_Server_Library_SectionAbstract at line 347
protected
getNewestItems()
Generic method allowing a child class to retrieve the newest items for its section.
in Plex_Server_Library_SectionAbstract at line 365
protected Plex_Server_Library_ItemAbstract[]
getRecentlyAddedSectionItems()
Generic method allowing a child class to retrieve recently added items for its section. It is named slightly differently as it collided with the library method of the same name.
in Plex_Server_Library_SectionAbstract at line 383
protected Plex_Server_Library_ItemAbstract[]
getOnDeckSectionItems()
Generic method allowing a child class to retrieve the on deck items for its section. It is named slightly differently as it collided with the library method of the same name.
in Plex_Server_Library_SectionAbstract at line 400
protected Plex_Server_Library_ItemAbstract[]
getRecentlyViewedItems()
Generic method allowing a child class to retrieve recently viewed items for its section.
in Plex_Server_Library_SectionAbstract at line 421
protected Plex_Server_Library_ItemAbstract[]
getItemsByCollection(integer $collectionKey)
Generic method allowing a child class to retrieve recently viewed items for its section.
in Plex_Server_Library_SectionAbstract at line 447
protected Plex_Server_Library_ItemAbstract[]
getItemsByFirstCharacter(string $character)
Generic method allowing a child class to retrieve items by first character from its section.
in Plex_Server_Library_SectionAbstract at line 474
protected Plex_Server_Library_ItemAbstract[]
getItemsByGenre(integer $genreKey)
Generic method allowing a child class to retrieve items by genre from its section.
in Plex_Server_Library_SectionAbstract at line 500
protected Plex_Server_Library_ItemAbstract[]
getItemsByYear(integer $year)
Generic method allowing a child class to retrieve items by four digit year from its section
at line 327
Plex_Server_Library_ItemAbstract
getPolymorphicItem(integer|string $polymorphicData, boolean $scopedToItem = FALSE)
Override of the section version of this method so we can apply slightly different rules when retrieving single children and grandchildren at the item level.
in Plex_Server_Library_SectionAbstract at line 655
array
getFirstCharacters()
Returns a list with first letter of title, key and size for the child class's section. We use makeCall directly here, because we want to return just the raw array of caracters and not do any post processing on it.
in Plex_Server_Library_SectionAbstract at line 671
array
getAlphabet()
Returns a list of alphanumeric of first letter for the child class's section.
in Plex_Server_Library_SectionAbstract at line 688
array
getCollections()
Returns a list of collections for the child class's section. We use makeCall directly here, because we want to return just the raw array of collections and not do any post processing on it.
at line 798
array
getGenres()
Returns the genres info of the item.
at line 396
static Plex_Server_Library_SectionAbstract
factory(string $type, string $name, string $address, integer $port, string $token)
Static factory method used to instantiate child item classes by their type.
in Plex_Server_Library_SectionAbstract at line 748
string
getArt()
Returns a reference to the section's art.
in Plex_Server_Library_SectionAbstract at line 762
void
setArt(string $art)
Sets a reference to the section's art.
in Plex_Server_Library_SectionAbstract at line 774
boolean
isRefreshing()
Tells whether the section is currently in the process of refreshing.
in Plex_Server_Library_SectionAbstract at line 788
void
setRefreshing(boolean $refreshing)
Sets whether the section is currently in the process of refreshing.
at line 505
integer
getKey()
Returns the key of the item.
at line 519
void
setKey(integer $key)
Sets the key of the item.
at line 531
string
getType()
Returns the type of the item.
at line 545
void
setType(string $type)
Sets the type of the item.
at line 557
string
getTitle()
Returns the title of the item.
at line 571
void
setTitle(string $title)
Sets the title of the item.
in Plex_Server_Library_SectionAbstract at line 878
string
getAgent()
Returns the section's agent.
in Plex_Server_Library_SectionAbstract at line 892
void
setAgent(string $agent)
Sets the section's agent.
in Plex_Server_Library_SectionAbstract at line 904
string
getScanner()
Returns the section's scanner
in Plex_Server_Library_SectionAbstract at line 918
void
setScanner(string $scanner)
Sets the section's scanner
in Plex_Server_Library_SectionAbstract at line 930
string
getLanguage()
Returns the section's language.
in Plex_Server_Library_SectionAbstract at line 944
void
setLanguage(string $language)
Sets the section's language.
in Plex_Server_Library_SectionAbstract at line 956
string
getUuid()
Returns the section's universally unique identifier.
in Plex_Server_Library_SectionAbstract at line 970
void
setUuid(string $uuid)
Sets the section's universally unique identifier.
at line 715
DateTime
getUpdatedAt()
Returns the time at which the item was last updated.
at line 756
void
setUpdatedAt(integer $updatedAtTs)
Sets the time at which the item was last updated.
in Plex_Server_Library_SectionAbstract at line 1010
DateTime
getCreatedAt()
Returns the time at which the section was created.
in Plex_Server_Library_SectionAbstract at line 1025
void
setCreatedAt(integer $createdAtTs)
Sets the time at which the section was last created.
at line 283
Plex_Server_Library_ItemAbstract
getItemByIndex(integer $index)
Returns a single item by its index.
at line 354
protected string
buildChildrenEndpoint()
Builds an endpoint for an item to retrieve its children and grandchildren items.
at line 373
protected string
buildAllLeavesEndpoint()
Builds an endpoint for an item to retrieve all of its grandchildren.
at line 415
string
buildUrlThumb()
Build a url with access to the thumbnail image.
at line 427
boolean
doesAllowSync()
Says whether or not the item is available for sync.
at line 441
void
setAllowSync(boolean $allowSync)
Sets whether or not the item is available for sync.
at line 453
int
getLibrarySectionId()
Return library section ID to which the item belongs.
at line 467
void
setLibrarySectionId(int $librarySectionId)
Sets the library section ID to which the item belongs.
at line 479
int
getRatingKey()
Returns the rating key of the item.
at line 493
void
setRatingKey(int $ratingKey)
Sets the rating key of the item.
at line 583
string
getTitleSort()
Returns the sort title of the item.
at line 597
void
setTitleSort(string $titleSort)
Sets the sort title of the item.
at line 609
string
getSummary()
Returns the summary of the item.
at line 623
void
setSummary(string $summary)
Sets the summary of the item.
at line 635
int
getIndex()
Returns the index of the item.
at line 649
void
setIndex(int $index)
Sets the index of the item.
at line 661
string
getThumb()
Returns the thumb reference of the item.
at line 675
void
setThumb(string $thumb)
Sets the thumb reference of the item.
at line 687
DateTime
getAddedAt()
Returns the time at which the item was added.
at line 702
void
setAddedAt(integer $addedAtTs)
Sets the time at which the item was added.
at line 729
void
setViewCount(integer $viewCount)
Sets the number of times the item has been viewed.
at line 741
integer
getViewCount()
Returns the number of times the item has been viewed.
at line 769
Plex_Server_Library_Item_Media
getMedia()
Returns the media info of the item.
at line 785
void
setMedia(array $media)
Sets the media info of the item.
at line 814
void
setGenres(array $genres)
Sets the genres info of the item.
at line 831
Plex_Server_Library_Item_Tag
getDirector()
Returns the director info of the item.
at line 847
void
setDirector(array $director)
Sets the director info of the item.
at line 860
Plex_Server_Library_Item_Tag
getWriter()
Returns the writer info of the item.
at line 876
void
setWriter(array $writer)
Sets the writer info of the item.
at line 889
Plex_Server_Library_Item_Tag
getProducer()
Returns the producer info of the item.
at line 905
void
setProducer(array $producer)
Sets the producer info of the item.
at line 918
Plex_Server_Library_Item_Tag
getCountry()
Returns the country info of the item.
at line 934
void
setCountry(array $country)
Sets the country info of the item.
at line 947
Plex_Server_Library_Item_Tag[]
getRoles()
Returns the roles info of the item.
at line 963
void
setRoles(array $roles)
Sets the roles info of the item.