Esempio n. 1
0
def tmdb_tv_most_popular(page, raw=False):
    from resources.lib.TheMovieDB import TV
    result = TV().popular(page=page, language='en')
    if raw:
        return result
    else:
        return list_tvshows(result)
Esempio n. 2
0
def item_images(type, tmdb_id=None, imdb_id=None, tvdb_id=None, name=None):
	from resources.lib.TheMovieDB import Movies, TV, Find
	poster = ''
	fanart = ''
	response = ''
	if not tmdb_id and not imdb_id and not tvdb_id and not tvrage_id and not name:
		return None
	if type == 'movie' and tmdb_id != None and tmdb_id != '':
		response = Movies(tmdb_id).info()
	elif type == 'tv' and tmdb_id != None and tmdb_id != '':
		response = TV(tmdb_id).info()
	elif type == 'tv' and tvdb_id != None and tvdb_id != '':
		response = Find(tvdb_id).info(external_source='tvdb_id')
	elif imdb_id != None and imdb_id != '':
		response = Find(imdb_id).info(external_source='imdb_id')
	if response == '':
		return False
	if tmdb_id == None:
		if type == 'movie':
			response = response.get('movie_results')
		elif type == 'tv':
			response = response.get('tv_results')
		elif type == 'season':
			response = response.get('season_results')
		elif type == 'episode':
			response = response.get('episode_results')
	if isinstance(response, dict):
		fanart = 'https://image.tmdb.org/t/p/original/%s' % response.get('backdrop_path')
		poster = 'https://image.tmdb.org/t/p/original/%s' % response.get('poster_path')
	elif isinstance(response, list):
		fanart = 'https://image.tmdb.org/t/p/original/%s' % response['backdrop_path']
		poster = 'https://image.tmdb.org/t/p/original/%s' % response['poster_path']
	images = [poster, fanart]
	return images
Esempio n. 3
0
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
Esempio n. 4
0
def tmdb_play_episode(id, season, episode):
	from resources.lib.TheMovieDB import TV, TV_Seasons, TV_Episodes
	tried = 'tvdb'
	id = int(id)
	season = int(season)
	episode = int(episode)
	dbid = xbmc.getInfoLabel('ListItem.DBID')
	try:
		dbid = int(dbid)
	except:
		dbid = None
	show = TV(id).info(language='en', append_to_response='external_ids,images')
	if 'first_air_date' in show and show['first_air_date'] != None:
		year = show['first_air_date'][:4]
	else:
		year = None
	trakt_ids = play_base.get_trakt_ids('tmdb', id)
	if 'status_code' in show:
		return trakt_play_episode(trakt_ids['trakt'], season, episode)
	if 'name' in show:
		title = show['name']
	else:
		title = None
	show_info = meta_info.get_tvshow_metadata_tmdb(show)
	title = show_info['name']
	preason = TV_Seasons(id, season).info(language='en', append_to_response='external_ids,images')
	if 'The resource you requested could not be found' in str(preason):
		return trakt_play_episode(trakt_ids['trakt'], season, episode)
	season_info = meta_info.get_season_metadata_tmdb(show_info, preason)
	prepisode = TV_Episodes(id, season, episode).info(language='en', append_to_response='external_ids,images')
	if prepisode == '{u"status_code": 34, u"status_message": u"The resource you requested could not be found."}':
		return trakt_play_episode(trakt_ids['tmdb'], season, episode)
	episode_info = meta_info.get_episode_metadata_tmdb(season_info, prepisode)
	if show_info['poster'] != None and show_info['poster'] != '':
		show_poster = show_info['poster']
	else:
		show_poster = ''
	if show_info['fanart'] != None and show_info['fanart'] != '':
		show_fanart = show_info['fanart']
	else:
		show_fanart = ''
	episodes = preason['episodes']
	items = []
	play_plugin = meta_players.ADDON_SELECTOR.id
	players = meta_players.get_players('tvshows')
	players = [p for p in players if p.id == play_plugin] or players
	if not players:
		return xbmc.executebuiltin('Action(Info)')
	trakt_ids = play_base.get_trakt_ids('tmdb', id, show_info['name'], 'show', show['first_air_date'][:4])
	params = {}
	for lang in meta_players.get_needed_langs(players):
		if show['name'] is None:
			continue
		episode_parameters = get_tmdb_episode_parameters(show, preason, prepisode)
		if episode_parameters is not None:
			params[lang] = episode_parameters
		else:
			if trakt_ids['trakt'] != None and trakt_ids['trakt'] != '':
				return trakt_play_episode(trakt_ids['trakt'], season, episode)
			else:
				msg = 'No TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode)
				plugin.ok('Episode information not found', msg)
		if trakt_ids != None:
			params[lang].update(trakt_ids)
		params[lang]['info'] = show_info
		params[lang] = text.to_unicode(params[lang])
	link = play_base.on_play_video(players, params, trakt_ids)
	if link:
		plugin.setProperty('plugin.video.openmeta.data', json.dumps(
			{
				'dbid': dbid,
				'tmdb': id,
				'season': season,
				'episode': episode
			}))
		episode_metadata = meta_info.get_episode_metadata_tmdb(season_info, prepisode)
		play_base.action_play(
			{
				'label': episode_info['title'],
				'path': link,
				'info': [],
				'is_playable': True,
				'info_type': 'video',
				'thumbnail': episode_info['poster'],
				'poster': episode_info['poster'],
				'fanart': str(show_info['fanart'])
			})
Esempio n. 5
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
Esempio n. 6
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
    }