コード例 #1
0
    def get_calendar_episodes(self, startdate=0, days=1, limit=25):
        items = []

        if not self.tmdb or not self.authorize():
            return items

        date = datetime.date.today() + datetime.timedelta(days=startdate)
        response = self.get_calendar('shows',
                                     True,
                                     start_date=date.strftime('%Y-%m-%d'),
                                     days=days)

        if not response:
            return items

        for i in response[-limit:]:
            episode = i.get('episode', {}).get('number')
            season = i.get('episode', {}).get('season')
            tmdb_id = i.get('show', {}).get('ids', {}).get('tmdb')
            item = ListItem(library=self.library,
                            **self.tmdb.get_detailed_item(itemtype='tv',
                                                          tmdb_id=tmdb_id,
                                                          season=season,
                                                          episode=episode))
            item.tmdb_id, item.season, item.episode = tmdb_id, season, episode
            item = self.get_calendar_properties(item, i)
            items.append(item)
        return items
コード例 #2
0
    def get_calendar_episodes(self, startdate=0, days=1, limit=25):
        items = []

        if not self.tmdb or not self.authorize():
            return items

        mod_date = startdate - 1
        mod_days = days + 2  # Broaden date range in case utc conversion bumps into different day
        date = datetime.date.today() + datetime.timedelta(days=mod_date)
        response = self.get_calendar('shows', True, start_date=date.strftime('%Y-%m-%d'), days=mod_days)

        if not response:
            return items

        traktitems = reversed(response) if startdate < -1 else response  # Reverse items for date ranges in past

        count = 0
        for i in traktitems:
            if not utils.date_in_range(i.get('first_aired'), utc_convert=True, start_date=startdate, days=days):
                continue  # Don't add items that aren't in our timezone converted range
            if count >= limit:
                break  # Only add the limit
            episode = i.get('episode', {}).get('number')
            season = i.get('episode', {}).get('season')
            tmdb_id = i.get('show', {}).get('ids', {}).get('tmdb')
            item = ListItem(library=self.library, **self.tmdb.get_detailed_item(
                itemtype='tv', tmdb_id=tmdb_id, season=season, episode=episode))
            item.tmdb_id, item.season, item.episode = tmdb_id, season, episode
            item = self.get_calendar_properties(item, i)
            items.append(item)
            count += 1
        return items
コード例 #3
0
    def get_calendar_episodes(self, startdate=0, days=1, limit=25):
        items = []

        if not self.tmdb or not self.authorize():
            return items

        date = datetime.datetime.today() + datetime.timedelta(days=startdate)
        response = TraktAPI().get_calendar(
            'shows', True, start_date=date.strftime('%Y-%m-%d'), days=days)

        if not response:
            return items

        for i in response[-limit:]:
            episode = i.get('episode', {}).get('number')
            season = i.get('episode', {}).get('season')
            tmdb_id = i.get('show', {}).get('ids', {}).get('tmdb')
            item = ListItem(library=self.library,
                            **self.tmdb.get_detailed_item(itemtype='tv',
                                                          tmdb_id=tmdb_id,
                                                          season=season,
                                                          episode=episode))
            item.tmdb_id, item.season, item.episode = tmdb_id, season, episode
            item.infolabels['title'] = item.label = i.get('episode',
                                                          {}).get('title')
            air_date = utils.convert_timestamp(i.get(
                'first_aired', '')) + datetime.timedelta(hours=self.utc_offset)
            item.infolabels['premiered'] = air_date.strftime('%Y-%m-%d')
            item.infolabels['year'] = air_date.strftime('%Y')
            item.infoproperties['air_time'] = air_date.strftime('%I:%M %p')
            items.append(item)
        return items