mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
parent
eb1e508638
commit
1f8cd6d5b7
2 changed files with 13 additions and 0 deletions
|
@ -46,6 +46,9 @@ class Library(object):
|
|||
def get(self, title):
|
||||
return video.find_item(self.server, '/library/all', title)
|
||||
|
||||
def getByKey(self, key):
|
||||
return video.find_key(self.server, key)
|
||||
|
||||
def search(self, title, filter='all', vtype=None, **tags):
|
||||
""" Search all available content.
|
||||
title: Title to search (pass None to search all titles).
|
||||
|
|
|
@ -215,6 +215,16 @@ def build_item(server, elem, initpath):
|
|||
raise UnknownType('Unknown video type: %s' % vtype)
|
||||
|
||||
|
||||
def find_key(server, key):
|
||||
path = '/library/metadata/{0}'.format(key)
|
||||
try:
|
||||
# Video seems to be the first sub element
|
||||
elem = server.query(path)[0]
|
||||
return build_item(server, elem, path)
|
||||
except:
|
||||
raise NotFound('Unable to find key: %s' % key)
|
||||
|
||||
|
||||
def find_item(server, path, title):
|
||||
for elem in server.query(path):
|
||||
if elem.attrib.get('title').lower() == title.lower():
|
||||
|
|
Loading…
Reference in a new issue