Beispiel #1
0
    def _add_season(self, season, blacklist=[0]):
        number = season.get('season_number', 0)
        folder = u'Season {}'.format(number)

        # Skip blacklisted seasons
        if try_int(number) in blacklist:  # TODO: Optional whitelist also
            self._log._add('tv',
                           self.tv.tmdb_id,
                           'skipped special season',
                           season=number)
            return

        # Skip if we've added season before and it isn't the most recent season
        # We still add most recent season even if we added it before because it might currently be airing
        if self._log._add('tv',
                          self.tv.tmdb_id,
                          self.tv._cache.is_added_season(number),
                          season=number):
            return

        # Add our episodes
        for x, episode in enumerate(self.tv.get_episodes(number), 1):
            self._add_episode(episode, number, folder)
            self._update(x, self.tv.e_total)

        # Store a season value of where we got up to
        if self.tv.e_total > 2 and season.get(
                'air_date') and not is_unaired_timestamp(
                    season.get('air_date'), self.hide_nodate):
            self.tv._cache.my_history['latest_season'] = try_int(number)
Beispiel #2
0
 def is_unaired(self, format_label=u'[COLOR=ffcc0000][I]{}[/I][/COLOR]', check_hide_settings=True, no_date=True):
     try:
         if not is_unaired_timestamp(self.infolabels.get('premiered'), no_date):
             return
         if format_label:
             self.label = format_label.format(self.label)
     except Exception as exc:
         kodi_log(u'Error: {}'.format(exc), 1)
     if not check_hide_settings:
         return True
     return self.unaired_bool()
Beispiel #3
0
    def _add_episode(self, episode, season, folder):
        number = episode.get('episode_number')
        filename = validify_filename(u'S{:02d}E{:02d} - {}'.format(
            try_int(season), try_int(number), episode.get('name')))
        self.tv._cache.my_history['episodes'].append(filename)

        # Skip episodes we added in the past
        if self._log._add('tv',
                          self.tv.tmdb_id,
                          self.tv._cache.is_added_episode(filename),
                          season=season,
                          episode=number):
            return

        # Skip future episodes
        if self.hide_unaired and is_unaired_timestamp(episode.get('air_date'),
                                                      self.hide_nodate):
            self.tv._cache.my_history['skipped'].append(filename)
            self._log._add('tv',
                           self.tv.tmdb_id,
                           'unaired episode',
                           season=season,
                           episode=number,
                           air_date=episode.get('air_date'))
            return

        # Check if item has already been added
        file = self.tv.get_episode_db_info(season, number, info='file')
        if file:
            self._log._add('tv',
                           self.tv.tmdb_id,
                           'found in library',
                           season=season,
                           episode=number,
                           path=file)
            return

        # Add our strm file
        file = create_file(STRM_EPISODE.format(self.tv.tmdb_id, season,
                                               number),
                           filename,
                           self.tv.name,
                           folder,
                           basedir=BASEDIR_TV)
        self._log._add('tv',
                       self.tv.tmdb_id,
                       'added strm file',
                       season=season,
                       episode=number,
                       path=file)