Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit 4f47b49

Browse files
committed
Added in the show section class.
1 parent adbb966 commit 4f47b49

File tree

1 file changed

+249
-0
lines changed

1 file changed

+249
-0
lines changed

Server/Library/Section/Show.php

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
<?php
2+
3+
/**
4+
* Plex Server Library Show Section
5+
*
6+
* @category php-plex
7+
* @package Plex_Server
8+
* @subpackage Plex_Server_Library
9+
* @author <[email protected]> Nick Bartkowiak
10+
* @copyright (c) 2012 Nick Bartkowiak
11+
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
12+
* @version 0.0.1
13+
*
14+
* This file is part of php-plex.
15+
*
16+
* php-plex is free software: you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation, either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* php-plex is distributed in the hope that it will be useful,
22+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+
* GNU General Public License for more details.
25+
*/
26+
27+
/**
28+
* Class that represents a Plex library show section and allows retrieval of
29+
* Plex library shows and their seasons and episodes.
30+
*
31+
* @category php-plex
32+
* @package Plex_Server
33+
* @subpackage Plex_Server_Library
34+
* @author <[email protected]> Nick Bartkowiak
35+
* @copyright (c) 2012 Nick Bartkowiak
36+
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
37+
* @version 0.0.1
38+
*/
39+
class Plex_Server_Library_Section_Show
40+
extends Plex_Server_Library_SectionAbstract
41+
{
42+
/**
43+
* Endpoint for retrieving recently viewed shows.
44+
*/
45+
const ENDPOINT_CATEGORY_RECENTLY_VIEWED_SHOWS = 'recentlyViewedShows';
46+
47+
/**
48+
* Endpoint for retrieving shows by content rating.
49+
*/
50+
const ENDPOINT_CATEGORY_CONTENT_RATING = 'contentRating';
51+
52+
/**
53+
* Returns all the shows for the given section.
54+
*
55+
* @uses Plex_Server_Library_SectionAbstract::getAllItems()
56+
*
57+
* @return Plex_Server_Library_Item_Show[] An array of shows.
58+
*/
59+
public function getAllShows()
60+
{
61+
return $this->getAllItems();
62+
}
63+
64+
/**
65+
* Returns all the unwatched shows for the given section.
66+
*
67+
* @uses Plex_Server_Library_SectionAbstract::getUnwatchedItems()
68+
*
69+
* @return Plex_Server_Library_Item_Show[] An array of shows.
70+
*/
71+
public function getUnwatchedShows()
72+
{
73+
return $this->getUnwatchedItems();
74+
}
75+
76+
/**
77+
* Returns the recently aired episodes for the given section.
78+
*
79+
* @uses Plex_Server_Library_SectionAbstract::getNewestItems()
80+
*
81+
* @return Plex_Server_Library_Item_Episode[] An array of episodes.
82+
*/
83+
public function getRecentlyAiredEpisodes()
84+
{
85+
return $this->getNewestItems();
86+
}
87+
88+
/**
89+
* Returns the recently added episodes for the given section.
90+
*
91+
* @uses Plex_Server_Library_SectionAbstract::getRecentlyAddedSectionItems()
92+
*
93+
* @return Plex_Server_Library_Item_Episode[] An array of episodes.
94+
*/
95+
public function getRecentlyAddedEpisodes()
96+
{
97+
return $this->getRecentlyAddedSectionItems();
98+
}
99+
100+
/**
101+
* Returns the recently viewed episodes for the given section.
102+
*
103+
* @uses Plex_Server_Library_SectionAbstract::getRecentlyViewedItems()
104+
*
105+
* @return Plex_Server_Library_Item_Episode[] An array of episodes.
106+
*/
107+
public function getRecentlyViewedEpisodes()
108+
{
109+
return $this->getRecentlyViewedItems();
110+
}
111+
112+
/**
113+
* Returns the recently viewed shows for the given section.
114+
*
115+
* @uses Plex_Server_Library::getItems()
116+
* @uses Plex_Server_Library_SectionAbstract::buildEndpoint()
117+
* @uses Plex_Server_Library_Section_Show::ENDPOINT_CATEGORY_RECENTLY_VIEWED_SHOWS
118+
*
119+
* @return Plex_Server_Library_Item_Show[] An array of shows.
120+
*/
121+
public function getRecentlyViewedShows()
122+
{
123+
return $this->getItems(
124+
$this->buildEndpoint(self::ENDPOINT_CATEGORY_RECENTLY_VIEWED_SHOWS)
125+
);
126+
}
127+
128+
/**
129+
* Returns the on deck episodes for the given section.
130+
*
131+
* @uses Plex_Server_Library_SectionAbstract::getOnDeckItems()
132+
*
133+
* @return Plex_Server_Library_Item_Episode[] An array of episodes.
134+
*/
135+
public function getOnDeckEpisodes()
136+
{
137+
return $this->getOnDeckSectionItems();
138+
}
139+
140+
/**
141+
* Returns all the shows contained in a given collection.
142+
*
143+
* @param integer $collectionKey Key that represents the collection by which
144+
* the shows will be retrieved. The genre key can be discovered by using
145+
* the getGenres() method from the parent class.
146+
*
147+
* @uses Plex_Server_Library_SectionAbstract::getItemsByCollection()
148+
*
149+
* @return Plex_Server_Library_Item_Show[] An array of shows.
150+
*/
151+
public function getShowsByCollection($collectionKey)
152+
{
153+
return $this->getItemsByCollection($collectionKey);
154+
}
155+
156+
/**
157+
* Returns all shows in the section whose titles start with the given
158+
* character.
159+
*
160+
* @param string $character The first character by which the movies will be
161+
* retrieved.
162+
*
163+
* @uses Plex_Server_Library_SectionAbstract::getItemsByFirstCharacter()
164+
*
165+
* @return Plex_Server_Library_Item_Show[] An array of shows.
166+
*/
167+
public function getShowsByFirstCharacter($character)
168+
{
169+
return $this->getItemsByFirstCharacter($character);
170+
}
171+
172+
/**
173+
* Returns all the shows categorized under a given genre.
174+
*
175+
* @param integer $genreKey Key that represents the genre by which the
176+
* shows will be retrieved. The genre key can be discovered by using the
177+
* getGenres() method from the parent class.
178+
*
179+
* @uses Plex_Server_Library_SectionAbstract::getItemsByGenre()
180+
*
181+
* @return Plex_Server_Library_Item_Show[] An array of shows.
182+
*/
183+
public function getShowsByGenre($genreKey)
184+
{
185+
return $this->getItemsByGenre($genreKey);
186+
}
187+
188+
/**
189+
* Returns all the shows from a given four digit year.
190+
*
191+
* @param integer $year Four digit year by which the shows will be
192+
* retrieved.
193+
*
194+
* @uses Plex_Server_Library_SectionAbstract::getItemsByYear()
195+
*
196+
* @return Plex_Server_Library_Item_Show[] An array of shows.
197+
*/
198+
public function getShowsByYear($year)
199+
{
200+
return $this->getItemsByYear($year);
201+
}
202+
203+
/**
204+
* Returns all the shows categorized under a given content rating.
205+
*
206+
* @param string $contentRating The content rating under which requested
207+
* shows are categorized. Valid content ratings can be discovered by using
208+
* the getContentRatings() method from this class.
209+
*
210+
* @uses Plex_Server_Library::getItems()
211+
* @uses Plex_Server_Library_SectionAbstract::buildEndpoint()
212+
* @uses Plex_Server_Library_Section_Artist::ENDPOINT_CATEGORY_CONTENT_RATING
213+
*
214+
* @return Plex_Server_Library_Item_Show[] An array of shows.
215+
*/
216+
public function getShowsByContentRating($contentRating)
217+
{
218+
return $this->getItems(
219+
$this->buildEndpoint(
220+
sprintf(
221+
'%s/%s',
222+
self::ENDPOINT_CATEGORY_CONTENT_RATING,
223+
$contentRating
224+
)
225+
)
226+
);
227+
}
228+
229+
/**
230+
* Returns a list of content ratings for the section. We use makeCall
231+
* directly here because we want to return just the raw array of content
232+
* ratings and not do any post processing on it.
233+
*
234+
* @uses Plex_MachineAbstract::makeCall()
235+
* @uses Plex_Server_Library::buildUrl()
236+
* @uses Plex_Server_Library_SectionAbstract::buildEndpoint()
237+
* @uses Plex_Server_Library_SectionAbstract::ENDPOINT_CATEGORY_CONTENT_RATING
238+
*
239+
* @return array An array of content ratings with their names and keys.
240+
*/
241+
public function getContentRatings()
242+
{
243+
return $this->makeCall(
244+
$this->buildUrl(
245+
$this->buildEndpoint(self::ENDPOINT_CATEGORY_CONTENT_RATING)
246+
)
247+
);
248+
}
249+
}

0 commit comments

Comments
 (0)