def get_tvdb_id(show_name, force_search=False): log.debug("Getting tvdb id for %s" % show_name) tvdb_id = None # Skip search in shownamemapping and id cache when force_search = True if not force_search: tvdb_id = show_name_mapping(show_name) if tvdb_id: log.debug("Tvdb id from shownamemapping %s" % tvdb_id) return int(tvdb_id) tvdb_id = TvdbIdCache().get_id(show_name) if tvdb_id: log.debug("Getting tvdb id from cache %s" % tvdb_id) if tvdb_id == -1: log.error("Tvdb id not found in cache for %s" % show_name) return return int(tvdb_id) # Search on tvdb try: show = tvdb_api.Tvdb()[show_name] if show: tvdb_id = show['id'] except: log.error("Tvdb id not found for %s" % show_name) TvdbIdCache().set_id(-1, show_name) if tvdb_id: log.debug("Tvdb id from api %s" % tvdb_id) TvdbIdCache().set_id(tvdb_id, show_name) log.info("%s added to cache with %s" % (show_name, tvdb_id)) return int(tvdb_id)
def xhr_tvdb_episode(tvshowid, season, episode_number): xbmc = jsonrpclib.Server(server_api_address()) t = tvdb_api.Tvdb(apikey=tvdb_apikey) show = xbmc.VideoLibrary.GetTVShowDetails(tvshowid=tvshowid, properties=['imdbnumber'])['tvshowdetails'] if show['imdbnumber'] and show['imdbnumber'].isdigit(): logger.log('TVDB :: Grabbing episode info based on TVBD ID', 'INFO') try: episode = t[int(show['imdbnumber'])][season][episode_number] except tvdb_exceptions.tvdb_shownotfound: return tvdb_except('notfound', show['label']) except tvdb_exceptions.tvdb_error: return tvdb_except('noconnect', show['label']) else: logger.log('TVDB :: No TVDB ID supplied. Searching using title', 'WARNING') try: episode = t[show['label']][season][episode_number] except tvdb_exceptions.tvdb_shownotfound: return tvdb_except('notfound', show['label']) except tvdb_exceptions.tvdb_error: return tvdb_except('noconnect', show['label']) title = '%s - %02dx%02d' % (show['label'], season, episode_number) return render_template('xbmcmm/modals/tvdb_episode_info.html', title=title, episode=tvdb_str2list(episode=episode) )
def tvdbInfo(guessData, tvdbid=None): series = guessData["title"] if 'year' in guessData: fullseries = series + " (" + str(guessData["year"]) + ")" season = guessData["season"] episode = guessData["episodeNumber"] t = tvdb_api.Tvdb(interactive=False, cache=False, banners=False, actors=False, forceConnect=True, language=settings.taglanguage) try: try: tvdbid = str(tvdbid) if tvdbid else t[fullseries]['id'] series = t[int(tvdbid)]['seriesname'] except: tvdbid = t[series]['id'] try: log.info("Matched TV episode as %s (TVDB ID:%d) S%02dE%02d" % (series.encode(sys.stdout.encoding, errors='ignore'), int(tvdbid), int(season), int(episode))) except: log.info("Matched TV episode") return { 'type': 3, 'provid': tvdbid, 'season': season, 'episode': episode } except: log.error("Unable to match against TVDB.") return None
def tvdbInfo(guessData): series = guessData["series"] season = guessData["season"] episode = guessData["episodeNumber"] t = tvdb_api.Tvdb() tvdbid = t[series]['id'] print "Matched TV episode as %s (TVDB ID:%d) S%02dE%02d" % (series.encode( sys.stdout.encoding, errors='ignore'), int(tvdbid), int(season), int(episode)) return 3, tvdbid, season, episode
def xhr_tvdb(show_name, id=None): args = request.args tvdb_params = {'apikey': tvdb_apikey} render_params = {'show_name': show_name} if args: tvdb_params['banners'] = True render_params['img_type'] = args['images'] render_params['template'] = 'xbmcmm/modals/tvdb_images.html' t = tvdb_api.Tvdb(**tvdb_params) if id: if id.isdigit(): logger.log('TVDB :: Grabbing show info based on TVBD ID', 'INFO') try: show = t[int(id)].data except tvdb_exceptions.tvdb_shownotfound: return tvdb_except('notfound', show_name) except tvdb_exceptions.tvdb_error: return tvdb_except('noconnect', show_name) if args: tvdb_show_image_cache(show, args['images']) render_params['show'] = tvdb_str2list(show=show) return render_tvdb(**render_params) elif id.startswith('tt'): logger.log('TVDB :: Grabbing show info based on IMDB ID', 'INFO') try: show = t[show_name].data except tvdb_exceptions.tvdb_shownotfound: return tvdb_except('notfound', show_name) except tvdb_exceptions.tvdb_error: return tvdb_except('noconnect', show_name) if show['imdb_id'] and id == show['imdb_id']: logger.log('TVDB :: Found IMDB ID match', 'INFO') render_params['show'] = tvdb_str2list(show=show) return render_tvdb(**render_params) logger.log('TVDB :: No ID supplied, or ID does not match title. Searching using title', 'WARNING') shows = tvdb_show_search(show_name) if not shows: return tvdb_except('notfound', show_name) render_params['shows'] = shows render_params['template'] = 'xbmcmm/modals/tvdb_info.html' return render_tvdb(**render_params)
def tvdb_show_search(show_name): t = tvdb_api.Tvdb(apikey=tvdb_apikey, custom_ui=maraUI) global tvdb_show_list try: t[show_name] shows = tvdb_show_list except tvdb_exceptions.tvdb_shownotfound: logger.log('Unable to find' + show_name + 'on TVDB', 'ERROR') return [] except tvdb_exceptions.tvdb_error: logger.log('TVDB :: Cannot connect to TVDB', 'ERROR') return [] return shows
def tvdbInfo(guessData, tvdbid=None): series = guessData["series"] if 'year' in guessData: fullseries = series + " (" + str(guessData["year"]) + ")" season = guessData["season"] episode = guessData["episodeNumber"] t = tvdb_api.Tvdb(interactive=False, cache=False, banners=False, actors=False, forceConnect=True, language='en') try: tvdbid = str(tvdbid) if tvdbid else t[fullseries]['id'] series = t[int(tvdbid)]['seriesname'] except: tvdbid = t[series]['id'] try: print("Matched TV episode as %s (TVDB ID:%d) S%02dE%02d" % (series.encode(sys.stdout.encoding, errors='ignore'), int(tvdbid), int(season), int(episode))) except: print("Matched TV episode") return 3, tvdbid, season, episode
def tvdbInfo(guessData, tvdbid=None): series = guessData["series"] if 'year' in guessData: try: series = series + " (" + str(guessData["year"]) + ")" except: pass season = guessData["season"] episode = guessData["episodeNumber"] t = tvdb_api.Tvdb() #tvdbid = t[series]['id'] tvdbid = str(tvdbid) if tvdbid else t[series]['id'] try: print "Matched TV episode as %s (TVDB ID:%d) S%02dE%02d" % ( series.encode(sys.stdout.encoding, errors='ignore'), int(tvdbid), int(season), int(episode)) except: print "Matched TV episode" return 3, tvdbid, season, episode
def _setup(self): self.tvdb = tvdb_api.Tvdb(**self.tvdb_api_parms) self.valid_languages = self.tvdb.config['valid_languages']