示例#1
0
 def items(self):
     if self._items is None:
         try:
             req = TVDBRequest(username=self.config['username'], account_id=self.config['account_id']).get(
                 'user/favorites')
             series_ids = [int(f_id) for f_id in req['favorites'] if f_id != '']
         except RequestException as e:
             raise PluginError('Error retrieving favorites from thetvdb: %s' % str(e))
         self._items = []
         for series_id in series_ids:
             # Lookup the series name from the id
             try:
                 series = lookup_series(tvdb_id=series_id)
             except LookupError as e:
                 log.error('Error looking up %s from thetvdb: %s' % (series_id, e.args[0]))
             else:
                 series_name = series.name
                 if self.config.get('strip_dates'):
                     # Remove year from end of series name if present
                     series_name, _ = split_title_year(series_name)
                 entry = Entry()
                 entry['title'] = entry['series_name'] = series_name
                 entry['url'] = 'http://thetvdb.com/index.php?tab=series&id={}'.format(str(series.id))
                 entry['tvdb_id'] = str(series.id)
                 self._items.append(entry)
     return self._items
示例#2
0
 def discard(self, entry):
     if not entry.get('tvdb_id'):
         log.verbose('entry does not have `tvdb_id`, cannot remove from list. Consider using a lookup plugin`')
         return
     try:
         TVDBRequest(username=self.config['username'], account_id=self.config['account_id']).delete(
             'user/favorites/{}'.format(entry['tvdb_id']))
     except RequestException as e:
         log.error('Could not add tvdb_id {} to favourites list: {}'.format(entry['tvdb_id'], e))
     self.invalidate_cache()