@@ -106,12 +106,12 @@ abstract class Plex_Server_Library_SectionAbstract extends Plex_Server_Library
106106 protected $ createdAt ;
107107
108108 /**
109- * Endpoint for retrieiving all items for a section.
109+ * Endpoint for retrieving all items for a section.
110110 */
111111 const ENDPOINT_CATEGORY_ALL = 'all ' ;
112112
113113 /**
114- * Endpoint for retrieiving all unwatched items for a section.
114+ * Endpoint for retrieving all unwatched items for a section.
115115 */
116116 const ENDPOINT_CATEGORY_UNWATCHED = 'unwatched ' ;
117117
@@ -151,10 +151,40 @@ abstract class Plex_Server_Library_SectionAbstract extends Plex_Server_Library
151151 const ENDPOINT_CATEGORY_GENRE = 'genre ' ;
152152
153153 /**
154- * Endpoint for retrieiving items for a sectoin by year.
154+ * Endpoint for retrieiving items for a section by year.
155155 */
156156 const ENDPOINT_CATEGORY_YEAR = 'year ' ;
157157
158+ /**
159+ * Endpoing for searching a section for items.
160+ */
161+ const ENDPOINT_SEARCH = 'search ' ;
162+
163+ /**
164+ * Parameter for searching movies.
165+ */
166+ const SEARCH_TYPE_MOVIE = 1 ;
167+
168+ /**
169+ * Parameter for searching television shows.
170+ */
171+ const SEARCH_TYPE_SHOW = 2 ;
172+
173+ /**
174+ * Parameter for searching teleivision episodes.
175+ */
176+ const SEARCH_TYPE_EPISODE = 4 ;
177+
178+ /**
179+ * Parameter for searching artists.
180+ */
181+ const SEARCH_TYPE_ARTIST = 8 ;
182+
183+ /**
184+ * Parameter for searching tracks.
185+ */
186+ const SEARCH_TYPE_TRACK = 10 ;
187+
158188 /**
159189 * Adds the attributes to the object if they exist.
160190 *
@@ -220,7 +250,7 @@ public function setAttributes($attribute)
220250 * @uses Plex_Server_Library::ENDPOINT_SECTION
221251 * @uses Plex_Server_Library_SectionAbstract::getKey()
222252 *
223- * @return void
253+ * @return string The requested endpoint.
224254 */
225255 protected function buildEndpoint ($ endpoint )
226256 {
@@ -232,6 +262,30 @@ protected function buildEndpoint($endpoint)
232262 );
233263 }
234264
265+ /**
266+ * Builds an endpoint to search a Plex library section.
267+ *
268+ * @param integer $type The type of item to be searched.
269+ * @param string $query The string of text against which the search will be
270+ * run.
271+ *
272+ * @uses Plex_Server_Library_SectionAbstract::ENDPOINT_SEARCH
273+ * @uses Plex_Server_Library_SectionAbstract::buildEndpoint()
274+ *
275+ * @return string The requested search endpoint.
276+ */
277+ protected function buildSearchEndpoint ($ type , $ query )
278+ {
279+ $ endpoint = sprintf (
280+ '%s?type=%d&query=%s ' ,
281+ self ::ENDPOINT_SEARCH ,
282+ $ type ,
283+ trim ($ query )
284+ );
285+
286+ return $ this ->buildEndpoint ($ endpoint );
287+ }
288+
235289 /**
236290 * Generic method allowing a child class to retrieve all items for its
237291 * section.
0 commit comments