Exemple #1
0
    def _build(self, data):
        """Build the calendar"""
        self._calendar = []

        for item in data:
            show_data = item.pop('show')
            episode_data = {
                **item.pop('episode'), 'airs_at':
                airs_date(item.get('first_aired'))
            }

            show = TVShow(
                show_data.pop('title'),
                slug="sodiafagiaugaiugh",
                **{
                    **show_data,
                    #                    'seasons': []
                })
            episode = TVEpisode(show.title,
                                episode_data.pop('season'),
                                episode_data.pop('number'),
                                slug=show.slug,
                                **episode_data)
            for season in show.seasons:
                if season.season != episode.season:
                    continue
                season._episodes = [episode]
                show._seasons = [season]
                self._calendar.append(show)
                break
        self._calendar = sorted(self._calendar,
                                key=lambda x: x.seasons[0].episodes[0].airs_at)
Exemple #2
0
def test_airs_date():
    """verify that the airs_date function works as expected"""
    stamps = ['2015-02-01T05:30:00.000-08:00Z', '2015-02-01T05:30:00.000Z']
    for timestamp in stamps:
        output = airs_date(timestamp)
        assert output.year == 2015
        assert output.month == 2
        assert output.day == 1
        assert output.hour == 5
        assert output.minute == 30
        assert output.second == 0
Exemple #3
0
def test_airs_date():
    """verify that the airs_date function works as expected"""
    stamps = ['2015-02-01T05:30:00.000-08:00Z',
              '2015-02-01T05:30:00.000Z']
    for timestamp in stamps:
        output = airs_date(timestamp)
        assert output.year == 2015
        assert output.month == 2
        assert output.day == 1
        assert output.hour == 5
        assert output.minute == 30
        assert output.second == 0
Exemple #4
0
 def _build(self, data):
     """Build the calendar"""
     self._calendar = []
     for episode in data:
         show = episode.get('show', {}).get('title')
         season = episode.get('episode', {}).get('season')
         ep = episode.get('episode', {}).get('number')
         e_data = {'airs_at': airs_date(episode.get('first_aired')),
                   'ids': episode.get('episode').get('ids'),
                   'title': episode.get('episode', {}).get('title')}
         self._calendar.append(TVEpisode(show, season, ep, **e_data))
     self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)
Exemple #5
0
 def _build(self, data):
     """Build the calendar"""
     self._calendar = []
     for episode in data:
         show = episode.get('show', {}).get('title')
         season = episode.get('episode', {}).get('season')
         ep = episode.get('episode', {}).get('number')
         e_data = {
             'airs_at': airs_date(episode.get('first_aired')),
             'ids': episode.get('episode').get('ids'),
             'title': episode.get('episode', {}).get('title')
         }
         self._calendar.append(TVEpisode(show, season, ep, **e_data))
     self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)
Exemple #6
0
 def _build(self, data):
     """Build this :class:`TVSeason` object with the data in *data*"""
     # only try to build our episodes if we got a list of episodes, not a
     # dict of season data
     if isinstance(data, list):
         self._episodes = [
             TVEpisode(show=self.show, slug=self.slug, **ep) for ep in data
         ]
     else:
         for key, val in data.items():
             try:
                 setattr(self, key, val)
             except AttributeError:
                 setattr(self, '_' + key, val)
     if hasattr(self, 'first_aired'):
         setattr(self, 'first_aired_date', airs_date(self.first_aired))
Exemple #7
0
 def _build(self, data):
     """Build the calendar"""
     self._calendar = []
     for cal_item in data:
         show_data = cal_item.get('show', {})
         episode = cal_item.get('episode', {})
         first_aired = cal_item.get('first_aired')
         season = episode.get('season')
         ep_num = episode.get('number')
         extract_ids(show_data)
         show_data.update(show_data)
         e_data = {
             'airs_at': airs_date(first_aired),
             'ids': episode.get('ids'),
             'title': show_data.get('title'),
             'show_data': TVShow(**show_data)
         }
         self._calendar.append(
             TVEpisode(show_data['trakt'], season, ep_num, **e_data)
         )
     self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)
Exemple #8
0
 def first_aired_date(self):
     """Python datetime object representation of the first_aired date of
     this :class:`TVEpisode`
     """
     return airs_date(self.first_aired)
Exemple #9
0
 def _get(self):
     data = yield self.ext_full
     data['first_aired'] = airs_date(data['first_aired'])
     data['airs'] = Airs(**data['airs'])
     self._build(data)
Exemple #10
0
 def _get(self):
     data = yield self.ext_full
     data['first_aired'] = airs_date(data['first_aired'])
     data['airs'] = Airs(**data['airs'])
     self._build(data)
Exemple #11
0
def test_episode_aired_dates():
    e1 = TVEpisode('Game of Thrones', season=1, number=1)
    assert e1.first_aired_date == airs_date('2011-04-18T01:00:00.000Z')
    assert e1.first_aired_end_time == airs_date('2011-04-18T01:58:00.000Z')
Exemple #12
0
 def first_aired_date(self):
     """Python datetime object representation of the first_aired date of
     this :class:`TVEpisode`
     """
     return airs_date(self.first_aired)