mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Change LibrarySection collections method to plural
* Add DeprecationWarning to old collection method * Add NotImplementedError for PhotoSection.collections()
This commit is contained in:
parent
f4229050d4
commit
86d51bae6c
1 changed files with 18 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import warnings
|
||||
from urllib.parse import quote, quote_plus, unquote, urlencode
|
||||
|
||||
from plexapi import X_PLEX_CONTAINER_SIZE, log, utils
|
||||
|
@ -842,6 +843,20 @@ class LibrarySection(PlexObject):
|
|||
"""
|
||||
return self._server.history(maxresults=maxresults, mindate=mindate, librarySectionID=self.key, accountID=1)
|
||||
|
||||
def collection(self, **kwargs):
|
||||
warnings.simplefilter('always')
|
||||
warnings.warn(
|
||||
'collection() will be deprecated in the future, use collections() (plural) instead.',
|
||||
DeprecationWarning
|
||||
)
|
||||
return self.collections()
|
||||
|
||||
def collections(self, **kwargs):
|
||||
""" Returns a list of collections from this library section.
|
||||
See description of :func:`plexapi.library.LibrarySection.search()` for details about filtering / sorting.
|
||||
"""
|
||||
return self.search(libtype='collection', **kwargs)
|
||||
|
||||
|
||||
class MovieSection(LibrarySection):
|
||||
""" Represents a :class:`~plexapi.library.LibrarySection` section containing movies.
|
||||
|
@ -855,10 +870,6 @@ class MovieSection(LibrarySection):
|
|||
METADATA_TYPE = 'movie'
|
||||
CONTENT_TYPE = 'video'
|
||||
|
||||
def collection(self, **kwargs):
|
||||
""" Returns a list of collections from this library section. """
|
||||
return self.search(libtype='collection', **kwargs)
|
||||
|
||||
def sync(self, videoQuality, limit=None, unwatched=False, **kwargs):
|
||||
""" Add current Movie library section as sync item for specified device.
|
||||
See description of :func:`~plexapi.library.LibrarySection.search` for details about filtering / sorting and
|
||||
|
@ -924,10 +935,6 @@ class ShowSection(LibrarySection):
|
|||
"""
|
||||
return self.search(sort='episode.addedAt:desc', libtype=libtype, maxresults=maxresults)
|
||||
|
||||
def collection(self, **kwargs):
|
||||
""" Returns a list of collections from this library section. """
|
||||
return self.search(libtype='collection', **kwargs)
|
||||
|
||||
def sync(self, videoQuality, limit=None, unwatched=False, **kwargs):
|
||||
""" Add current Show library section as sync item for specified device.
|
||||
See description of :func:`~plexapi.library.LibrarySection.search` for details about filtering / sorting and
|
||||
|
@ -999,10 +1006,6 @@ class MusicSection(LibrarySection):
|
|||
""" Search for a track. See :func:`~plexapi.library.LibrarySection.search` for usage. """
|
||||
return self.search(libtype='track', **kwargs)
|
||||
|
||||
def collection(self, **kwargs):
|
||||
""" Returns a list of collections from this library section. """
|
||||
return self.search(libtype='collection', **kwargs)
|
||||
|
||||
def sync(self, bitrate, limit=None, **kwargs):
|
||||
""" Add current Music library section as sync item for specified device.
|
||||
See description of :func:`~plexapi.library.LibrarySection.search` for details about filtering / sorting and
|
||||
|
@ -1050,6 +1053,9 @@ class PhotoSection(LibrarySection):
|
|||
CONTENT_TYPE = 'photo'
|
||||
METADATA_TYPE = 'photo'
|
||||
|
||||
def collections(self, **kwargs):
|
||||
raise NotImplementedError('Collections are not available for a Photo library.')
|
||||
|
||||
def searchAlbums(self, title, **kwargs):
|
||||
""" Search for an album. See :func:`~plexapi.library.LibrarySection.search` for usage. """
|
||||
return self.search(libtype='photoalbum', title=title, **kwargs)
|
||||
|
|
Loading…
Reference in a new issue