def add_episode_info(torrent, episodes): """ Add episode info from TheTVDB to the torrent :param torrent: a torrent object from Rarbg :type torrent: dict :param episodes: TV episodes database with info from TheTVDB :type episodes: dict """ tvdbid = torrent['episode_info']['tvdb'] episode_id = '{0}-{1}x{2}'.format(tvdbid, torrent['episode_info']['seasonnum'], torrent['episode_info']['epnum']) episode_info = episodes.get(episode_id) if episode_info is None: try: episode_info = tvdb.get_episode( tvdbid, torrent['episode_info']['seasonnum'], torrent['episode_info']['epnum']) except RarbgError: plugin.log_error( 'TheTVDB returned no data for episode {0}, torrent {1}'.format( episode_id, torrent['title'])) episode_info = None episodes[episode_id] = episode_info torrent['tvdb_episode_info'] = episode_info
def add_episode(self, tvdb_series, tvdb_episode, meta = None): try: if not meta: meta = tvdb.get_episode(tvdb_episode) self.db.execute(''' insert into episodes (tvdb_series, tvdb_episode, episode_name, season_number, episode_number, aired) VALUES (?,?,?,?,?,?)''', (tvdb_series, tvdb_episode, meta['name'], meta['season_number'], meta['episode_number'], meta['first_aired'] ) ) self.db.commit() log.info("added episode %s" %(meta['name'], )) except Exception, e: log.error("%s[%s] / %d" %(str(e), tvdb_series, tvdb_episode))
def loadEpisode(self, metadata): season_num = metadata.getSeason() episode_num = metadata.getEpisode() tvshow_id = metadata.getTvShowId() log.debug("Loading details for tv show episode id: %s" % str(tvshow_id)) episode = tvdb.get_episode(tvshow_id, season_num, episode_num) log.debug("Loading details: %s" % str(episode)) episodeId = episode['id'] episodename = episode["name"] firstAired = episode['first_aired'] if firstAired: firstAired = firstAired.date() metadata.title(episodename).season(episode['season_number']).episode(episode['episode_number']) metadata.plot(episode["overview"]).premiered(str(firstAired)).code(episodeId) if settings.isSet("load-episode-cover") and episode["image"]: cover = "http://thetvdb.com/banners/%s" % episode["image"] metadata.cover(cover) log.debug("Created episode metadata from TVDB: %s" % metadata) return metadata
def add_episode(self, tvdb_series, tvdb_episode, meta=None): try: if not meta: meta = tvdb.get_episode(tvdb_episode) self.db.execute( ''' insert into episodes (tvdb_series, tvdb_episode, episode_name, season_number, episode_number, aired) VALUES (?,?,?,?,?,?)''', (tvdb_series, tvdb_episode, meta['name'], meta['season_number'], meta['episode_number'], meta['first_aired'])) self.db.commit() log.info("added episode %s" % (meta['name'], )) except Exception, e: log.error("%s[%s] / %d" % (str(e), tvdb_series, tvdb_episode))
def _get_meta(tvdb_episode): try: return json.dumps(tvdb.get_episode(int(tvdb_episode))) except Exception as exc: return None