diff --git a/arrapi/apis/radarr.py b/arrapi/apis/radarr.py index 81e73b3..c04b264 100644 --- a/arrapi/apis/radarr.py +++ b/arrapi/apis/radarr.py @@ -98,7 +98,7 @@ def _validate_ids(self, ids): def respect_list_exclusions_when_adding(self): """ Stores all List Exclusions so whenever :func:`~arrapi.objs.reload.Movie.add` or :func:`~arrapi.apis.sonarr.RadarrAPI.add_multiple_movies` is called the additions will be checked against the Exclusion List """ - self.exclusions = [RadarrExclusion(self, ex).tmdbId for ex in self._raw.get_exclusions()] + self.exclusions = [ex.tmdbId for ex in RadarrExclusion.all(self)] def get_movie(self, movie_id: Optional[int] = None, tmdb_id: Optional[int] = None, imdb_id: Optional[str] = None) -> Movie: """ Gets a :class:`~arrapi.objs.reload.Movie` by one of the IDs. diff --git a/arrapi/objs/simple.py b/arrapi/objs/simple.py index 721c456..a6eaa33 100644 --- a/arrapi/objs/simple.py +++ b/arrapi/objs/simple.py @@ -169,6 +169,26 @@ class RadarrExclusion(SimpleObj): year (int): Year of the Excluded Movie. """ + @classmethod + def all(cls, arr): + if not arr._raw.new_codebase: + return [cls(arr, data) for data in arr._raw.get_exclusions()] + + page = 1 + page_size = 250 + exclusions = [] + while True: + response = arr._raw.get_exclusions_paged(page=page, pageSize=page_size) + records = response.get("records", []) + exclusions.extend(cls(arr, data) for data in records) + total_records = response.get("totalRecords") + if total_records is not None: + if len(exclusions) >= total_records: + return exclusions + elif len(records) < page_size: + return exclusions + page += 1 + def _load(self, data): super()._load(data) self.tmdbId = self._parse(attrs="tmdbId", value_type="int") diff --git a/arrapi/raws/radarr.py b/arrapi/raws/radarr.py index d09fd3c..8aa50f5 100644 --- a/arrapi/raws/radarr.py +++ b/arrapi/raws/radarr.py @@ -61,6 +61,15 @@ def get_exclusions(self): """ GET /exclusions """ return self._get("exclusions") + def get_exclusions_paged(self, page=1, pageSize=10, sortKey=None, sortDirection=None): + """ GET /exclusions/paged """ + params = {"page": page, "pageSize": pageSize} + if sortKey is not None: + params["sortKey"] = sortKey + if sortDirection is not None: + params["sortDirection"] = sortDirection + return self._get("exclusions/paged", **params) + def post_exclusions(self, json): """ POST /exclusions """ return self._post("exclusions", json=json)