|
9 | 9 | * @author <[email protected]> Nick Bartkowiak
|
10 | 10 | * @copyright (c) 2012 Nick Bartkowiak
|
11 | 11 | * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
|
12 |
| - * @version 0.0.2.5 |
| 12 | + * @version 0.0.2.6 |
13 | 13 | *
|
14 | 14 | * This file is part of php-plex.
|
15 | 15 | *
|
@@ -124,6 +124,36 @@ abstract class Plex_Server_Library_ItemAbstract
|
124 | 124 | * @var Plex_Server_Library_Item_Media
|
125 | 125 | */
|
126 | 126 | protected $media;
|
| 127 | + /** |
| 128 | + * The genres info associated with a Plex item. |
| 129 | + * @var Plex_Server_Library_Item_Genre[] |
| 130 | + */ |
| 131 | + protected $genres; |
| 132 | + /** |
| 133 | + * The director info associated with a Plex item. |
| 134 | + * @var Plex_Server_Library_Item_Tag |
| 135 | + */ |
| 136 | + protected $director; |
| 137 | + /** |
| 138 | + * The writer info associated with a Plex item. |
| 139 | + * @var Plex_Server_Library_Item_Tag |
| 140 | + */ |
| 141 | + protected $writer; |
| 142 | + /** |
| 143 | + * The producer info associated with a Plex item. |
| 144 | + * @var Plex_Server_Library_Item_Tag |
| 145 | + */ |
| 146 | + protected $producer; |
| 147 | + /** |
| 148 | + * The country info associated with a Plex item. |
| 149 | + * @var Plex_Server_Library_Item_Tag |
| 150 | + */ |
| 151 | + protected $country; |
| 152 | + /** |
| 153 | + * The roles info associated with a Plex item. |
| 154 | + * @var Plex_Server_Library_Item_Tag[] |
| 155 | + */ |
| 156 | + protected $roles; |
127 | 157 |
|
128 | 158 | /**
|
129 | 159 | * Endpoint for listing the child items of a parent or grandparent item.
|
@@ -156,6 +186,12 @@ abstract class Plex_Server_Library_ItemAbstract
|
156 | 186 | * @uses Plex_Server_Library_ItemAbstract::setUpdatedAt()
|
157 | 187 | * @uses Plex_Server_Library_ItemAbstract::setViewCount()
|
158 | 188 | * @uses Plex_Server_Library_ItemAbstract::setMedia()
|
| 189 | + * @uses Plex_Server_Library_ItemAbstract::setGenres() |
| 190 | + * @uses Plex_Server_Library_ItemAbstract::setDirector() |
| 191 | + * @uses Plex_Server_Library_ItemAbstract::setWriter() |
| 192 | + * @uses Plex_Server_Library_ItemAbstract::setProducer() |
| 193 | + * @uses Plex_Server_Library_ItemAbstract::setCountry() |
| 194 | + * @uses Plex_Server_Library_ItemAbstract::setRoles() |
159 | 195 | *
|
160 | 196 | * @return void
|
161 | 197 | */
|
@@ -203,6 +239,24 @@ public function setAttributes($attribute)
|
203 | 239 | if (isset($attribute['Media'])) {
|
204 | 240 | $this->setMedia($attribute['Media']);
|
205 | 241 | }
|
| 242 | + if (isset($attribute['Genre'])) { |
| 243 | + $this->setGenres($attribute['Genre']); |
| 244 | + } |
| 245 | + if (isset($attribute['Director'])) { |
| 246 | + $this->setDirector($attribute['Director']); |
| 247 | + } |
| 248 | + if (isset($attribute['Writer'])) { |
| 249 | + $this->setWriter($attribute['Writer']); |
| 250 | + } |
| 251 | + if (isset($attribute['Producer'])) { |
| 252 | + $this->setProducer($attribute['Producer']); |
| 253 | + } |
| 254 | + if (isset($attribute['Country'])) { |
| 255 | + $this->setCountry($attribute['Country']); |
| 256 | + } |
| 257 | + if (isset($attribute['Role'])) { |
| 258 | + $this->setRoles($attribute['Role']); |
| 259 | + } |
206 | 260 | }
|
207 | 261 |
|
208 | 262 | /**
|
@@ -340,6 +394,20 @@ public static function factory($type, $name, $address, $port, $token)
|
340 | 394 | return new $class($name, $address, $port, $token);
|
341 | 395 | }
|
342 | 396 |
|
| 397 | + /** |
| 398 | + * Build a url with access to the thumbnail image. |
| 399 | + * |
| 400 | + * @uses Plex_MachineAbstract::$getBaseUrl() |
| 401 | + * @uses Plex_Server_Library_ItemAbstract::$thumb |
| 402 | + * @uses Plex::$token |
| 403 | + * |
| 404 | + * @return string An url with access the thumbnail image. |
| 405 | + */ |
| 406 | + public function buildUrlThumb() |
| 407 | + { |
| 408 | + return $this->getBaseUrl().$this->thumb.'?X-Plex-Token='.$this->token; |
| 409 | + } |
| 410 | + |
343 | 411 | /**
|
344 | 412 | * Says whether or not the item is available for sync.
|
345 | 413 | *
|
@@ -710,4 +778,186 @@ public function setMedia($media)
|
710 | 778 | $mediaObject = new Plex_Server_Library_Item_Media(reset($media));
|
711 | 779 | $this->media = $mediaObject;
|
712 | 780 | }
|
| 781 | + |
| 782 | + /** |
| 783 | + * Returns the genres info of the item. |
| 784 | + * |
| 785 | + * @uses Plex_Server_Library_ItemAbstract::$genres |
| 786 | + * |
| 787 | + * @return Plex_Server_Library_Item_Tag The genres info of the item. |
| 788 | + */ |
| 789 | + public function getGenres() |
| 790 | + { |
| 791 | + return $this->genres; |
| 792 | + } |
| 793 | + |
| 794 | + /** |
| 795 | + * Sets the genres info of the item. |
| 796 | + * |
| 797 | + * @uses Plex_Server_Library_Item_Tag() |
| 798 | + * @uses Plex_Server_Library_ItemAbstract::$genres |
| 799 | + * |
| 800 | + * @param string $genres Raw genres info that is to be converted into a genres |
| 801 | + * info object. |
| 802 | + * |
| 803 | + * @return void |
| 804 | + */ |
| 805 | + public function setGenres($genres) |
| 806 | + { |
| 807 | + $genresObject = array(); |
| 808 | + foreach ($genres as $genre) { |
| 809 | + $genresObject[] = new Plex_Server_Library_Item_Tag($genre); |
| 810 | + } |
| 811 | + |
| 812 | + $this->genres = $genresObject; |
| 813 | + } |
| 814 | + |
| 815 | + /** |
| 816 | + * Returns the director info of the item. |
| 817 | + * |
| 818 | + * @uses Plex_Server_Library_ItemAbstract::$director |
| 819 | + * |
| 820 | + * @return Plex_Server_Library_Item_Tag The director info of the item. |
| 821 | + */ |
| 822 | + public function getDirector() |
| 823 | + { |
| 824 | + return $this->director; |
| 825 | + } |
| 826 | + |
| 827 | + /** |
| 828 | + * Sets the director info of the item. |
| 829 | + * |
| 830 | + * @uses Plex_Server_Library_Item_Tag() |
| 831 | + * @uses Plex_Server_Library_ItemAbstract::$director |
| 832 | + * |
| 833 | + * @param string $director Raw director info that is to be converted into a director |
| 834 | + * info object. |
| 835 | + * |
| 836 | + * @return void |
| 837 | + */ |
| 838 | + public function setDirector($director) |
| 839 | + { |
| 840 | + $directorObject = new Plex_Server_Library_Item_Tag(reset($director)); |
| 841 | + $this->director = $directorObject; |
| 842 | + } |
| 843 | + |
| 844 | + /** |
| 845 | + * Returns the writer info of the item. |
| 846 | + * |
| 847 | + * @uses Plex_Server_Library_ItemAbstract::$writer |
| 848 | + * |
| 849 | + * @return Plex_Server_Library_Item_Tag The writer info of the item. |
| 850 | + */ |
| 851 | + public function getWriter() |
| 852 | + { |
| 853 | + return $this->writer; |
| 854 | + } |
| 855 | + |
| 856 | + /** |
| 857 | + * Sets the writer info of the item. |
| 858 | + * |
| 859 | + * @uses Plex_Server_Library_Item_Tag() |
| 860 | + * @uses Plex_Server_Library_ItemAbstract::$writer |
| 861 | + * |
| 862 | + * @param string $writer Raw writer info that is to be converted into a writer |
| 863 | + * info object. |
| 864 | + * |
| 865 | + * @return void |
| 866 | + */ |
| 867 | + public function setWriter($writer) |
| 868 | + { |
| 869 | + $writerObject = new Plex_Server_Library_Item_Tag(reset($writer)); |
| 870 | + $this->writer = $writerObject; |
| 871 | + } |
| 872 | + |
| 873 | + /** |
| 874 | + * Returns the producer info of the item. |
| 875 | + * |
| 876 | + * @uses Plex_Server_Library_ItemAbstract::$producer |
| 877 | + * |
| 878 | + * @return Plex_Server_Library_Item_Tag The producer info of the item. |
| 879 | + */ |
| 880 | + public function getProducer() |
| 881 | + { |
| 882 | + return $this->producer; |
| 883 | + } |
| 884 | + |
| 885 | + /** |
| 886 | + * Sets the producer info of the item. |
| 887 | + * |
| 888 | + * @uses Plex_Server_Library_Item_Tag() |
| 889 | + * @uses Plex_Server_Library_ItemAbstract::$producer |
| 890 | + * |
| 891 | + * @param string $producer Raw producer info that is to be converted into a producer |
| 892 | + * info object. |
| 893 | + * |
| 894 | + * @return void |
| 895 | + */ |
| 896 | + public function setProducer($producer) |
| 897 | + { |
| 898 | + $producerObject = new Plex_Server_Library_Item_Tag(reset($producer)); |
| 899 | + $this->producer = $producerObject; |
| 900 | + } |
| 901 | + |
| 902 | + /** |
| 903 | + * Returns the country info of the item. |
| 904 | + * |
| 905 | + * @uses Plex_Server_Library_ItemAbstract::$country |
| 906 | + * |
| 907 | + * @return Plex_Server_Library_Item_Tag The country info of the item. |
| 908 | + */ |
| 909 | + public function getCountry() |
| 910 | + { |
| 911 | + return $this->country; |
| 912 | + } |
| 913 | + |
| 914 | + /** |
| 915 | + * Sets the country info of the item. |
| 916 | + * |
| 917 | + * @uses Plex_Server_Library_Item_Tag() |
| 918 | + * @uses Plex_Server_Library_ItemAbstract::$country |
| 919 | + * |
| 920 | + * @param string $country Raw country info that is to be converted into a country |
| 921 | + * info object. |
| 922 | + * |
| 923 | + * @return void |
| 924 | + */ |
| 925 | + public function setCountry($country) |
| 926 | + { |
| 927 | + $countryObject = new Plex_Server_Library_Item_Tag(reset($country)); |
| 928 | + $this->country = $countryObject; |
| 929 | + } |
| 930 | + |
| 931 | + /** |
| 932 | + * Returns the roles info of the item. |
| 933 | + * |
| 934 | + * @uses Plex_Server_Library_ItemAbstract::$roles |
| 935 | + * |
| 936 | + * @return Plex_Server_Library_Item_Tag THe roles info of the item. |
| 937 | + */ |
| 938 | + public function getRoles() |
| 939 | + { |
| 940 | + return $this->roles; |
| 941 | + } |
| 942 | + |
| 943 | + /** |
| 944 | + * Sets the roles info of the item. |
| 945 | + * |
| 946 | + * @uses Plex_Server_Library_Item_Tag() |
| 947 | + * @uses Plex_Server_Library_ItemAbstract::$roles |
| 948 | + * |
| 949 | + * @param string $roles Raw roles info that is to be converted into a roles |
| 950 | + * info object. |
| 951 | + * |
| 952 | + * @return void |
| 953 | + */ |
| 954 | + public function setRoles($roles) |
| 955 | + { |
| 956 | + $rolesObject = array(); |
| 957 | + foreach ($roles as $role) { |
| 958 | + $rolesObject[] = new Plex_Server_Library_Item_Tag($role); |
| 959 | + } |
| 960 | + |
| 961 | + $this->roles = $rolesObject; |
| 962 | + } |
713 | 963 | }
|
0 commit comments