mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Rename variable to kwargs
This commit is contained in:
parent
f676d4cbbf
commit
76c0cb55a1
5 changed files with 25 additions and 25 deletions
|
@ -103,10 +103,10 @@ class Artist(Audio):
|
|||
key = '%s/children' % self.key
|
||||
return self.fetchItem(key, title=title)
|
||||
|
||||
def albums(self, **attrs):
|
||||
def albums(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.audio.Album` objects by this artist. """
|
||||
key = '%s/children' % self.key
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def track(self, title):
|
||||
""" Returns the :class:`~plexapi.audio.Track` that matches the specified title.
|
||||
|
@ -117,10 +117,10 @@ class Artist(Audio):
|
|||
key = '%s/allLeaves' % self.key
|
||||
return self.fetchItem(key, title=title)
|
||||
|
||||
def tracks(self, **attrs):
|
||||
def tracks(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.audio.Track` objects by this artist. """
|
||||
key = '%s/allLeaves' % self.key
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def get(self, title):
|
||||
""" Alias of :func:`~plexapi.audio.Artist.track`. """
|
||||
|
@ -192,10 +192,10 @@ class Album(Audio):
|
|||
key = '%s/children' % self.key
|
||||
return self.fetchItem(key, title=title)
|
||||
|
||||
def tracks(self, **attrs):
|
||||
def tracks(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.audio.Track` objects in this album. """
|
||||
key = '%s/children' % self.key
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def get(self, title):
|
||||
""" Alias of :func:`~plexapi.audio.Album.track`. """
|
||||
|
|
|
@ -73,31 +73,31 @@ class PlexObject(object):
|
|||
items.append(self._buildItemOrNone(elem, cls, initpath, bytag))
|
||||
return [item for item in items if item]
|
||||
|
||||
def fetchItem(self, key, cls=None, bytag=False, tag=None, **attrs):
|
||||
def fetchItem(self, key, cls=None, bytag=False, tag=None, **kwargs):
|
||||
""" Load the specified key to find and build the first item with the
|
||||
specified tag and attrs. If no tag or attrs are specified then
|
||||
the first item in the result set is returned.
|
||||
"""
|
||||
for elem in self._root._query(key):
|
||||
if tag and elem.tag != tag or not self._checkAttrs(elem, **attrs):
|
||||
if tag and elem.tag != tag or not self._checkAttrs(elem, **kwargs):
|
||||
continue
|
||||
return self._buildItem(elem, cls, key, bytag)
|
||||
raise NotFound('Unable to find elem: tag=%s, attrs=%s' % (tag, attrs))
|
||||
raise NotFound('Unable to find elem: tag=%s, attrs=%s' % (tag, kwargs))
|
||||
|
||||
def fetchItems(self, key, cls=None, bytag=False, tag=None, **attrs):
|
||||
def fetchItems(self, key, cls=None, bytag=False, tag=None, **kwargs):
|
||||
""" Load the specified key to find and build all items with the
|
||||
specified tag and attrs.
|
||||
"""
|
||||
items = []
|
||||
for elem in self._root._query(key):
|
||||
if tag and elem.tag != tag or not self._checkAttrs(elem, **attrs):
|
||||
if tag and elem.tag != tag or not self._checkAttrs(elem, **kwargs):
|
||||
continue
|
||||
items.append(self._buildItemOrNone(elem, cls, key, bytag))
|
||||
return [item for item in items if item]
|
||||
|
||||
def _checkAttrs(self, elem, **attrs):
|
||||
def _checkAttrs(self, elem, **kwargs):
|
||||
# TODO: Implement opterations
|
||||
if not all(elem.attrib.get(a,'').lower() == str(v).lower() for a,v in attrs.items()):
|
||||
if not all(elem.attrib.get(a,'').lower() == str(v).lower() for a,v in kwargs.items()):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -72,11 +72,11 @@ class Library(PlexObject):
|
|||
self.sections()
|
||||
return self._sectionsByID[sectionID]
|
||||
|
||||
def all(self, **attrs):
|
||||
def all(self, **kwargs):
|
||||
""" Returns a list of all media from all library sections.
|
||||
This may be a very large dataset to retrieve.
|
||||
"""
|
||||
return [item for section in self.sections() for item in section.all(**attrs)]
|
||||
return [item for section in self.sections() for item in section.all(**kwargs)]
|
||||
|
||||
def onDeck(self):
|
||||
""" Returns a list of all media items on deck. """
|
||||
|
@ -197,10 +197,10 @@ class LibrarySection(PlexObject):
|
|||
key = '/library/sections/%s/all' % self.key
|
||||
return self.fetchItem(key, title=title)
|
||||
|
||||
def all(self, **attrs):
|
||||
def all(self, **kwargs):
|
||||
""" Returns a list of media from this library section. """
|
||||
key = '/library/sections/%s/all' % self.key
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def onDeck(self):
|
||||
""" Returns a list of media items on deck from this library section. """
|
||||
|
|
|
@ -48,10 +48,10 @@ class Photoalbum(PlexPartialObject):
|
|||
self.type = data.attrib.get('type')
|
||||
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
||||
|
||||
def photos(self, **attrs):
|
||||
def photos(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.photo.Photo` objects in this album. """
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def photo(self, title):
|
||||
""" Returns the :class:`~plexapi.photo.Photo` that matches the specified title. """
|
||||
|
|
|
@ -175,10 +175,10 @@ class Show(Video):
|
|||
def isWatched(self):
|
||||
return bool(self.viewedLeafCount == self.leafCount)
|
||||
|
||||
def seasons(self, **attrs):
|
||||
def seasons(self, **kwargs):
|
||||
"""Returns a list of Season."""
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItems(key, type=Season.TYPE, **attrs)
|
||||
return self.fetchItems(key, type=Season.TYPE, **kwargs)
|
||||
|
||||
def season(self, title=None):
|
||||
""" Returns the season with the specified title or number.
|
||||
|
@ -191,10 +191,10 @@ class Show(Video):
|
|||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItem(key, tag='Directory', title=title)
|
||||
|
||||
def episodes(self, **attrs):
|
||||
def episodes(self, **kwargs):
|
||||
""" Returs a list of Episode """
|
||||
key = '/library/metadata/%s/allLeaves' % self.ratingKey
|
||||
return self.fetchItems(key, **attrs)
|
||||
return self.fetchItems(key, **kwargs)
|
||||
|
||||
def episode(self, title=None, season=None, episode=None):
|
||||
"""Find a episode using a title or season and episode.
|
||||
|
@ -300,10 +300,10 @@ class Season(Video):
|
|||
"""Returns season number."""
|
||||
return self.index
|
||||
|
||||
def episodes(self, **attrs):
|
||||
def episodes(self, **kwargs):
|
||||
""" Returs a list of Episode. """
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItems(key, type=Episode.TYPE, **attrs)
|
||||
return self.fetchItems(key, type=Episode.TYPE, **kwargs)
|
||||
|
||||
def episode(self, title=None, num=None):
|
||||
""" Returns the episode with the given title or number.
|
||||
|
|
Loading…
Reference in a new issue