Update Pytvmaze library 2.0.8 (16ed096) → 2.0.8 (81888a5).

This commit is contained in:
JackDandy 2023-04-30 09:15:38 +01:00
parent 1f3e1416d4
commit b6b362845d
3 changed files with 54 additions and 5 deletions

View file

@ -7,6 +7,7 @@
* Update feedparser 6.0.10 (5fcb3ae) to 6.0.10 (6d032b8)
* Update filelock 3.9.0 (ce3e891) to 3.11.0 (d3241b9)
* Update Msgpack 1.0.4 (b5acfd5) to 1.0.5 (0516c2c)
* Update Pytvmaze library 2.0.8 (16ed096) to 2.0.8 (81888a5)
* Update Requests library 2.28.1 (ec553c2) to 2.29.0 (87d63de)
* Update SimpleJSON 3.18.1 (c891b95) to 3.19.1 (aeb63ee)
* Update Tornado Web Server 6.3.0 (7186b86) to 6.3.1 (419838b)

View file

@ -17,6 +17,7 @@ show_index = 'https://api.tvmaze.com/shows?page={0}'
people_search = 'https://api.tvmaze.com/search/people?q={0}'
person_main_info = 'https://api.tvmaze.com/people/{0}'
person_cast_credits = 'https://api.tvmaze.com/people/{0}/castcredits'
person_guestcast_credits = 'https://api.tvmaze.com/people/{0}/guestcastcredits'
person_crew_credits = 'https://api.tvmaze.com/people/{0}/crewcredits'
show_crew = 'https://api.tvmaze.com/shows/{0}/crew'
show_updates = 'https://api.tvmaze.com/updates/shows'
@ -24,6 +25,8 @@ show_akas = 'https://api.tvmaze.com/shows/{0}/akas'
show_seasons = 'https://api.tvmaze.com/shows/{0}/seasons'
season_by_id = 'https://api.tvmaze.com/seasons/{0}'
episode_by_id = 'https://api.tvmaze.com/episodes/{0}'
episode_guestcast = 'https://api.tvmaze.com/episodes/{0}/guestcast'
episode_guestcrew = 'https://api.tvmaze.com/episodes/{0}/guestcrew'
show_images = 'https://api.tvmaze.com/shows/{0}/images'
# TVmaze Premium endpoints

View file

@ -287,9 +287,12 @@ class Episode(object):
if data.get('show'):
self.show = Show(data.get('show'))
# Reference to show for when using get_full_schedule()
if data.get('_embedded'):
if not self.show and data.get('_embedded'):
if data['_embedded'].get('show'):
self.show = Show(data['_embedded']['show'])
if not self.show and data.get('_links') and 'show' in data['_links']:
self.show = Show({})
self.show.id = int(re.search(r'/(\d+)$', data['_links']['show']['href']).group(1))
def __repr__(self):
if self.special:
@ -345,6 +348,7 @@ class Person(object):
self.country = data.get('country')
self.character = None
self._castcredits = None
self._guestcastcredits = None
self._crewcredits = None
# self.populate(data)
@ -363,6 +367,12 @@ class Person(object):
self._castcredits = person_cast_credits(self.id, embed='show,character', raise_error=False)
return self._castcredits
@property
def guestcastcredits(self):
if None is self._guestcastcredits:
self._guestcastcredits = person_guestcast_credits(self.id, embed='episode,character', raise_error=False)
return self._guestcastcredits
@property
def crewcredits(self):
if None is self._crewcredits:
@ -451,8 +461,9 @@ class Cast(object):
class CastCredit(object):
def __init__(self, data):
self.links = data.get('_links')
self.character = None
self.show = None
self.character = None # type: Optional[Character]
self.show = None # type: Optional[Show]
self.episode = None # type: Optional[Episode]
self.populate(data)
def populate(self, data):
@ -461,6 +472,8 @@ class CastCredit(object):
self.character = Character(data['_embedded']['character'])
if data['_embedded'].get('show'):
self.show = Show(data['_embedded']['show'])
if data['_embedded'].get('episode'):
self.episode = Episode(data['_embedded']['episode'])
def __repr__(self):
return self.__str__()
@ -1437,6 +1450,17 @@ def person_cast_credits(person_id, embed=None, raise_error=True):
return []
def person_guestcast_credits(person_id, embed=None, raise_error=True):
url = _embed_url(endpoints.person_guestcast_credits.format(person_id), embed,
[None, 'episode', 'character'], '?')
q = TVmaze.endpoint_standard_get(url)
if q:
return [CastCredit(credit) for credit in q]
elif raise_error:
raise CreditsNotFound('Couldn\'t find cast credits for person ID {0}'.format(person_id))
return []
def person_crew_credits(person_id, embed=None, raise_error=True):
url = _embed_url(endpoints.person_crew_credits.format(person_id), embed,
[None, 'show'], '?')
@ -1518,10 +1542,31 @@ def season_by_id(season_id, embed=None):
raise SeasonNotFound('Couldn\'t find Season with ID {0}'.format(season_id))
def episode_by_id(episode_id, show=None, raise_error=True):
url = endpoints.episode_by_id.format(episode_id)
def episode_by_id(episode_id, show=None, raise_error=True, embed=None):
url = _embed_url(endpoints.episode_by_id.format(episode_id), embed,
[None, 'show', 'guestcast', 'guestcrew'], '?')
q = TVmaze.endpoint_standard_get(url)
if q:
return Episode(q, show=show)
elif raise_error:
raise EpisodeNotFound('Couldn\'t find Episode with ID {0}'.format(episode_id))
def episode_guestcast_credits(episode_id, raise_error=True):
url = endpoints.episode_guestcast.format(episode_id)
q = TVmaze.endpoint_standard_get(url)
if q:
return [CastCredit(credit) for credit in q]
elif raise_error:
raise CreditsNotFound('Couldn\'t find cast credits for episode ID {0}'.format(episode_id))
return []
def episode_crew_credits(episode_id, raise_error=True):
url = endpoints.episode_guestcrew.format(episode_id)
q = TVmaze.endpoint_standard_get(url)
if q:
return [CrewCredit(credit) for credit in q]
elif raise_error:
raise CreditsNotFound('Couldn\'t find crew credits for episode ID {0}'.format(episode_id))
return []