From 3e8a5663a3abcdc4bd6e8af7ff08beac6d18fbb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 22:27:15 -0700 Subject: [PATCH] Bump plexapi from 4.15.11 to 4.15.12 (#2311) * Bump plexapi from 4.15.11 to 4.15.12 Bumps [plexapi](https://github.com/pkkid/python-plexapi) from 4.15.11 to 4.15.12. - [Release notes](https://github.com/pkkid/python-plexapi/releases) - [Commits](https://github.com/pkkid/python-plexapi/compare/4.15.11...4.15.12) --- updated-dependencies: - dependency-name: plexapi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update plexapi==4.15.12 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci] --- lib/plexapi/base.py | 26 ++++++++++++++++++-------- lib/plexapi/const.py | 2 +- lib/plexapi/server.py | 4 ++-- requirements.txt | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/plexapi/base.py b/lib/plexapi/base.py index 0852426d..c08334f9 100644 --- a/lib/plexapi/base.py +++ b/lib/plexapi/base.py @@ -170,7 +170,16 @@ class PlexObject: elem = ElementTree.fromstring(xml) return self._buildItemOrNone(elem, cls) - def fetchItems(self, ekey, cls=None, container_start=None, container_size=None, maxresults=None, **kwargs): + def fetchItems( + self, + ekey, + cls=None, + container_start=None, + container_size=None, + maxresults=None, + params=None, + **kwargs, + ): """ Load the specified key to find and build all items with the specified tag and attrs. @@ -186,6 +195,7 @@ class PlexObject: container_start (None, int): offset to get a subset of the data container_size (None, int): How many items in data maxresults (int, optional): Only return the specified number of results. + params (dict, optional): Any additional params to add to the request. **kwargs (dict): Optionally add XML attribute to filter the items. See the details below for more info. @@ -268,7 +278,7 @@ class PlexObject: headers['X-Plex-Container-Start'] = str(container_start) headers['X-Plex-Container-Size'] = str(container_size) - data = self._server.query(ekey, headers=headers) + data = self._server.query(ekey, headers=headers, params=params) subresults = self.findItems(data, cls, ekey, **kwargs) total_size = utils.cast(int, data.attrib.get('totalSize') or data.attrib.get('size')) or len(subresults) @@ -283,6 +293,11 @@ class PlexObject: results.extend(subresults) + container_start += container_size + + if container_start > total_size: + break + wanted_number_of_items = total_size - offset if maxresults is not None: wanted_number_of_items = min(maxresults, wanted_number_of_items) @@ -291,11 +306,6 @@ class PlexObject: if wanted_number_of_items <= len(results): break - container_start += container_size - - if container_start > total_size: - break - return results def fetchItem(self, ekey, cls=None, **kwargs): @@ -337,7 +347,7 @@ class PlexObject: kwargs['type'] = cls.TYPE # rtag to iter on a specific root tag using breadth-first search if rtag: - data = next(utils.iterXMLBFS(data, rtag), []) + data = next(utils.iterXMLBFS(data, rtag), Element('Empty')) # loop through all data elements to find matches items = MediaContainer[cls](self._server, data, initpath=initpath) if data.tag == 'MediaContainer' else [] for elem in data: diff --git a/lib/plexapi/const.py b/lib/plexapi/const.py index e043d8c2..c987e305 100644 --- a/lib/plexapi/const.py +++ b/lib/plexapi/const.py @@ -4,6 +4,6 @@ # Library version MAJOR_VERSION = 4 MINOR_VERSION = 15 -PATCH_VERSION = 11 +PATCH_VERSION = 12 __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" diff --git a/lib/plexapi/server.py b/lib/plexapi/server.py index bdd330f7..178ce82b 100644 --- a/lib/plexapi/server.py +++ b/lib/plexapi/server.py @@ -746,7 +746,7 @@ class PlexServer(PlexObject): """ Returns list of all :class:`~plexapi.media.TranscodeJob` objects running or paused on server. """ return self.fetchItems('/status/sessions/background') - def query(self, key, method=None, headers=None, timeout=None, **kwargs): + def query(self, key, method=None, headers=None, params=None, timeout=None, **kwargs): """ Main method used to handle HTTPS requests to the Plex server. This method helps by encoding the response to utf-8 and parsing the returned XML into and ElementTree object. Returns None if no data exists in the response. @@ -756,7 +756,7 @@ class PlexServer(PlexObject): timeout = timeout or self._timeout log.debug('%s %s', method.__name__.upper(), url) headers = self._headers(**headers or {}) - response = method(url, headers=headers, timeout=timeout, **kwargs) + response = method(url, headers=headers, params=params, timeout=timeout, **kwargs) if response.status_code not in (200, 201, 204): codename = codes.get(response.status_code)[0] errtext = response.text.replace('\n', ' ') diff --git a/requirements.txt b/requirements.txt index ea940f73..cdf89bb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ musicbrainzngs==0.7.1 packaging==24.0 paho-mqtt==2.0.0 platformdirs==4.2.0 -plexapi==4.15.11 +plexapi==4.15.12 portend==3.2.0 profilehooks==1.12.0 PyJWT==2.8.0