def lists_trakt_my_lists(): lists = trakt.trakt_get_lists() items = [] for list in lists: name = list["name"] user = list["user"]["username"] slug = list["ids"]["slug"] items.append({ 'label': name, 'path': plugin.url_for("lists_trakt_show_list", user=user, slug=slug), 'context_menu': [(_("Scan item to library"), "RunPlugin({0})".format( plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug))), ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("lists_trakt_play_random", user=user, slug=slug)))], 'icon': get_icon_path("traktmylists"), 'thumbnail': get_icon_path("traktmylists"), }) fanart = plugin.addon.getAddonInfo('fanart') for item in items: item['properties'] = {'fanart_image': get_background_path()} if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def people_list_show_people(id, source, fanart): items = [] try: if source == "imdb": people = trakt.get_show_people(id) else: xbmcgui.Dialog().ok("Error", "No cast info found") return plugin.finish(items=[]) except: xbmcgui.Dialog().ok("Error", "No cast info found") return plugin.finish(items=[]) if "cast" in people: for actor in people["cast"]: context_menu = [ ( "Convert to bob_xml", "RunPlugin({0})".format( plugin.url_for("bob_convert_person_to_xml", trakt_id=actor["person"]["ids"]["trakt"])) ) ] image = get_person_artwork(actor) label = "{0} ({1})".format(to_utf8(actor["person"]["name"]), to_utf8(actor["character"])) info = actor["person"]["biography"] items.append({'label': label, 'path': plugin.url_for("people_list_person_select", id=actor["person"]["ids"]["trakt"], name=to_utf8(actor["person"]["name"])), 'info': info, 'thumbnail': image, 'poster': image, 'context_menu': context_menu, 'icon': "DefaultVideo.png", 'properties': {'fanart_image': fanart}, }) return plugin.finish(items=items)
def tmdb_tv_top_rated(page): """ Top rated shows """ import_tmdb() result = tmdb.TV().top_rated(page=page, language=LANG) items = list_tvshows(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_tv_most_popular(page): """ Most popular shows """ import_tmdb() result = tmdb.TV().popular(page=page, language=LANG) items = list_tvshows(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_tv_now_playing(page): """ On the air shows """ import_tmdb() result = tmdb.TV().on_the_air(page=page, language=LANG) items = list_tvshows(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def lists_trakt_liked_lists(page): lists, pages = trakt.trakt_get_liked_lists(page) items = [] for list in lists: info = list["list"] name = info["name"] user = info["user"]["username"] slug = info["ids"]["slug"] items.append({ 'label': name, 'path': plugin.url_for("lists_trakt_show_list", user = user, slug = slug), 'context_menu': [ ( _("Add list to library"), "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug)) ) ], 'icon': get_icon_path("traktlikedlists"), }) if pages > page: items.append({ 'label': _("Next >>"), 'path': plugin.url_for("lists_trakt_liked_lists", page = int(page) + 1), 'icon': get_icon_path("traktlikedlists"), }) 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_movie_items_with_genres(results, pages, page): from trakt import trakt genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [ get_trakt_movie_metadata(item["movie"], genres_dict) for item in results ] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > 1: args = caller_args() args['page'] = page + 1 items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'path': plugin.url_for(caller_name(), **args), 'icon': get_icon_path("item_next"), 'properties': { 'fanart_image': get_background_path() } }) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_movies_search_term(term, page): """ Perform search of a specified <term>""" import_tmdb() result = tmdb.Search().movie(query=term, language = LANG, page = page) items = list_tmdb_movies(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_movies_most_popular(page): """ Most popular movies """ import_tmdb() result = tmdb.Movies().popular(language=LANG, page=page) items = list_tmdb_movies(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def movies_genre(id, page): """ Movies by genre id """ import_tmdb() result = tmdb.Genres(id).movies(id=id, language=LANG, page=page) items = list_tmdb_movies(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tv_genre(id, page): """ Shows by genre """ import_tmdb() result = tmdb.Discover().tv(with_genres=id, page=page, language=LANG) items = list_tvshows(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def lists_trakt_my_lists(): lists = trakt.trakt_get_lists() items = [] for list in lists: name = list["name"] user = list["user"]["username"] slug = list["ids"]["slug"] items.append({ 'label': name, 'path': plugin.url_for("lists_trakt_show_list", user = user, slug = slug), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug)) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("lists_trakt_play_random", user=user, slug=slug)) ) ], 'icon': get_icon_path("traktmylists"), 'thumbnail': get_icon_path("traktmylists"), }) fanart = plugin.addon.getAddonInfo('fanart') for item in items: item['properties'] = {'fanart_image' : get_background_path()} 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_movies_trending_paginated(results, pages, page): from trakt import trakt results = sorted( results, key=lambda item: item["movie"]["title"].lower().replace("the ", "")) genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [ get_trakt_movie_metadata(item["movie"], genres_dict) for item in results ] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > page: items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'path': plugin.url_for("trakt_movies_trending", page=page + 1), 'icon': get_icon_path("item_next"), 'properties': { 'fanart_image': get_background_path() }, }) 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_tmdb_items(result): if FORCE == True: plugin.set_view_mode(VIEW) genres_dict = get_base_genres() movies = [get_movie_metadata(item, None) for item in result['results']] items = [make_movie_item(movie) for movie in movies] if 'page' in result: page = int(result['page']) pages = int(result['total_pages']) args = caller_args() if pages > page: args['page'] = str(page + 1) items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'icon': get_icon_path("item_next"), 'path': plugin.url_for(caller_name(), **args), 'properties': { 'fanart_image': get_background_path() }, }) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_tv_search_term(term, page): """ Perform search of a specified <term>""" import_tmdb() result = tmdb.Search().tv(query=term, language = LANG, page = page) items = list_tvshows(result) 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_movies_basic(results): from trakt import trakt genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [get_trakt_movie_metadata(item, genres_dict) for item in results] items = [make_movie_item(movie) for movie in movies] if FORCE == True: return plugin.finish(items=items, sort_methods=SORTRAKT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORTRAKT)
def list_trakt_movies_basic(results): from trakt import trakt genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [get_trakt_movie_metadata(item, genres_dict) for item in results] items = [make_movie_item(movie) for movie in movies] if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_movies_genres(): """ List all movie genres """ genres = get_base_genres() items = sorted([{ 'label': name, 'icon': get_genre_icon(id), 'path': plugin.url_for("tmdb_movies_genre", id=id, page='1'), 'context_menu': [("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("tmdb_movies_play_random_genre", id = id)))]} for id, name in genres.items()], key=lambda k: k['label']) for item in items: item['properties'] = {'fanart_image' : get_background_path()} if FORCE == True: plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def list_trakt_movies_related(results): from trakt import trakt results = sorted(results,key=lambda item: item["title"].lower().replace("the ", "")) genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [get_trakt_movie_metadata(item, genres_dict) for item in results] items = [make_movie_item(movie) for movie in movies] if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def movies_trakt_recommendations(): from trakt import trakt genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = trakt.get_recommendations("movies") items = [] for movie in movies: items.append(make_movie_item(get_trakt_movie_metadata(movie, 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 movies_related(id): import_tmdb() movie = tmdb.Movies(id).info() imdb_id = movie.get('imdb_id') from trakt import trakt results = trakt.trakt_get_related_movies_paginated(imdb_id) items = list_trakt_movies_related(results) 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_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 trakt_my_movies(): items = [ { 'label': "{0} ({1})".format(_("Library"), "collection"), 'path': plugin.url_for("trakt_movies_collection"), 'icon': get_icon_path("traktcollection"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_collection_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_collection")) ) ] }, { 'label': "{0} {1} ({2})".format(_("Unwatched"), _("movies"), "watchlist"), 'path': plugin.url_for("trakt_movies_watchlist"), 'icon': get_icon_path("traktwatchlist"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_watchlist_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_watchlist")) ) ] }, { 'label':"{0} ({1})".format(_("Find similar"), "recommendations"), 'path': plugin.url_for("trakt_movies_recommendations"), 'icon': get_icon_path("traktrecommendations"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_recommendations_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_recommendation")) ) ] } ] for item in items: item['properties'] = {'fanart_image' : get_background_path()} if FORCE == True: plugin.finish(items=items, view_mode=VIEW) else: return plugin.finish(items=items)
def trakt_my_movies(): items = [ { 'label': "{0} ({1})".format(_("Library"), "collection"), 'path': plugin.url_for("trakt_movies_collection"), 'icon': get_icon_path("traktcollection"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_collection_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_collection")) ) ] }, { 'label': "{0} {1} ({2})".format(_("Unwatched"), _("movies"), "watchlist"), 'path': plugin.url_for("trakt_movies_watchlist"), 'icon': get_icon_path("traktwatchlist"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_watchlist_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_watchlist")) ) ] }, { 'label':"{0} ({1})".format(_("Find similar"), "recommendations"), 'path': plugin.url_for("trakt_movies_recommendations"), 'icon': get_icon_path("traktrecommendations"), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("trakt_movies_recommendations_to_library")) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("trakt_movies_play_random_recommendation")) ) ] } ] for item in items: item['properties'] = {'fanart_image' : get_background_path()} if FORCE == True: plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def list_trakt_movies_trending_paginated(results, pages, page): from trakt import trakt results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", "")) genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results] items = [make_movie_item(movie) for movie in movies] if int(pages) > int(page): items.append({ 'label': _("Next page").format() + " >> (%s/%s)" % (int(page) + 1, int(pages)), 'path': plugin.url_for("trakt_movies_trending", 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 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 lists_search_for_lists_term(term, page): lists, pages = trakt.search_for_list(term, page) page = int(page) pages = int(pages) items = [] for list in lists: if "list" in list: list_info = list["list"] else: continue name = list_info["name"] user = list_info["username"] slug = list_info["ids"]["slug"] total = list_info["item_count"] info = {} info['title'] = name if "description" in list_info: info["plot"] = list_info["description"] else: info["plot"] = _("No description available") if user != None and total != None and total != 0: items.append({ 'label': "{0} - {1} ({2})".format(to_utf8(name), to_utf8(user), total), 'path': plugin.url_for("lists_trakt_show_list", user=user, slug=slug), 'context_menu': [ ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug)) ), ( "{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format(plugin.url_for("lists_trakt_play_random", user=user, slug=slug)) ) ], 'info': info, 'icon': get_icon_path("traktlikedlists"), 'thumbnail': get_icon_path("traktlikedlists"), }) fanart = plugin.addon.getAddonInfo('fanart') for item in items: item['properties'] = {'fanart_image' : get_background_path()} if pages > page: items.append({ 'label': _("Next page").format() + " >> (%s/%s)" % (page + 1, pages), 'path': plugin.url_for("lists_search_for_lists_term", term = term, page=page + 1), 'icon': get_icon_path("item_next"), 'thumbnail': 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_tv_next_episodes(): from trakt import trakt list = [] result = trakt.trakt_get_next_episodes() for episode in result: trakt_id = episode["show"]["ids"]["trakt"] episode_info = trakt.get_episode(trakt_id, episode["season"], episode["number"]) first_aired_string = episode_info["first_aired"] if first_aired_string: first_aired = time.mktime(time.strptime(first_aired_string[:19], "%Y-%m-%dT%H:%M:%S")) if first_aired < time.time(): list.append(episode) items = list_trakt_episodes(list) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def lists_search_for_lists_term(term,page): lists, pages = trakt.search_for_list(term, page) page = int(page) pages = int(pages) items = [] for list in lists: if "list" in list: list_info = list["list"] else: continue name = list_info["name"] user = list_info["username"] slug = list_info["ids"]["slug"] info = {} info['title'] = name if "description" in list_info: info["plot"] = list_info["description"] else: info["plot"] = _("No description available") if user != None: items.append({ 'label': "{0} {1} {2}".format(to_utf8(name), _("by"), to_utf8(user)), 'path': plugin.url_for("lists_trakt_show_list", user=user, slug=slug), 'context_menu': [ ( _("Add list to library"), "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug)) ) ], 'info': info, 'icon': get_icon_path("traktlikedlists"), }) fanart = plugin.addon.getAddonInfo('fanart') for item in items: item['properties'] = {'fanart_image' : get_background_path()} if (len(items) < plugin.get_setting(SETTING_TRAKT_PER_PAGE, int) and pages > page): page = page + 1 results = lists_search_for_lists_term(term, page) return items + results if pages > page: items.append({ 'label': _("Next page").format() + " >> (%s/%s)" % (page + 1, pages), 'path': plugin.url_for("lists_search_for_lists_term", term = term, page=page + 1), 'icon': get_icon_path("traktlikedlists"), }) 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_movie_items(results, pages, page): from trakt import trakt movies = [get_trakt_movie_metadata(item["movie"], None) for item in results] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > 1: args = caller_args() args['page'] = page + 1 items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'path': plugin.url_for(caller_name(), **args), 'icon': get_icon_path("item_next"), 'properties' : {'fanart_image' : get_background_path()}}) 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_tmdb_movies(result): genres_dict = get_base_genres() movies = [get_movie_metadata(item, genres_dict) for item in result['results']] items = [make_movie_item(movie) for movie in movies] if 'page' in result: page = result['page'] args = caller_args() if page < result['total_pages']: args['page'] = str(page + 1) items.append({ 'label': _("Next >>"), 'icon': get_icon_path("item_next"), 'path': plugin.url_for(caller_name(), **args) }) 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_movies_trending_paginated(results, pages, page): from trakt import trakt results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", "")) genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")]) movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results] items = [make_movie_item(movie) for movie in movies] page = int(page) pages = int(pages) if pages > page: items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'path': plugin.url_for("trakt_movies_trending", page=page + 1), 'icon': get_icon_path("item_next"), 'properties' : {'fanart_image' : get_background_path()}, }) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def movies_blockbusters(page): import_tmdb() result = tmdb.Discover().movie(language=LANG, **{ 'page': page, 'sort_by': 'revenue.desc' }) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def list_tmdb_items(result): if FORCE == True: plugin.set_view_mode(VIEW) genres_dict = get_base_genres() movies = [get_movie_metadata(item, None) for item in result['results']] items = [make_movie_item(movie) for movie in movies] if 'page' in result: page = int(result['page']) pages = int(result['total_pages']) args = caller_args() if pages > page: args['page'] = str(page + 1) items.append({ 'label': "{0} >> ({1}/{2})".format(_("Next page"), page + 1, pages), 'icon': get_icon_path("item_next"), 'path': plugin.url_for(caller_name(), **args), 'properties' : {'fanart_image' : get_background_path()}, }) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def movies_search_term(term, page): """ Perform search of a specified <term>""" import_tmdb() result = tmdb.Search().movie(query=term, language=LANG, page=page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_trakt_watchlist(): from trakt import trakt result = trakt.trakt_get_watchlist("movies") return plugin.finish(list_trakt_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_genre(id, page): """ Movies by genre id """ import_tmdb() result = tmdb.Genres(id).movies(id=id, language=LANG, page=page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_blockbusters(page): import_tmdb() result = tmdb.Discover().movie(language=LANG, **{'page': page, 'sort_by': 'revenue.desc'}) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_top_rated(page): import_tmdb() result = tmdb.Movies().top_rated(language=LANG, page=page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_search_term(term, page): """ Perform search of a specified <term>""" import_tmdb() result = tmdb.Search().movie(query=term, language = LANG, page = page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def tmdb_movies_top_rated(page): import_tmdb() result = tmdb.Movies().top_rated(language=LANG, page=page) items = list_tmdb_movies(result) 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_tv_watchlist(): from trakt import trakt result = trakt.trakt_get_watchlist("shows") items = list_trakt_tvshows(result) 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_tv_calendar(): from trakt import trakt result = trakt.trakt_get_calendar() items = list_trakt_episodes(result, with_time=True) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
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"] 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': get_icon_path("tv"), '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(to_utf8(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': 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 = [ ( _("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': 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) item = make_movie_item(movie_info, True) if item is not None: items.append(item) for item in items: item['properties'] = {'fanart_image' : get_background_path()} 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_movies_watchlist(): from trakt import trakt result = trakt.trakt_get_watchlist("movies") items = list_trakt_movies(result) if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def movies_most_popular(page): """ Most popular movies """ import_tmdb() result = tmdb.Movies().popular(language=LANG, page=page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies_now_playing(page): import_tmdb() result = tmdb.Movies().now_playing(language=LANG, page=page) return plugin.finish(list_tmdb_movies(result), sort_methods=MOVIE_SORT_METHODS)
def movies(): items = [{ 'label': _("Enter search string"), 'path': plugin.url_for("movies_search"), 'icon': get_icon_path("search"), }, { 'label': "{0} ({1})".format("Blockbusters", "TMDb"), 'path': plugin.url_for("tmdb_movies_blockbusters", page='1'), 'icon': get_icon_path("most_voted"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("tmdb_movies_play_random_blockbuster"))), ], }, { 'label': "{0} ({1})".format(_("Genres"), "TMDb"), 'path': plugin.url_for("tmdb_movies_genres"), 'icon': get_icon_path("genres"), }, { 'label': "{0} ({1})".format("In theatres", "TMDb"), 'path': plugin.url_for("tmdb_movies_now_playing", page='1'), 'icon': get_icon_path("intheatres"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("tmdb_movies_play_random_now_playing"))), ], }, { 'label': "{0} ({1})".format("Popular", "TMDb"), 'path': plugin.url_for("tmdb_movies_popular", page='1'), 'icon': get_icon_path("popular"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("tmdb_movies_play_random_popular"))), ], }, { 'label': "{0} ({1})".format("Top rated", "TMDb"), 'path': plugin.url_for("tmdb_movies_top_rated", page='1'), 'icon': get_icon_path("top_rated"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("tmdb_movies_play_random_top_rated"))), ], }, { 'label': "{0} ({1})".format("Most played", "Trakt"), 'path': plugin.url_for("trakt_movies_played", page='1'), 'icon': get_icon_path("player"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("trakt_movies_play_random_played"))), ], }, { 'label': "{0} ({1})".format("Most watched", "Trakt"), 'path': plugin.url_for("trakt_movies_watched", page='1'), 'icon': get_icon_path("traktwatchlist"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("trakt_movies_play_random_watched"))), ], }, { 'label': "{0} ({1})".format("Most collected", "Trakt"), 'path': plugin.url_for("trakt_movies_collected", page='1'), 'icon': get_icon_path("traktcollection"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("trakt_movies_play_random_collected"))), ], }, { 'label': "{0} ({1})".format("Popular", "Trakt"), 'path': plugin.url_for("trakt_movies_popular", page='1'), 'icon': get_icon_path("traktrecommendations"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("trakt_movies_play_random_popular"))), ], }, { 'label': "{0} ({1})".format("Trending", "Trakt"), 'path': plugin.url_for("trakt_movies_trending", page='1'), 'icon': get_icon_path("trending"), 'context_menu': [ ("{0} ({1})".format(_("Play"), _("Random").lower()), "RunPlugin({0})".format( plugin.url_for("trakt_movies_play_random_trending"))), ], }, { 'label': "{0} {1}".format(_("Use your"), "Trakt"), 'path': plugin.url_for("trakt_my_movies"), 'icon': get_icon_path("trakt"), }] for item in items: item['properties'] = {'fanart_image': get_background_path()} if FORCE == True: plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW) else: return plugin.finish(items=items, sort_methods=SORT)
def tmdb_movies_genres(): """ List all movie genres """ genres = get_base_genres() items = sorted([{ 'label': name, 'icon': get_genre_icon(id), 'path': plugin.url_for(movies_genre, id=id, page='1')} for id, name in genres.items()], key=lambda k: k['label']) if FORCE == True: return plugin.finish(items=items, view_mode=VIEW) else: return plugin.finish(items=items)