Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
    }