def tvdb_tv_search_term(term, page): search_results = TVDB.search(term, language='en') items = [] load_full_tvshow = lambda tvshow : TVDB.get_show(tvshow['id'], full=True) for tvdb_show in executor.execute(load_full_tvshow, search_results, workers=10): info = build_tvshow_info(tvdb_show) items.append(make_tvshow_item(info)) return items
def get_tvdb_id_from_name(name, lang): tools.show_busy() search_results = TVDB.search(name, language=lang) if not search_results: tools.hide_busy() plugin.ok( 'TV show not found', 'no show information found for %s in tvdb' % text.to_utf8(name)) items = [] for show in search_results: if show['seriesname'] == name: if 'firstaired' in show: show['year'] = int(show['firstaired'].split('-')[0].strip()) else: show['year'] = 'unknown' items.append(show) if len(items) > 1: selection = plugin.select('Choose TV Show', [ '%s (%s)' % (text.to_utf8(s['seriesname']), s['year']) for s in items ]) else: selection = 0 tools.hide_busy() if selection != -1: return items[selection]['id']
def tv_add_to_library_parsed(id, player): if id.startswith('tt'): try: id = TVDB.search_by_imdb(id) except: plugin.ok('TV show not found', 'no show information found for %s in TheTVDB' % id) library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) show = TVDB[int(id)] imdb = show['imdb_id'] library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) if lib_tvshows.add_tvshow_to_library(library_folder, show, player): plugin.setProperty('plugin.video.openmeta.clean_library', 'true') tools.scan_library(path=plugin.get_setting('tv_library_folder', unicode))
def tmdb_to_tvdb(tmdb_show): from resources.lib.TheMovieDB import TV tvdb_show = None name = tmdb_show['original_name'] try: year = int(text.parse_year(tmdb_show['first_air_date'])) except: year = '' results = [x['id'] for x in TVDB.search(name, year)] if len(results) != 1: id = TV(tmdb_show['id']).external_ids().get('tvdb_id', None) if id: results = [id] if results: tvdb_show = TVDB[results[0]] return tvdb_show, tmdb_show
def make_tvshow_item(info): from resources.lib.TheMovieDB import TV, Find try: tvdb_id = info['tvdb'] except: tvdb_id = '' if tvdb_id == '': try: tvdb_id = info['tvdb_id'] except: tvdb_id = '' try: tmdb_id = info['tmdb'] except: tmdb_id = '' if tmdb_id == '': try: tmdb_id = info['id'] except: tmdb_id = '' try: imdb_id = info['imdb_id'] except: imdb_id = '' if imdb_id == '': try: imdb_id = info['imdb'] except: imdb_id = '' if not info['poster']: info['poster'] = None if not info['fanart']: info['fanart'] = None if info['poster'] == None or info['poster'] == '': if tmdb_id != None and tmdb_id != '': show = TV(tmdb_id).info() if show['poster_path'] != None and show['poster_path'] != '': info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[ 'poster_path'] if info['fanart'] == None or info['fanart'] == '': if show['backdrop_path'] != None and show[ 'backdrop_path'] != '': info[ 'fanart'] = u'https://image.tmdb.org/t/p/original' + show[ 'backdrop_path'] if info['poster'] == None or info['poster'] == '': if tvdb_id != None and tvdb_id != '': show = TVDB.get_show(int(tvdb_id), full=False) if show != None: if show['seriesname'] != None and show['seriesname'] != '': if show.get('poster', '') != None and show.get( 'poster', '') != '': info['poster'] = show.get('poster', '') if info['fanart'] == None or info['fanart'] == '': if show.get('fanart', '') != None and show.get( 'fanart', '') != '': info['fanart'] = show.get('fanart', '') if info['poster'] == None or info['poster'] == '': if imdb_id != None and imdb_id != '': preshow = Find(imdb_id).info(external_source='imdb_id') proshow = preshow['tv_results'] if proshow != []: show = proshow[0] else: show = [] if show != []: if show['poster_path'] != None and show['poster_path'] != '': info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[ 'poster_path'] if info['fanart'] == None or info['fanart'] == '': if show['backdrop_path'] != None and show[ 'backdrop_path'] != '': info[ 'fanart'] = u'https://image.tmdb.org/t/p/original' + show[ 'backdrop_path'] if info['fanart'] == None or info['fanart'] == '': info['fanart'] = plugin.get_addon_fanart() if xbmc.getCondVisibility('system.hasaddon(script.extendedinfo)'): context_menu = [ ('OpenInfo', 'RunScript(script.extendedinfo,info=extendedtvinfo,tvdb_id=%s)' % tvdb_id), ('TV trailer', 'RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id=%s)' % tvdb_id), ('Add to library', 'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id)) ] else: context_menu = [ ('Add to library', 'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id)) ] properties = {} try: if traktenabled and countenabled: if 'trakt_id' in info.keys() and info['trakt_id'] != '': id = info['trakt_id'] else: id = Trakt.find_trakt_ids('tvdb', tvdb_id, 'show')['trakt'] playdata = get_show_play_count(id) properties = { 'TotalSeasons': len(playdata['seasons']), 'TotalEpisodes': playdata['aired'], 'WatchedEpisodes': playdata['completed'], 'UnWatchedEpisodes': playdata['aired'] - playdata['completed'] } if properties['UnWatchedEpisodes'] == 0: info.update({'playcount': 1}) except: pass showitem = { 'label': text.to_utf8(info['title']), 'path': plugin.url_for('tv_tvshow', id=tvdb_id), 'context_menu': context_menu, 'thumbnail': info['poster'], 'poster': info['poster'], 'fanart': info['fanart'], 'info_type': 'video', 'stream_info': { 'video': {} }, 'properties': properties, 'info': info } if enablefanart: try: art = get_fanarttv_art(tvdb_id, query='show') art = checkart(art) showitem.update(art) except: pass return showitem
def get_tvdb_id_from_imdb_id(imdb_id): tvdb_id = TVDB.search_by_imdb(imdb_id) if not tvdb_id: plugin.ok('TV show not found', 'no show information found for %s in tvdb' % imdb_id) return tvdb_id
def make_tvshow_item(info): from resources.lib.TheMovieDB import TV, Find try: tvdb_id = info['tvdb'] except: tvdb_id = '' if tvdb_id == '': try: tvdb_id = info['tvdb_id'] except: tvdb_id = '' try: tmdb_id = info['tmdb'] except: tmdb_id = '' if tmdb_id == '': try: tmdb_id = info['id'] except: tmdb_id = '' try: imdb_id = info['imdb_id'] except: imdb_id = '' if imdb_id == '': try: imdb_id = info['imdb'] except: imdb_id = '' if not info['poster']: info['poster'] = None if not info['fanart']: info['fanart'] = None if info['poster'] == None or info['poster'] == '': if tmdb_id != None and tmdb_id != '': show = TV(tmdb_id).info() if show['poster_path'] != None and show['poster_path'] != '': info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[ 'poster_path'] if info['fanart'] == None or info['fanart'] == '': if show['backdrop_path'] != None and show[ 'backdrop_path'] != '': info[ 'fanart'] = u'https://image.tmdb.org/t/p/original' + show[ 'backdrop_path'] if info['poster'] == None or info['poster'] == '': if tvdb_id != None and tvdb_id != '': show = TVDB.get_show(int(tvdb_id), full=False) if show != None: if show['seriesname'] != None and show['seriesname'] != '': if show.get('poster', '') != None and show.get( 'poster', '') != '': info['poster'] = show.get('poster', '') if info['fanart'] == None or info['fanart'] == '': if show.get('fanart', '') != None and show.get( 'fanart', '') != '': info['fanart'] = show.get('fanart', '') if info['poster'] == None or info['poster'] == '': if imdb_id != None and imdb_id != '': preshow = Find(imdb_id).info(external_source='imdb_id') proshow = preshow['tv_results'] if proshow != []: show = proshow[0] else: show = [] if show != []: if show['poster_path'] != None and show['poster_path'] != '': info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[ 'poster_path'] if info['fanart'] == None or info['fanart'] == '': if show['backdrop_path'] != None and show[ 'backdrop_path'] != '': info[ 'fanart'] = u'https://image.tmdb.org/t/p/original' + show[ 'backdrop_path'] if info['fanart'] == None or info['fanart'] == '': info['fanart'] = plugin.get_addon_fanart() if xbmc.getCondVisibility('system.hasaddon(script.extendedinfo)'): context_menu = [ ('OpenInfo', 'RunScript(script.extendedinfo,info=extendedtvinfo,tvdb_id=%s)' % tvdb_id), ('TV trailer', 'RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id=%s)' % tvdb_id), ('Add to library', 'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id)) ] else: context_menu = [ ('Add to library', 'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id)) ] return { 'label': text.to_utf8(info['title']), 'path': plugin.url_for('tv_tvshow', id=tvdb_id), 'context_menu': context_menu, 'thumbnail': info['poster'], 'poster': info['poster'], 'fanart': info['fanart'], 'info_type': 'video', 'stream_info': { 'video': {} }, 'info': info }