Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@get
def images(self):
"""All of the artwork associated with this :class:`Movie`"""
if self._images is None:
data = yield self.images_ext
self._images = data.get('images', {})
yield self._images
@get
def next_episode(self):
"""Returns the next scheduled to air :class:`TVEpisode`. If no episode
is found, `None` will be returned.
"""
if self._next_episode is None:
data = yield (self.ext + '/next_episode?extended=full')
self._next_episode = data and TVEpisode(show=self.title, **data)
yield self._next_episode
@get
def followers(self):
"""A list of all followers including the since timestamp which is when
the relationship began. Protected users won't return any data unless
you are friends. Any friends of the main user that are protected won't
display data either.
"""
if self._followers is None:
data = yield 'users/{user}/followers'.format(user=self.username)
self._followers = []
for user in data:
user_data = user.pop('user')
date = user.pop('followed_at')
self._followers.append(User(followed_at=date, **user_data))
yield self._followers
@get
def trending_shows():
"""All :class:`TVShow`'s being watched right now"""
data = yield 'shows/trending'
to_ret = []
for show in data:
show_data = show.pop('show')
ids = show_data.pop('ids')
extract_ids(ids)
show_data['watchers'] = show.get('watchers')
to_ret.append(TVShow(**show_data))
yield to_ret
@get
def _get(self):
"""Get this :class:`User` from the trakt.tv API"""
data = yield 'users/{username}'.format(username=self.username)
self._build(data)
@get
def _episode_getter(self, episode):
"""Recursive episode getter generator. Will attempt to get the
speicifed episode for this season, and if the requested episode wasn't
found, then we return :const:`None` to indicate to the `episodes`
property that we've already yielded all valid episodes for this season.
:param episode: An int corresponding to the number of the episode
we're trying to retrieve
"""
episode_extension = '/episodes/{}?extended=full'.format(episode)
try:
data = yield (self.ext + episode_extension)
yield TVEpisode(show=self.show, **data)
except NotFoundException:
yield None
@get
def seasons(self):
"""A list of :class:`TVSeason` objects representing all of this show's
seasons
"""
if self._seasons is None:
data = yield (self.ext + '/seasons?extended=full')
self._seasons = []
for season in data:
extract_ids(season)
self._seasons.append(TVSeason(self.title, **season))
yield self._seasons
@get
def watching_now(self):
"""A list of all :class:`User`'s watching a movie."""
from .users import User
data = yield self.ext + '/watching'
users = []
for user in data:
users.append(User(**user))
yield users
@get
def movie_credits(self):
"""Return a collection of movie credits that this :class:`Person` was a
cast or crew member on
"""
if self._movie_credits is None:
data = yield self.ext_movie_credits
self._movie_credits = MovieCredits(**data)
yield self._movie_credits
@get
def people(self):
"""A :const:`list` of all of the :class:`People` involved in this
:class:`TVShow`, including both cast and crew
"""
if self._people is None:
data = yield (self.ext + '/people')
crew = data.get('crew', {})
cast = []
for c in data.get('cast', []):
person = c.pop('person')
character = c.pop('character')
cast.append(Person(character=character, **person))
_crew = []
for key in crew:
for department in crew.get(key): # lists