Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_seasons():
got = TVShow('Game of Thrones')
assert all([isinstance(s, TVSeason) for s in got.seasons])
def test_last_episode():
got = TVShow('Game of Thrones')
assert isinstance(got.last_episode, TVEpisode)
def test_show_comment():
got = TVShow('Game of Thrones')
got.comment('Test Comment Data')
for media_item in data:
extract_ids(media_item)
results = []
for d in data:
if 'episode' in d:
from trakt.tv import TVEpisode
show = d.pop('show')
extract_ids(d['episode'])
results.append(TVEpisode(show['title'], **d['episode']))
elif 'movie' in d:
from trakt.movies import Movie
results.append(Movie(**d.pop('movie')))
elif 'show' in d:
from trakt.tv import TVShow
results.append(TVShow(**d.pop('show')))
elif 'person' in d:
from trakt.people import Person
results.append(Person(**d.pop('person')))
yield results
"""
data = yield 'users/{user}/lists/{id}/items'.format(user=self.creator,
id=self.slug)
for item in data:
# match list item type
if 'type' not in item:
continue
item_type = item['type']
item_data = item.pop(item_type)
extract_ids(item_data)
if item_type == 'movie':
self._items.append(Movie(item_data['title'], item_data['year'], item_data['slug']))
elif item_type == 'show':
self._items.append(TVShow(item_data['title'], item_data['slug']))
elif item_type == 'season':
show_data = item.pop('show')
extract_ids(show_data)
season = TVSeason(show_data['title'], item_data['number'], show_data['slug'])
self._items.append(season)
elif item_type == 'episode':
show_data = item.pop('show')
extract_ids(show_data)
episode = TVEpisode(show_data['title'], item_data['season'], item_data['number'])
self._items.append(episode)
elif item_type == 'person':
self._items.append(Person(item_data['name'], item_data['slug']))
yield self._items
if year is not None:
uri += '&year={}'.format(year)
data = yield uri
for media_item in data:
extract_ids(media_item)
# Need to do imports here to prevent circular imports with modules that
# need to import Scrobblers
if search_type == 'movie':
from trakt.movies import Movie
yield [Movie(**d.pop('movie')) for d in data]
elif search_type == 'show':
from trakt.tv import TVShow
yield [TVShow(**d.pop('show')) for d in data]
elif search_type == 'episode':
from trakt.tv import TVEpisode
episodes = []
for episode in data:
show = episode.pop('show')
extract_ids(episode['episode'])
episodes.append(TVEpisode(show.get('title', None),
**episode['episode']))
yield episodes
elif search_type == 'person':
from trakt.people import Person
yield [Person(**d.pop('person')) for d in data]
def __init__(self, title='', slug=None, **kwargs):
super(TVShow, self).__init__()
self.media_type = 'shows'
self.top_watchers = self.top_episodes = self.year = self.tvdb = None
self.imdb = self.genres = self.certification = self.network = None
self.trakt = self.tmdb = self._aliases = self._comments = None
self._images = self._people = self._ratings = self._translations = None
self._seasons = None
self._last_episode = self._next_episode = None
self.title = title
self.slug = slug or slugify(self.title)
if len(kwargs) > 0:
self._build(kwargs)
else:
self._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
MyShowCalendar, None, self.days
)
except trakt.errors.TraktInternalException:
_LOGGER.error("Trakt api encountered an internal error.")
raise UpdateFailed
if not self.calendar:
_LOGGER.warning("Trakt upcoming calendar is empty")
for show in self.calendar:
if not show or show.show in self.exclude:
continue
try:
show_details = await self.hass.async_add_executor_job(
TVShow.search, show.show, show.year
)
except AttributeError:
_LOGGER.error("Unable to retrieve show details for " + show.show)
if not show_details:
continue
if days_until(show.airs_at) < 0:
continue
if days_until(show.airs_at) <= 7:
release = "$day, $time"
else:
release = "$day, $date $time"
session = aiohttp_client.async_get_clientsession(self.hass)
try:
query=slugify(query), type=','.join(search_type))
data = yield uri
# Need to do imports here to prevent circular imports with modules that
# need to import Scrobblers
results = []
for media_item in data:
extract_ids(media_item)
result = SearchResult(media_item['type'], media_item['score'])
if media_item['type'] == 'movie':
from trakt.movies import Movie
result.media = Movie(**media_item.pop('movie'))
elif media_item['type'] == 'show':
from trakt.tv import TVShow
result.media = TVShow(**media_item.pop('show'))
elif media_item['type'] == 'episode':
from trakt.tv import TVEpisode
show = media_item.pop('show')
result.media = TVEpisode(show.get('title', None),
**media_item.pop('episode'))
elif media_item['type'] == 'person':
from trakt.people import Person
result.media = Person(**media_item.pop('person'))
results.append(result)
yield results