@@ -106,12 +106,12 @@ abstract class Plex_Server_Library_SectionAbstract extends Plex_Server_Library
106
106
protected $ createdAt ;
107
107
108
108
/**
109
- * Endpoint for retrieiving all items for a section.
109
+ * Endpoint for retrieving all items for a section.
110
110
*/
111
111
const ENDPOINT_CATEGORY_ALL = 'all ' ;
112
112
113
113
/**
114
- * Endpoint for retrieiving all unwatched items for a section.
114
+ * Endpoint for retrieving all unwatched items for a section.
115
115
*/
116
116
const ENDPOINT_CATEGORY_UNWATCHED = 'unwatched ' ;
117
117
@@ -151,10 +151,40 @@ abstract class Plex_Server_Library_SectionAbstract extends Plex_Server_Library
151
151
const ENDPOINT_CATEGORY_GENRE = 'genre ' ;
152
152
153
153
/**
154
- * Endpoint for retrieiving items for a sectoin by year.
154
+ * Endpoint for retrieiving items for a section by year.
155
155
*/
156
156
const ENDPOINT_CATEGORY_YEAR = 'year ' ;
157
157
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
+
158
188
/**
159
189
* Adds the attributes to the object if they exist.
160
190
*
@@ -220,7 +250,7 @@ public function setAttributes($attribute)
220
250
* @uses Plex_Server_Library::ENDPOINT_SECTION
221
251
* @uses Plex_Server_Library_SectionAbstract::getKey()
222
252
*
223
- * @return void
253
+ * @return string The requested endpoint.
224
254
*/
225
255
protected function buildEndpoint ($ endpoint )
226
256
{
@@ -232,6 +262,30 @@ protected function buildEndpoint($endpoint)
232
262
);
233
263
}
234
264
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
+
235
289
/**
236
290
* Generic method allowing a child class to retrieve all items for its
237
291
* section.
0 commit comments