diff --git a/Plex.php b/Plex.php index 8446e96..bff6cb3 100644 --- a/Plex.php +++ b/Plex.php @@ -45,6 +45,10 @@ require_once(sprintf('%s/Server/Library/Section/Show.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/Section/Artist.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/Section/Photo.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Media/File/FileInterface.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Media/File/File.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Media/MediaInterface.php', $phpPlexDir)); +require_once(sprintf('%s/Server/Library/Item/Media/Media.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemInterface.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemAbstract.php', $phpPlexDir)); require_once(sprintf('%s/Server/Library/ItemGrandparentAbstract.php', $phpPlexDir)); @@ -72,7 +76,7 @@ * @author Nick Bartkowiak * @copyright (c) 2013 Nick Bartkowiak * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) - * @version 0.0.2 + * @version 0.0.2.5 */ class Plex { diff --git a/README.md b/README.md index f51b5b2..7dfbcf5 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,23 @@ Artists, albums, and tracks $trackByKey = $albumByExactTitleMatch->getTrack('/library/metadata/57726'); $trackByExactTitleMatch = $albumByExactTitleMatch->getTrack('Rewind'); +Item Media Info + + $showSection = $library->getSection('TV Shows'); + $episode = $showSection->getShow("The Simpsons") + ->getSeason(4) + ->getEpisode(12); + + // Media Info + $media = $episode->getMedia(); + $duration = $media->getDuration(); + $bitrate = $media->getBitrate(); + + // File + $file = $media->getFile(); + $path = $file->getFile(); + $size = $file->getSize(); + Playback Controller $playback = $client->getPlaybackController(); diff --git a/Server/Library/Item/Media/File/File.php b/Server/Library/Item/Media/File/File.php new file mode 100644 index 0000000..53b0b73 --- /dev/null +++ b/Server/Library/Item/Media/File/File.php @@ -0,0 +1,269 @@ + Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Class that represents a file associated with a media item. + * + * @category php-plex + * @package Plex_Server_Library_Item + * @subpackage Plex_Server_Library_Item_Media + * @author Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + */ +class Plex_Server_Library_Item_Media_File + implements Plex_Server_Library_Item_Media_FileInterface +{ + /** + * The ID of the file. + * @var integer + */ + private $id; + + /** + * The key of the file. + * @var string + */ + private $key; + + /** + * The duration of the file in milliseconds. + * @var integer + */ + private $duration; + + /** + * Full path to the file. + * @var string + */ + private $file; + + /** + * Size of the file in bytes. + * @var integer + */ + private $size; + + /** + * Container of the file. + * @var string + */ + private $container; + + /** + * Sets an array of file info to their corresponding class members. + * + * @param array $rawFile An array of the raw file info returned from the + * Plex HTTP API. + * + * @uses Plex_Server_Library_Item_Media_File::setId() + * @uses Plex_Server_Library_Item_Media_File::setKey() + * @uses Plex_Server_Library_Item_Media_File::setDuration() + * @uses Plex_Server_Library_Item_Media_File::setFile() + * @uses Plex_Server_Library_Item_Media_File::setSize() + * @uses Plex_Server_Library_Item_Media_File::setContainer() + * + * @return void + */ + public function __construct($rawFile) + { + if (isset($rawFile['id'])) { + $this->setId($rawFile['id']); + } + if (isset($rawFile['key'])) { + $this->setKey($rawFile['key']); + } + if (isset($rawFile['duration'])) { + $this->setDuration($rawFile['duration']); + } + if (isset($rawFile['file'])) { + $this->setFile($rawFile['file']); + } + if (isset($rawFile['size'])) { + $this->setSize($rawFile['size']); + } + if (isset($rawFile['container'])) { + $this->setContainer($rawFile['container']); + } + } + + /** + * Returns the ID of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$id + * + * @return integer The ID of the file. + */ + public function getId() + { + return $this->id; + } + + /** + * Sets the ID of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$id + * + * @param integer $id The ID of the file. + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * Returns the key of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$key + * + * @return string The key of the file. + */ + public function getKey() + { + return $this->key; + } + + /** + * Sets the key of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$key + * + * @param string $key The key of the file. + * + * @return void + */ + public function setKey($key) + { + $this->key = $key; + } + + /** + * Returns the duration of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$duration + * + * @return integer The duration of the file. + */ + public function getDuration() + { + return $this->duration; + } + + /** + * Sets the duration of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$duration + * + * @param integer $duration The duration of the file. + * + * @return void + */ + public function setDuration($duration) + { + $this->duration = $duration; + } + + /** + * Returns the path of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$file + * + * @return string The path of the file. + */ + public function getFile() + { + return $this->file; + } + + /** + * Sets the path of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$file + * + * @param string $file The path of the file. + * + * @return void + */ + public function setFile($file) + { + $this->file = $file; + } + + /** + * Returns the size of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$size + * + * @return integer The size of the file. + */ + public function getSize() + { + return $this->size; + } + + /** + * Sets the size of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$size + * + * @param integer $size The size of the file. + * + * @retur void + */ + public function setSize($size) + { + $this->size = $size; + } + + /** + * Returns the container of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$container + * + * @return string The container of the file. + */ + public function getContainer() + { + return $this->container; + } + + /** + * Sets the container of the file. + * + * @uses Plex_Server_Library_Item_Media_File::$container + * + * @param string $container The container of the file. + * + * @return void + */ + public function setContainer($container) + { + $this->container = $container; + } +} diff --git a/Server/Library/Item/Media/File/FileInterface.php b/Server/Library/Item/Media/File/FileInterface.php new file mode 100644 index 0000000..4673193 --- /dev/null +++ b/Server/Library/Item/Media/File/FileInterface.php @@ -0,0 +1,135 @@ + Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Interface that defines the structure of the file associated with an item. + * + * @category php-plex + * @package Plex_Server_Library + * @subpackage Plex_Server_Library_Item + * @author Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + */ +interface Plex_Server_Library_Item_Media_FileInterface +{ + /** + * Returns the ID of the file. + * + * @return integer The ID of the file. + */ + public function getId(); + + /** + * Sets the ID of the file. + * + * @param integer $id The ID of the file. + * + * @return void + */ + public function setId($id); + + /** + * Returns the key of the file. + * + * @return string The key of the file. + */ + public function getKey(); + + /** + * Sets the key of the file. + * + * @param string $key The key of the file. + * + * @return void + */ + public function setKey($key); + + /** + * Returns the duration of the file. + * + * @return integer The duration of the file. + */ + public function getDuration(); + + /** + * Sets the duration of the file. + * + * @param integer $duration The duration of the file. + * + * @return void + */ + public function setDuration($duration); + + /** + * Returns the path of the file. + * + * @return string The path of the file. + */ + public function getFile(); + + /** + * Sets the path of the file. + * + * @param string $file The path of the file. + * + * @return void + */ + public function setFile($file); + + /** + * Returns the size of the file. + * + * @return integer The size of the file. + */ + public function getSize(); + + /** + * Sets the size of the file. + * + * @param integer $size The size of the file. + * + * @retur void + */ + public function setSize($size); + + /** + * Returns the container of the file. + * + * @return string The container of the file. + */ + public function getContainer(); + + /** + * Sets the container of the file. + * + * @param string $container The container of the file. + * + * @return void + */ + public function setContainer($container); +} diff --git a/Server/Library/Item/Media/Media.php b/Server/Library/Item/Media/Media.php new file mode 100644 index 0000000..f2a7eb8 --- /dev/null +++ b/Server/Library/Item/Media/Media.php @@ -0,0 +1,420 @@ + Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Class that represents the media info a Plex Server Library Item. + * + * @category php-plex + * @package Plex_Server_Library + * @subpackage Plex_Server_Library_Item + * @author Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + */ +class Plex_Server_Library_Item_Media + implements Plex_Server_Library_Item_MediaInterface +{ + /** + * ID of the media info. + * @var integer + */ + private $id; + + /** + * Length of the file in milliseconds. + * @var integer + */ + private $duration; + + /** + * Bitrate of the file in kilobytes per second. + * @var integer + */ + private $bitrate; + + /** + * Width of the file's video in pixels. + * @var integer + */ + private $width; + + /** + * Height of the file's video in pixels. + * @var integer + */ + private $height; + + /** + * Aspect ration of the file's video. + * @var float + */ + private $aspectRatio; + + /** + * Resolution of the file's video. + * @var integer + */ + private $videoResolution; + + /** + * Container of the file. + * @var string + */ + private $container; + + /** + * Frame rate of the file's video. + * @var string + */ + private $videoFrameRate; + + /** + * The files associated with the item. + * @var Plex_Server_Library_Item_Media_File[] + */ + private $files; + + /** + * Sets an array of media info to their corresponding class members. + * + * @param array $rawMedia An array of the raw media info returned from the + * Plex HTTP API. + * + * @uses Plex_Server_Library_Item_Media::setId() + * @uses Plex_Server_Library_Item_Media::setDuration() + * @uses Plex_Server_Library_Item_Media::setBitrate() + * @uses Plex_Server_Library_Item_Media::setWidth() + * @uses Plex_Server_Library_Item_Media::setHeight() + * @uses Plex_Server_Library_Item_Media::setAspectRatio() + * @uses Plex_Server_Library_Item_Media::setVideoResolution() + * @uses Plex_Server_Library_Item_Media::setContainer() + * @uses Plex_Server_Library_Item_Media::setVideoFrameRate() + * @uses Plex_Server_Library_Item_Media::setFiles() + * @uses Plex_Server_Library_Item_Media_File() + * + * @return void + */ + public function __construct($rawMedia) + { + if (isset($rawMedia['id'])) { + $this->setId($rawMedia['id']); + } + if (isset($rawMedia['duration'])) { + $this->setDuration($rawMedia['duration']); + } + if (isset($rawMedia['bitrate'])) { + $this->setBitrate($rawMedia['bitrate']); + } + if (isset($rawMedia['width'])) { + $this->setWidth($rawMedia['width']); + } + if (isset($rawMedia['height'])) { + $this->setHeight($rawMedia['height']); + } + if (isset($rawMedia['aspectRatio'])) { + $this->setAspectRatio($rawMedia['aspectRatio']); + } + if (isset($rawMedia['videoResolution'])) { + $this->setVideoResolution($rawMedia['videoResolution']); + } + if (isset($rawMedia['container'])) { + $this->setContainer($rawMedia['container']); + } + if (isset($rawMedia['videoFrameRate'])) { + $this->setVideoFrameRate($rawMedia['videoFrameRate']); + } + + $files = array(); + foreach ($rawMedia['Part'] as $file) { + $files[] = new Plex_Server_Library_Item_Media_File($file); + } + + if (!empty($files)) { + $this->setFiles($files); + } + } + + /** + * Returns the ID of the media info. + * + * @uses Plex_Server_Library_Item_Media::$id + * + * @return integer The ID of the media info. + */ + public function getId() + { + return $this->id; + } + + /** + * Sets the ID of the media info. + * + * @param integer $id The ID of the media info. + * + * @uses Plex_Server_Library_Item_Media::$id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * Returns the length of the file. + * + * @uses Plex_Server_Library_Item_Media::$duration + * + * @return integer The length of the file. + */ + public function getDuration() + { + return $this->duration; + } + + /** + * Sets the length of the file. + * + * @param integer $duration The length of the file. + * + * @uses Plex_Server_Library_Item_Media::$duration + * + * @return void + */ + public function setDuration($duration) + { + $this->duration = $duration; + } + + /** + * Returns the bitrate of the file. + * + * @uses Plex_Server_Library_Item_Media::$bitrate + * + * @return integer The bitrate of the file. + */ + public function getBitrate() + { + return $this->bitrate; + } + + /** + * Sets the bitrate of the file. + * + * @param integer $bitrate The bitrate of the file. + * + * @uses Plex_Server_Library_Item_Media::$bitrate + * + * @return void + */ + public function setBitrate($bitrate) + { + $this->bitrate = $bitrate; + } + + /** + * Returns the width of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$width + * + * @return integer The width of the file's video. + */ + public function getWidth() + { + return $this->width; + } + + /** + * Sets the width of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$width + * + * @param integer $width The width of the file's video. + * + * @return void + */ + public function setWidth($width) + { + $this->width = $width; + } + + /** + * Returns the height of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$height + * + * @return integer The height of the file's video. + */ + public function getHeight() + { + return $this->height; + } + + /** + * Sets the height of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$height + * + * @param integer $height The height of the file's video. + * + * @return void + */ + public function setHeight($height) + { + $this->height = $height; + } + + /** + * Returns the aspect ratio of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$aspectRatio + * + * @return float The aspect ratio of the file's video. + */ + public function getAspectRatio() + { + return $this->aspectRatio; + } + + /** + * Sets the aspect ratio of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$aspectRatio + * + * @param float $aspectRatio The aspect ratio of the file's video. + * + * @return void + */ + public function setAspectRatio($aspectRatio) + { + $this->aspectRatio = $aspectRatio; + } + + /** + * Returns the video resolution of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$videoResolution + * + * @return integer The video resolution of the file's video. + */ + public function getVideoResolution() + { + return $this->videoResolution; + } + + /** + * Sets the video resolution of the file's video. + * + * @uses Plex_Server_Library_Item_Media::$videoResolution + * + * @param integer $videoResolution The video resolution of the file's video. + * + * @return void + */ + public function setVideoResolution($videoResolution) + { + $this->videoResolution = $videoResolution; + } + + /** + * Returns the container of the file. + * + * @uses Plex_Server_Library_Item_Media::$container + * + * @return string The container of the file. + */ + public function getContainer() + { + return $this->container; + } + + /** + * Sets the container of the file. + * + * @uses Plex_Server_Library_Item_Media::$container + * + * @param string $container The container of the file. + * + * @return void + */ + public function setContainer($container) + { + $this->container = $container; + } + + /** + * Returns the frame rate of the file's video + * + * @uses Plex_Server_Library_Item_Media::$videoFrameRate + * + * @return string The frame rate of the file's video. + */ + public function getVideoFrameRate() + { + return $this->videoFrameRate; + } + + /** + * Sets the frame rate of the file's video + * + * @uses Plex_Server_Library_Item_Media::$videoFrameRate + * + * @param string $videoFrameRate The frame rate of the file's video. + * + * @return void + */ + public function setVideoFrameRate($videoFrameRate) + { + $this->videoFrameRate = $videoFrameRate; + } + + /** + * Returns the files associated with the item. + * + * @uses Plex_Server_Library_Item_Media::$files + * + * @return Plex_Server_Library_Item_Media_File[] Array of media files. + */ + public function getFiles() + { + return $this->files; + } + + /** + * Sets the files associated with the item. + * + * @uses Plex_Server_Library_Item_Media::$files + * + * @param Plex_Server_Library_Item_Media_File[] $files Array of media files. + * + * @return void + */ + public function setFiles($files) + { + $this->files = $files; + } +} diff --git a/Server/Library/Item/Media/MediaInterface.php b/Server/Library/Item/Media/MediaInterface.php new file mode 100644 index 0000000..2e74f02 --- /dev/null +++ b/Server/Library/Item/Media/MediaInterface.php @@ -0,0 +1,199 @@ + Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + * + * This file is part of php-plex. + * + * php-plex is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * php-plex is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/** + * Interface that defines the structure of item media info. + * + * @category php-plex + * @package Plex_Server_Library + * @subpackage Plex_Server_Library_Item + * @author Nick Bartkowiak + * @copyright (c) 2013 Nick Bartkowiak + * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) + * @version 0.0.2.5 + */ +interface Plex_Server_Library_Item_MediaInterface +{ + /** + * Returns the ID of the media info. + * + * @return integer The ID of the media info. + */ + public function getId(); + + /** + * Sets the ID of the media info. + * + * @param integer $id The ID of the media info. + * + * @return void + */ + public function setId($id); + + /** + * Returns the length of the file. + * + * @return integer The length of the file. + */ + public function getDuration(); + + /** + * Sets the length of the file. + * + * @param integer $duration The length of the file. + * + * @return void + */ + public function setDuration($duration); + + /** + * Returns the bitrate of the file. + * + * @return integer The bitrate of the file. + */ + public function getBitrate(); + + /** + * Sets the bitrate of the file. + * + * @param integer $bitrate The bitrate of the file. + * + * @return void + */ + public function setBitrate($bitrate); + + /** + * Returns the width of the file's video. + * + * @return integer The width of the file's video. + */ + public function getWidth(); + + /** + * Sets the width of the file's video. + * + * @param integer $width The width of the file's video. + * + * @return void + */ + public function setWidth($width); + + /** + * Returns the height of the file's video. + * + * @return integer The height of the file's video. + */ + public function getHeight(); + + /** + * Sets the height of the file's video. + * + * @param integer $height The height of the file's video. + * + * @return void + */ + public function setHeight($height); + + /** + * Returns the aspect ratio of the file's video. + * + * @return float The aspect ratio of the file's video. + */ + public function getAspectRatio(); + + /** + * Sets the aspect ratio of the file's video. + * + * @param float $aspectRatio The aspect ratio of the file's video. + * + * @return void + */ + public function setAspectRatio($aspectRatio); + + /** + * Returns the video resolution of the file's video. + * + * @return integer The video resolution of the file's video. + */ + public function getVideoResolution(); + + /** + * Sets the video resolution of the file's video. + * + * @param integer $videoResolution The video resolution of the file's video. + * + * @return void + */ + public function setVideoResolution($videoResolution); + + /** + * Returns the container of the file. + * + * @return string The container of the file. + */ + public function getContainer(); + + /** + * Sets the container of the file. + * + * @param string $container The container of the file. + * + * @return void + */ + public function setContainer($container); + + /** + * Returns the frame rate of the file's video + * + * @return string The frame rate of the file's video. + */ + public function getVideoFrameRate(); + + /** + * Sets the frame rate of the file's video + * + * @param string $videoFrameRate The frame rate of the file's video. + * + * @return void + */ + public function setVideoFrameRate($videoFrameRate); + + /** + * Returns the files associated with the item. + * + * @return Plex_Server_Library_Item_Media_File[] Array of media files. + */ + public function getFiles(); + + /** + * Sets the files associated with the item. + * + * @param Plex_Server_Library_Item_Media_File[] $files Array of media files. + * + * @return void + */ + public function setFiles($files); +} diff --git a/Server/Library/ItemAbstract.php b/Server/Library/ItemAbstract.php index 8173dd5..49199d7 100644 --- a/Server/Library/ItemAbstract.php +++ b/Server/Library/ItemAbstract.php @@ -9,7 +9,7 @@ * @author Nick Bartkowiak * @copyright (c) 2012 Nick Bartkowiak * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) - * @version 0.0.1 + * @version 0.0.2.5 * * This file is part of php-plex. * @@ -34,7 +34,7 @@ * @author Nick Bartkowiak * @copyright (c) 2012 Nick Bartkowiak * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3) - * @version 0.0.1 + * @version 0.0.2.5 */ abstract class Plex_Server_Library_ItemAbstract extends Plex_Server_Library_SectionAbstract @@ -113,6 +113,12 @@ abstract class Plex_Server_Library_ItemAbstract */ protected $updatedAt; + /** + * The media info associated with a Plex item. + * @var Plex_Server_Library_Item_Media + */ + protected $media; + /** * Endpoint for listing the child items of a parent or grandparent item. */ @@ -142,6 +148,7 @@ abstract class Plex_Server_Library_ItemAbstract * @uses Plex_Server_Library_ItemAbstract::setThumb() * @uses Plex_Server_Library_ItemAbstract::setAddedAt() * @uses Plex_Server_Library_ItemAbstract::setUpdatedAt() + * @uses Plex_Server_Library_ItemAbstract::setMedia() * * @return void */ @@ -183,6 +190,9 @@ public function setAttributes($attribute) if (isset($attribute['updatedAt'])) { $this->setUpdatedAt($attribute['updatedAt']); } + if (isset($attribute['Media'])) { + $this->setMedia($attribute['Media']); + } } /** @@ -635,4 +645,33 @@ public function setUpdatedAt($updatedAtTs) $updatedAt = new DateTime(sprintf('@%s', $updatedAtTs)); $this->updatedAt = $updatedAt; } + + /** + * Returns the media info of the item. + * + * @uses Plex_Server_Library_ItemAbstract::$media + * + * @return Plex_Server_Library_Item_Media THe media info of the item. + */ + public function getMedia() + { + return $this->media; + } + + /** + * Sets the media info of the item. + * + * @uses Plex_Server_Library_Item_Media() + * @uses Plex_Server_Library_ItemAbstract::$media + * + * @param string $media Raw media info that is to be converted into a media + * info object. + * + * @return void + */ + public function setMedia($media) + { + $mediaObject = new Plex_Server_Library_Item_Media(reset($media)); + $this->media = $mediaObject; + } }