Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arrapi/apis/radarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions arrapi/objs/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions arrapi/raws/radarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down