add .searchAudio method to PlexServer, to specifically search for audio

This commit is contained in:
Håvard Gulldahl 2016-01-28 13:09:36 +01:00
parent e437e857cd
commit 0229226448

View file

@ -4,7 +4,7 @@ PlexServer
import requests
from requests.status_codes import _codes as codes
from plexapi import BASE_HEADERS, TIMEOUT
from plexapi import log, video
from plexapi import log, video, audio
from plexapi.client import Client
from plexapi.exceptions import BadRequest, NotFound
from plexapi.library import Library
@ -99,6 +99,13 @@ class PlexServer(object):
return [item for item in items if item.type == mediatype]
return items
def searchAudio(self, query, mediatype=None):
query = quote(query)
items = audio.list_items(self, '/search?query=%s' % query)
if mediatype:
return [item for item in items if item.type == mediatype]
return items
def sessions(self):
return video.list_items(self, '/status/sessions')