Skip to content

Commit

Permalink
limit total pages to 500
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Sep 26, 2024
1 parent b4620bf commit ee26d0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.19
1.2.20
6 changes: 3 additions & 3 deletions tmdbapis/objs/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def load_next(self):
Raises:
:class:`~tmdbapis.exceptions.Invalid`: When ``start_date`` or ``end_date`` is in an incorrect format.
"""
if self.page + 1 > self.total_pages:
if self.page + 1 > self.total_pages or self.page + 1 > 500:
raise NotFound("No Next Page")
self.load_page(self.page + 1)

Expand All @@ -73,8 +73,8 @@ def load_page(self, page: int):
:class:`~tmdbapis.exceptions.Invalid`: When ``page`` is not in the range of valid page numbers.
"""
page = int(page)
if page < 1 or page > self.total_pages:
raise Invalid(f"Page must be an integer 1-{self.total_pages}")
if page < 1 or page > self.total_pages or page > 500:
raise Invalid(f"Page must be an integer 1-{'500' if self.total_pages > 500 else self.total_pages}")
if page in self._page_storage:
self._loading = True
self.results = self._page_storage[page]
Expand Down
2 changes: 0 additions & 2 deletions tmdbapis/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ def _validate_discover(self, is_movie, **kwargs):
raise Invalid(f"{k} must be a number greater than 0.0")
validated[k] = float(v)
elif k == "with_watch_monetization_types":
if v not in ["flatrate", "free", "ads", "rent", "buy"]:
raise Invalid(f"{v} is not a valid with_watch_monetization_types option. Options: [flatrate, free, ads, rent, or buy]")
if "watch_region" not in kwargs:
raise Invalid("with_watch_monetization_types must be used with watch_region")
validated[k] = v
Expand Down

0 comments on commit ee26d0c

Please sign in to comment.