def list_trakt_tvshows(results): from trakt import trakt results = sorted(results,key=lambda item: item["show"]["title"].lower().replace("the ", "")) genres_dict = trakt_get_genres() shows = [get_tvshow_metadata_trakt(item["show"], genres_dict) for item in results] items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')] return items
def tv_trakt_recommendations(): from trakt import trakt genres_dict = trakt.trakt_get_genres("tv") shows = trakt.get_recommendations("shows") items = [] for show in shows: items.append(make_tvshow_item(get_tvshow_metadata_trakt(show, genres_dict))) return items
def trakt_tv_recommendations(): from trakt import trakt genres_dict = trakt.trakt_get_genres("tv") shows = trakt.get_recommendations("shows") items = [] for show in shows: items.append(make_tvshow_item(get_tvshow_metadata_trakt(show, genres_dict))) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def list_trakt_tvshows_updated_paginated(results, pages, page): from trakt import trakt results = sorted(results,key=lambda item: item["show"]["title"].lower().replace("the ", "")) genres_dict = trakt_get_genres() shows = [get_tvshow_metadata_trakt(item["show"], genres_dict) for item in results] items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')] nextpage = int(page) + 1 if pages > page: items.append({ 'label': _("Next page").format() + " >> (%s/%s)" % (nextpage, pages), 'path': plugin.url_for("tv_trakt_updated", page=int(page) + 1), 'icon': get_icon_path("item_next"), }) return items
def list_trakt_tvshows_played_paginated(results, pages, page): from trakt import trakt results = sorted(results,key=lambda item: item["show"]["title"].lower().replace("the ", "")) genres_dict = trakt_get_genres() shows = [get_tvshow_metadata_trakt(item["show"], genres_dict) for item in results] items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')] if int(pages) > int(page): items.append({ 'label': _("Next page").format() + " >> (%s/%s)" % (int(page), int(pages)), 'path': plugin.url_for("trakt_tv_played", page=int(page) + 1), 'icon': get_icon_path("item_next"), }) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def trakt_play_episode(id, season, episode, mode): from trakt import trakt id = int(id) season = int(season) episode = int(episode) show = None preason = None prepisode = None dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None show = trakt.get_show(id) if 'name' in show: show_title = show['name'] elif 'title' in show: show_title = show['title'] if show: if show['first_aired']: year = show['first_aired'][:4] else: year = None trakt_ids = get_trakt_ids("trakt", id, show_title, "show", year) preason = trakt.get_season(id, season) if preason: prepisode = trakt.get_episode(id, season, episode) elif not preason and season > 1900: seasons = trakt.get_seasons(id) for item in seasons: if item['first_aired'] != None: if int(item['first_aired'][:4]) == season: season_number = item['number'] preason = trakt.get_season(id, season_number) if not prepisode or not preason or not show: return tvmaze_play_episode(show_title, season, episode, mode) show_info = get_tvshow_metadata_trakt(show) season_info = get_season_metadata_trakt(show_info, preason) episode_info = get_episode_metadata_trakt(season_info, prepisode) title = show_info['name'] 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 = "" items = [] if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode) elif mode == 'library': play_plugin = get_tv_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode) else: play_plugin = mode if mode == 'default' or mode == 'select': players = active_players("tvshows") else: 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)") params = {} for lang in get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_trakt_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids["tmdb"] != None and trakt_ids["tmdb"] != "" and tried != "tmdb": tried = "tmdb" return tvdb_play_episode(trakt_ids["tvdb"], season, episode, mode) elif tried == "tmdb": msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return else: msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, players, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'trakt': id, 'season': season, 'episode': episode})) episode_metadata = get_episode_metadata_trakt(season_info, prepisode) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : str(show_info['fanart'])}, })
def _lists_trakt_show_list(list_items): genres_dict = trakt.trakt_get_genres("tv") if type(list_items) == str: import urllib list_items = eval(urllib.unquote(list_items)) items = [] for list_item in list_items[:25]: item = None item_type = list_item["type"] if item_type == "show": tvdb_id = list_item["show"]["ids"]["tvdb"] show = list_item["show"] info = get_tvshow_metadata_trakt(show, genres_dict) context_menu = [ ( _("Add to library"), "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id)) ), ( _("Show info"), 'Action(Info)' ), ( _("Remove from list"), "RunPlugin({0})".format(plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id)) ) ] item = ({ 'label': info['title'], 'path': plugin.url_for("tv_tvshow", id=tvdb_id), 'context_menu': context_menu, 'thumbnail': info['poster'], 'icon': "DefaultVideo.png", 'poster': info['poster'], 'properties' : {'fanart_image' : info['fanart']}, 'info_type': 'video', 'stream_info': {'video': {}}, 'info': info }) elif item_type == "season": tvdb_id = list_item["show"]["ids"]["tvdb"] season = list_item["season"] show = list_item["show"] show_info = get_tvshow_metadata_trakt(show, genres_dict) season_info = get_season_metadata_trakt(show_info,season, genres_dict) label = "{0} - Season {1}".format(show["title"],season["number"]) context_menu = [ ( _("Add to library"), "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id)) ), ( _("Show info"), 'Action(Info)' ), ( _("Remove from list"), "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=list_item["season"]["number"])) ) ] item = ({ 'label': label, 'path': plugin.url_for(tv_season, id=tvdb_id, season_num=list_item["season"]["number"]), 'context_menu': context_menu, 'info': season_info, 'thumbnail': season_info['poster'], 'icon': "DefaultVideo.png", 'poster': season_info['poster'], 'properties': {'fanart_image': season_info['fanart']}, }) elif item_type == "episode": tvdb_id = list_item["show"]["ids"]["tvdb"] episode = list_item["episode"] show = list_item["show"] season_number = episode["season"] episode_number = episode["number"] show_info = get_tvshow_metadata_trakt(show, genres_dict) episode_info = get_episode_metadata_trakt(show_info, episode) label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number, episode_number, episode_info["title"]) context_menu = [ ( _("Select stream..."), "PlayMedia({0})".format( plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='select')) ), ( _("Show info"), 'Action(Info)' ), ( _("Add to list"), "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id, season=season_number, episode=episode_number)) ), ( _("Remove from list"), "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=season_number, episode = episode_number)) ) ] item = ({ 'label': label, 'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='default'), 'context_menu': context_menu, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'icon': "DefaultVideo.png", 'properties': {'fanart_image': episode_info['fanart']}, }) elif item_type == "movie": movie = list_item["movie"] movie_info = get_trakt_movie_metadata(movie) item = make_movie_item(movie_info, True) if item is not None: items.append(item) if len(list_items) >= 25: items.append({ 'label': _('Next >>'), 'path': plugin.url_for(_lists_trakt_show_list, list_items=str(list_items[25:])) }) return items
def _lists_trakt_show_list(list_items): genres_dict = trakt.trakt_get_genres("tv") if type(list_items) == str: import urllib list_items = eval(urllib.unquote(list_items)) items = [] for list_item in list_items: item = None item_type = list_item["type"] if item_type == "show": tvdb_id = list_item["show"]["ids"]["tvdb"] if tvdb_id != "" and tvdb_id != None: show = list_item["show"] info = get_tvshow_metadata_trakt(show, genres_dict) context_menu = [ (_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("tv_add_to_library", id=tvdb_id))), (_("TV show information"), 'Action(Info)'), ("{0}".format( _("Remove from library").replace( _("Library").lower(), _("Playlist").lower())), "RunPlugin({0})".format( plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id))) ] if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK, bool) == False: item = ({ 'label': info['title'], 'path': plugin.url_for("tv_tvshow", id=tvdb_id), 'context_menu': context_menu, 'thumbnail': info['poster'], 'icon': get_icon_path("tv"), 'poster': info['poster'], 'properties': { 'fanart_image': info['fanart'] }, 'info_type': 'video', 'stream_info': { 'video': {} }, 'info': info }) else: item = make_tvshow_item(info) else: item = None elif item_type == "season": tvdb_id = list_item["show"]["ids"]["tvdb"] season = list_item["season"] show = list_item["show"] show_info = get_tvshow_metadata_trakt(show, genres_dict) season_info = get_season_metadata_trakt(show_info, season, genres_dict) label = "{0} - Season {1}".format(show["title"], season["number"]) context_menu = [ (_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("tv_add_to_library", id=tvdb_id))), ("%s %s" % (_("Season"), _("Information").lower()), 'Action(Info)'), ("{0}".format( _("Remove from library").replace( _("Library").lower(), _("Playlist").lower())), "RunPlugin({0})".format( plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=list_item["season"]["number"]))) ] item = ({ 'label': label, 'path': plugin.url_for("tv_season", id=tvdb_id, season_num=list_item["season"]["number"]), 'context_menu': context_menu, 'info': season_info, 'thumbnail': season_info['poster'], 'icon': get_icon_path("tv"), 'poster': season_info['poster'], 'properties': { 'fanart_image': season_info['fanart'] }, }) elif item_type == "episode": tvdb_id = list_item["show"]["ids"]["tvdb"] episode = list_item["episode"] show = list_item["show"] season_number = episode["season"] episode_number = episode["number"] show_info = get_tvshow_metadata_trakt(show, genres_dict) episode_info = get_episode_metadata_trakt(show_info, episode) label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number, episode_number, episode_info["title"]) context_menu = [ ("{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format( plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='select'))), ("%s %s" % (_("Episode"), _("Information").lower()), 'Action(Info)'), (_("Add to playlist"), "RunPlugin({0})".format( plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id, season=season_number, episode=episode_number))), ("{0}".format( _("Remove from library").replace( _("Library").lower(), _("Playlist").lower())), "RunPlugin({0})".format( plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=season_number, episode=episode_number))) ] item = ({ 'label': label, 'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='default'), 'context_menu': context_menu, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'stream_info': { 'video': {} }, 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'icon': get_icon_path("tv"), 'properties': { 'fanart_image': episode_info['fanart'] }, }) elif item_type == "movie": movie = list_item["movie"] movie_info = get_trakt_movie_metadata(movie) try: tmdb_id = movie_info['tmdb'] except: tmdb_id = "" try: imdb_id = movie_info['imdb'] except: imdb_id = "" if tmdb_id != None and tmdb_id != "": src = "tmdb" id = tmdb_id elif imdb_id != None and mdb_id != "": src = "imdb" id = imdb_id else: src = "" id = "" if src == "": item = None else: if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [ (_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.qlickplay,info=playtrailer,id={0})". format(id)), ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})". format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})" .format(id)) ] elif xbmc.getCondVisibility( "system.hasaddon(script.extendedinfo)"): context_menu = [ (_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.extendedinfo,info=playtrailer,id={0})" .format(id)), ((_("Extended movie info"), _("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})" .format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})" .format(id))) ] else: context_menu = [ (_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("movies_add_to_library", src=src, id=id))) ] context_menu.append( ("%s %s (%s)" % ("Related", _("movies"), "Trakt"), "ActivateWindow(10025,{0})".format( plugin.url_for("movies_related", id=id, page=1)))) context_menu.append( ("{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format( plugin.url_for("movies_play", src=src, id=id, mode='select')))) context_menu.append( (_("Add to playlist"), "RunPlugin({0})".format( plugin.url_for("lists_add_movie_to_list", src=src, id=id)))) context_menu.append( (_("Movie information"), 'Action(Info)')) if imdb_id != None and imdb_id != "": context_menu.append( ("Show Actors", "ActivateWindow(10025,{0})".format( plugin.url_for("people_list_movie_people", id=imdb_id, source="imdb", fanart=get_background_path())))) elif tmdb_id != None and tmdb_id != "": context_menu.append( ("Show Actors", "ActivateWindow(10025,{0})".format( plugin.url_for("people_list_movie_people", id=tmdb_id, source="tmdb", fanart=get_background_path())))) item = make_movie_item(movie_info, True) elif item_type == "person": person_id = list_item['person']['ids']['trakt'] person_tmdb_id = list_item['person']['ids']['tmdb'] context_menu = [] try: import_tmdb() person_images = tmdb.People( person_tmdb_id).images()['profiles'] person_image = 'https://image.tmdb.org/t/p/w640' + person_images[ 0]['file_path'] except: person_image = '' person_name = to_utf8(list_item['person']['name']) item = ({ 'label': person_name, 'path': plugin.url_for("trakt_movies_person", person_id=person_id), 'context_menu': context_menu, #'info': season_info, 'thumbnail': person_image, 'icon': get_icon_path("movies"), 'poster': person_image, 'properties': { 'fanart_image': person_image }, }) if item is not None: items.append(item) for item in items: item['properties'] = {'fanart_image': get_background_path()} return items
def list_trakt_episodes(result, with_time=False): genres_dict = trakt_get_genres() items = [] for item in result: if 'episode' in item: episode = item['episode'] else: episode = item id = episode["ids"].get("tvdb") if not id: continue season_num = episode["season"] episode_num = episode["number"] info = get_tvshow_metadata_trakt(item["show"], genres_dict) info['season'] = episode["season"] info['episode'] = episode["number"] info['title'] = episode["title"] info['aired'] = episode.get('first_aired','') info['premiered'] = episode.get('first_aired','') info['rating'] = episode.get('rating', '') info['plot'] = episode.get('overview','') info['tagline'] = episode.get('tagline') info['votes'] = episode.get('votes','') #info['poster'] = episode['images']['poster']['thumb'] label = "{0} - S{1:02d}E{2:02d} - {3}".format(item["show"]["title"], season_num, episode_num, episode["title"]) if with_time and info['premiered']: airtime = time.strptime(item["first_aired"], "%Y-%m-%dt%H:%M:%S.000Z") airtime = time.strftime("%Y-%m-%d %H:%M", airtime) label = "{0}\n{1}".format(label, airtime) context_menu = [ ( _("Select stream..."), "PlayMedia({0})".format(plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select')) ), ( _("Show info"), 'Action(Info)' ) ] items.append({'label': label, 'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'), 'context_menu': context_menu, 'info': info, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'thumbnail': info['poster'], 'poster': info['poster'], 'icon': "DefaultVideo.png", 'properties' : {'fanart_image' : info['fanart']}, }) plugin.set_content('episodes') return items
def list_trakt_episodes(result, with_time=False): genres_dict = trakt_get_genres() items = [] for item in result: if 'episode' in item: episode = item['episode'] else: episode = item id = episode["ids"].get("tvdb") if not id: continue season_num = episode["season"] episode_num = episode["number"] info = get_tvshow_metadata_trakt(item["show"], genres_dict) info['season'] = episode["season"] info['episode'] = episode["number"] info['title'] = episode["title"] info['aired'] = episode.get('first_aired', '') info['premiered'] = episode.get('first_aired', '') info['rating'] = episode.get('rating', '') info['plot'] = episode.get('overview', '') info['tagline'] = episode.get('tagline') info['votes'] = episode.get('votes', '') #info['poster'] = episode['images']['poster']['thumb'] label = "{0} - S{1:02d}E{2:02d} - {3}".format(item["show"]["title"], season_num, episode_num, episode["title"]) if with_time and info['premiered']: airtime = time.strptime(item["first_aired"], "%Y-%m-%dt%H:%M:%S.000Z") airtime = time.strftime("%Y-%m-%d %H:%M", airtime) label = "{0}\n{1}".format(label, airtime) context_menu = [ (_("Select stream..."), "PlayMedia({0})".format( plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select'))), (_("Show info"), 'Action(Info)'), (_("Add to list"), "RunPlugin({0})".format( plugin.url_for("lists_add_episode_to_list", src='tvdb', id=id, season=season_num, episode=episode_num))), ] items.append({ 'label': label, 'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'), 'context_menu': context_menu, 'info': info, 'is_playable': True, 'info_type': 'video', 'stream_info': { 'video': {} }, 'thumbnail': info['poster'], 'poster': info['poster'], 'icon': "DefaultVideo.png", 'properties': { 'fanart_image': info['fanart'] }, }) plugin.set_content('episodes') return items
def _lists_trakt_show_list(list_items): genres_dict = trakt.trakt_get_genres("tv") if type(list_items) == str: import urllib list_items = eval(urllib.unquote(list_items)) items = [] for list_item in list_items: item = None item_type = list_item["type"] if item_type == "show": tvdb_id = list_item["show"]["ids"]["tvdb"] if tvdb_id != "" and tvdb_id != None: show = list_item["show"] info = get_tvshow_metadata_trakt(show, genres_dict) context_menu = [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id)) ), ( _("TV show information"), 'Action(Info)' ), ( "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())), "RunPlugin({0})".format(plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id)) ) ] if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK, bool) == False: item = ({ 'label': info['title'], 'path': plugin.url_for("tv_tvshow", id=tvdb_id), 'context_menu': context_menu, 'thumbnail': info['poster'], 'icon': get_icon_path("tv"), 'poster': info['poster'], 'properties' : {'fanart_image' : info['fanart']}, 'info_type': 'video', 'stream_info': {'video': {}}, 'info': info }) else: item = make_tvshow_item(info) else: item = None elif item_type == "season": tvdb_id = list_item["show"]["ids"]["tvdb"] season = list_item["season"] show = list_item["show"] show_info = get_tvshow_metadata_trakt(show, genres_dict) season_info = get_season_metadata_trakt(show_info,season, genres_dict) label = "{0} - Season {1}".format(show["title"],season["number"]) context_menu = [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id)) ), ( "%s %s" % (_("Season"), _("Information").lower()), 'Action(Info)' ), ( "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())), "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=list_item["season"]["number"])) ) ] item = ({ 'label': label, 'path': plugin.url_for("tv_season", id=tvdb_id, season_num=list_item["season"]["number"]), 'context_menu': context_menu, 'info': season_info, 'thumbnail': season_info['poster'], 'icon': get_icon_path("tv"), 'poster': season_info['poster'], 'properties': {'fanart_image': season_info['fanart']}, }) elif item_type == "episode": tvdb_id = list_item["show"]["ids"]["tvdb"] episode = list_item["episode"] show = list_item["show"] season_number = episode["season"] episode_number = episode["number"] show_info = get_tvshow_metadata_trakt(show, genres_dict) episode_info = get_episode_metadata_trakt(show_info, episode) label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number, episode_number, episode_info["title"]) context_menu = [ ( "{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format( plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='select')) ), ( "%s %s" % (_("Episode"), _("Information").lower()), 'Action(Info)' ), ( _("Add to playlist"), "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id, season=season_number, episode=episode_number)) ), ( "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())), "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id, season=season_number, episode = episode_number)) ) ] item = ({ 'label': label, 'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number, episode=episode_number, mode='default'), 'context_menu': context_menu, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'icon': get_icon_path("tv"), 'properties': {'fanart_image': episode_info['fanart']}, }) elif item_type == "movie": movie = list_item["movie"] movie_info = get_trakt_movie_metadata(movie) try: tmdb_id = movie_info['tmdb'] except: tmdb_id = "" try: imdb_id = movie_info['imdb'] except: imdb_id = "" if tmdb_id != None and tmdb_id != "": src = "tmdb" id = tmdb_id elif imdb_id != None and mdb_id != "": src = "imdb" id = imdb_id else: src = "" id = "" if src == "": item = None else: if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))] elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), ( (_("Extended movie info"),_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id)))] else: context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))] context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"), "ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1)))) context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select')))) context_menu.append((_("Add to playlist"), "RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id)))) context_menu.append((_("Movie information"), 'Action(Info)')) if imdb_id != None and imdb_id != "": context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=imdb_id, source="imdb", fanart=get_background_path())))) elif tmdb_id != None and tmdb_id != "": context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=tmdb_id, source="tmdb", fanart=get_background_path())))) item = make_movie_item(movie_info, True) elif item_type == "person": person_id = list_item['person']['ids']['trakt'] person_tmdb_id = list_item['person']['ids']['tmdb'] context_menu= [] try: import_tmdb() person_images = tmdb.People(person_tmdb_id).images()['profiles'] person_image = 'https://image.tmdb.org/t/p/w640' + person_images[0]['file_path'] except: person_image = '' person_name = to_utf8(list_item['person']['name']) item = ({ 'label': person_name, 'path': plugin.url_for("trakt_movies_person", person_id=person_id), 'context_menu': context_menu, #'info': season_info, 'thumbnail': person_image, 'icon': get_icon_path("movies"), 'poster': person_image, 'properties': {'fanart_image': person_image}, }) if item is not None: items.append(item) for item in items: item['properties'] = {'fanart_image' : get_background_path()} return items
def list_aired_episodes(result): genres_dict = trakt_get_genres() items = [] count = 1 if not result: return None for day in result.iteritems(): day_nr = 1 for episode in day[1]: banner = episode["show"]["images"]["banner"]["full"] fanart = episode["show"]["images"]["fanart"]["full"] poster = episode["show"]["images"]["poster"]["full"] if episode["episode"]["title"] != None: episode_title = (episode["episode"]["title"]).encode('utf-8') elif episode["episode"]["title"] == None: episode_title = "TBA" try: id = episode["show"]["ids"].get("tvdb") except: id = episode["show"]["ids"]["tvdb"] if not id: continue season_num = episode["episode"]["season"] episode_num = episode["episode"]["number"] tvshow_title = (episode["show"]["title"]).encode('utf-8') info = get_tvshow_metadata_trakt(episode["show"], genres_dict) info['season'] = episode["episode"]["season"] info['episode'] = episode["episode"]["number"] info['title'] = episode["episode"]["title"] info['aired'] = episode["episode"].get('first_aired','') info['premiered'] = episode["episode"].get('first_aired','') info['rating'] = episode["episode"].get('rating', '') info['plot'] = episode["episode"].get('overview','') info['tagline'] = episode["episode"].get('tagline') info['votes'] = episode["episode"].get('votes','') info['showtitle'] = episode["show"]["title"] #info['poster'] = episode['images']['poster']['thumb'] label = "{0} - S{1:02d}E{2:02d} - {3}".format(tvshow_title, season_num, episode_num, episode_title) context_menu = [ ( _("Select stream..."), "PlayMedia({0})".format(plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select')) ), ( _("Show info"), 'Action(Info)' ), ( _("Add to list"), "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=id, season=season_num, episode=episode_num)) ), ] items.append({'label': label, 'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'), 'context_menu': context_menu, 'info': info, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'thumbnail': info['poster'], 'poster': info['poster'], 'icon': "DefaultVideo.png", 'properties' : {'fanart_image' : info['fanart']}, }) day_nr = day_nr +1 plugin.set_content('episodes') if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)