From d52a056a89e3b11116d3e1fd0fa1e50372cbe933 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 10 Jan 2024 14:47:24 +0100 Subject: [PATCH] Fix limit loaded cast (max 30) and crew (max 5) from TVmaze API. --- CHANGES.md | 7 ++++++- lib/pytvmaze/tvmaze.py | 13 +++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c72446f1..a31d8a66 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 3.30.6 (2024-01-02 11:05:00 UTC) +### 3.30.7 (2024-01-10 14:20:00 UTC) + +* Fix limit loaded cast (max 30) and crew (max 5) from TVmaze API + + +### 3.30.6 (2024-01-02 11:05:00 UTC) * Fix Shows IMDb cards to new layout at IMDb * Change update fallback zoneinfo to 2023d diff --git a/lib/pytvmaze/tvmaze.py b/lib/pytvmaze/tvmaze.py index 24b4f8ed..07020cd5 100644 --- a/lib/pytvmaze/tvmaze.py +++ b/lib/pytvmaze/tvmaze.py @@ -442,11 +442,12 @@ class Cast(object): self.populate(data) def populate(self, data): - for cast_member in data: - self.people.append(Person(cast_member['person'])) - self.characters.append(Character(cast_member['character'], cast_member)) - self.people[-1].character = self.characters[-1] # add reference to character - self.characters[-1].person = self.people[-1] # add reference to cast member + if isinstance(data, list): + for cast_member in data[:30]: + self.people.append(Person(cast_member['person'])) + self.characters.append(Character(cast_member['character'], cast_member)) + self.people[-1].character = self.characters[-1] # add reference to character + self.characters[-1].person = self.people[-1] # add reference to cast member def __repr__(self): return self.__str__() @@ -1476,7 +1477,7 @@ def get_show_crew(maze_id, raise_error=True): url = endpoints.show_crew.format(maze_id) q = TVmaze.endpoint_standard_get(url) if q: - return [Crew(crew) for crew in q] + return [Crew(crew) for crew in (isinstance(q, list) and q[:5]) or []] elif raise_error: raise CrewNotFound('Couldn\'t find crew for TVmaze ID {}'.format(maze_id)) return []