mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
parent
772c41dfdf
commit
6eea7cce0f
3 changed files with 30 additions and 1 deletions
|
@ -146,11 +146,21 @@ class PlexObject(object):
|
|||
""" Load the specified key to find and build all items with the specified tag
|
||||
and attrs. See :func:`~plexapi.base.PlexObject.fetchItem` for more details
|
||||
on how this is used.
|
||||
|
||||
Use container_start and container_size for pagination.
|
||||
"""
|
||||
url_kw = {}
|
||||
for key, value in dict(kwargs).items():
|
||||
if key == "container_start":
|
||||
url_kw["X-Plex-Container-Start"] = kwargs.pop(key)
|
||||
if key == "container_size":
|
||||
url_kw["X-Plex-Container-Size"] = kwargs.pop(key)
|
||||
|
||||
if ekey is None:
|
||||
raise BadRequest('ekey was not provided')
|
||||
data = self._server.query(ekey)
|
||||
data = self._server.query(ekey, params=url_kw)
|
||||
items = self.findItems(data, cls, ekey, **kwargs)
|
||||
|
||||
librarySectionID = data.attrib.get('librarySectionID')
|
||||
if librarySectionID:
|
||||
for item in items:
|
||||
|
|
|
@ -332,6 +332,8 @@ class LibrarySection(PlexObject):
|
|||
type (str): Type of content section represents (movie, artist, photo, show).
|
||||
updatedAt (datetime): Datetime this library section was last updated.
|
||||
uuid (str): Unique id for this section (32258d7c-3e6c-4ac5-98ad-bad7a3b78c63)
|
||||
totalSize (int): Total number of item in the library
|
||||
|
||||
"""
|
||||
ALLOWED_FILTERS = ()
|
||||
ALLOWED_SORT = ()
|
||||
|
@ -355,6 +357,17 @@ class LibrarySection(PlexObject):
|
|||
self.type = data.attrib.get('type')
|
||||
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
||||
self.uuid = data.attrib.get('uuid')
|
||||
# Private attrs as we dont want a reload.
|
||||
self._total_size = None
|
||||
|
||||
@property
|
||||
def totalSize(self):
|
||||
if self._total_size is None:
|
||||
part = '/library/sections/%s/all?X-Plex-Container-Start=0&X-Plex-Container-Size=1' % self.key
|
||||
data = self._server.query(part)
|
||||
self._total_size = int(data.attrib.get("totalSize"))
|
||||
|
||||
return self._total_size
|
||||
|
||||
def delete(self):
|
||||
""" Delete a library section. """
|
||||
|
|
|
@ -50,6 +50,12 @@ def test_library_section_get_movie(plex):
|
|||
assert plex.library.section("Movies").get("Sita Sings the Blues")
|
||||
|
||||
|
||||
def test_library_section_movies_all(movies):
|
||||
# size should always be none unless pagenation is being used.
|
||||
assert movies.totalSize == 4
|
||||
assert len(movies.all(container_start=0, container_size=1)) == 1
|
||||
|
||||
|
||||
def test_library_section_delete(movies, patched_http_call):
|
||||
movies.delete()
|
||||
|
||||
|
|
Loading…
Reference in a new issue