def handle_movies(results): movies = [] path = 'extendedinfo&&id=%s' if SETTING("infodialog_onclick") != "false" else "playtrailer&&id=%s" for movie in results: movie = {'title': movie["movie"]["title"], 'Runtime': movie["movie"]["runtime"], 'duration': movie["movie"]["runtime"], 'duration(h)': format_time(movie["movie"]["runtime"], "h"), 'duration(m)': format_time(movie["movie"]["runtime"], "m"), 'Tagline': movie["movie"]["tagline"], 'Trailer': convert_youtube_url(movie["movie"]["trailer"]), 'year': movie["movie"]["year"], 'id': movie["movie"]["ids"]["tmdb"], 'imdb_id': movie["movie"]["ids"]["imdb"], 'path': PLUGIN_BASE + path % fetch(movie["movie"]["ids"], 'tmdb'), 'mpaa': movie["movie"]["certification"], 'Plot': movie["movie"]["overview"], 'Premiered': movie["movie"]["released"], 'Rating': round(movie["movie"]["rating"], 1), 'Votes': movie["movie"]["votes"], 'Watchers': movie["watchers"], 'genre': " / ".join(movie["movie"]["genres"]), 'poster': movie["movie"]["images"]["poster"]["full"], 'fanart': movie["movie"]["images"]["fanart"]["full"], 'thumb': movie['movie']["images"]["poster"]["thumb"]} movies.append(movie) movies = local_db.merge_with_local_movie_info(online_list=movies, library_first=False) return movies
def handle_movies(results): movies = [] path = 'extendedinfo&&id=%s' if SETTING( "infodialog_onclick") != "false" else "playtrailer&&id=%s" for movie in results: movie = { 'title': movie["movie"]["title"], 'Runtime': movie["movie"]["runtime"], 'duration': movie["movie"]["runtime"], 'duration(h)': format_time(movie["movie"]["runtime"], "h"), 'duration(m)': format_time(movie["movie"]["runtime"], "m"), 'Tagline': movie["movie"]["tagline"], 'Trailer': convert_youtube_url(movie["movie"]["trailer"]), 'year': movie["movie"]["year"], 'id': movie["movie"]["ids"]["tmdb"], 'imdb_id': movie["movie"]["ids"]["imdb"], 'path': PLUGIN_BASE + path % fetch(movie["movie"]["ids"], 'tmdb'), 'mpaa': movie["movie"]["certification"], 'Plot': movie["movie"]["overview"], 'Premiered': movie["movie"]["released"], 'Rating': round(movie["movie"]["rating"], 1), 'Votes': movie["movie"]["votes"], 'Watchers': movie["watchers"], 'genre': " / ".join(movie["movie"]["genres"]), 'poster': movie["movie"]["images"]["poster"]["full"], 'fanart': movie["movie"]["images"]["fanart"]["full"], 'thumb': movie['movie']["images"]["poster"]["thumb"] } movies.append(movie) movies = local_db.merge_with_local_movie_info(online_list=movies, library_first=False) return movies
def get_movies(movie_type): movies = [] url = '%s.json?apikey=%s' % (movie_type, RT_KEY) results = get_JSON_response(BASE_URL + url, folder="RottenTomatoes") if not results or "movies" not in results: return [] for item in results["movies"]: if "alternate_ids" not in item: continue imdb_id = str(item["alternate_ids"]["imdb"]) poster = "http://content6.flixster.com/" + item["posters"]["original"][93:] if SETTING("infodialog_onclick") != "false": path = PLUGIN_BASE + 'extendedinfo&&imdb_id=%s' % imdb_id else: search_string = "%s %s trailer" % (item["title"], item["year"]) path = PLUGIN_BASE + "playtrailer&&title=%s&&imdb_id=%s" % (search_string, imdb_id) movies.append({'title': item["title"], 'imdb_id': imdb_id, 'thumb': poster, 'mediatype': "movie", 'poster': poster, 'Runtime': item["runtime"] * 60, 'duration': item["runtime"] * 60, 'duration(h)': format_time(item["runtime"], "h"), 'duration(m)': format_time(item["runtime"], "m"), 'year': item["year"], 'path': path, 'Premiered': item["release_dates"].get("theater", ""), 'mpaa': item["mpaa_rating"], 'Rating': item["ratings"]["audience_score"] / 10.0, 'Plot': item["synopsis"]}) return local_db.merge_with_local_movie_info(movies, False)
def handle_movies(results, local_first=True, sortkey="year"): response = get_data(url="genre/movie/list", params={"language": SETTING("LanguageID")}, cache_days=30) ids = [item["id"] for item in response["genres"]] labels = [item["name"] for item in response["genres"]] movies = [] path = 'extendedinfo&&id=%s' if SETTING( "infodialog_onclick") != "false" else "playtrailer&&id=%s" for movie in results: genres = [ labels[ids.index(id_)] for id_ in movie.get("genre_ids", []) if id_ in ids ] tmdb_id = str(fetch(movie, 'id')) artwork = get_image_urls(poster=movie.get("poster_path"), fanart=movie.get("backdrop_path")) trailer = PLUGIN_BASE + "playtrailer&&id=" + tmdb_id listitem = { 'title': fetch(movie, 'title'), 'Label': fetch(movie, 'title'), 'OriginalTitle': fetch(movie, 'original_title'), 'id': tmdb_id, 'path': PLUGIN_BASE + path % tmdb_id, 'media_type': "movie", 'country': fetch(movie, 'original_language'), 'plot': fetch(movie, 'overview'), 'Trailer': trailer, 'Popularity': fetch(movie, 'popularity'), 'Rating': fetch(movie, 'vote_average'), 'credit_id': fetch(movie, 'credit_id'), 'character': fetch(movie, 'character'), 'job': fetch(movie, 'job'), 'department': fetch(movie, 'department'), 'Votes': fetch(movie, 'vote_count'), 'User_Rating': fetch(movie, 'rating'), 'year': get_year(fetch(movie, 'release_date')), 'genre': " / ".join(genres), 'time_comparer': fetch(movie, 'release_date').replace("-", ""), 'Premiered': fetch(movie, 'release_date') } listitem.update(artwork) movies.append(listitem) movies = local_db.merge_with_local_movie_info(movies, local_first, sortkey) return movies
def handle_movies(results, local_first=True, sortkey="year"): response = get_data(url="genre/movie/list", params={"language": SETTING("LanguageID")}, cache_days=30) ids = [item["id"] for item in response["genres"]] labels = [item["name"] for item in response["genres"]] movies = [] path = 'extendedinfo&&id=%s' if SETTING("infodialog_onclick") != "false" else "playtrailer&&id=%s" for movie in results: genres = [labels[ids.index(id_)] for id_ in movie.get("genre_ids", []) if id_ in ids] genres = [i for i in genres if i] tmdb_id = str(fetch(movie, 'id')) artwork = get_image_urls(poster=movie.get("poster_path"), fanart=movie.get("backdrop_path")) trailer = PLUGIN_BASE + "playtrailer&&id=" + tmdb_id listitem = {'title': fetch(movie, 'title'), 'Label': fetch(movie, 'title'), 'OriginalTitle': fetch(movie, 'original_title'), 'id': tmdb_id, 'path': PLUGIN_BASE + path % tmdb_id, 'mediatype': "movie", 'country': fetch(movie, 'original_language'), 'plot': fetch(movie, 'overview'), 'Trailer': trailer, 'Popularity': fetch(movie, 'popularity'), 'Rating': fetch(movie, 'vote_average'), 'credit_id': fetch(movie, 'credit_id'), 'character': fetch(movie, 'character'), 'job': fetch(movie, 'job'), 'department': fetch(movie, 'department'), 'Votes': fetch(movie, 'vote_count'), 'User_Rating': fetch(movie, 'rating'), 'year': get_year(fetch(movie, 'release_date')), 'genre': " / ".join(genres), 'time_comparer': fetch(movie, 'release_date').replace("-", ""), 'Premiered': fetch(movie, 'release_date')} listitem.update(artwork) movies.append(listitem) movies = local_db.merge_with_local_movie_info(movies, local_first, sortkey) return movies
def get_movies(movie_type): movies = [] url = '%s.json?apikey=%s' % (movie_type, RT_KEY) results = get_JSON_response(BASE_URL + url, folder="RottenTomatoes") if not results or "movies" not in results: return [] for item in results["movies"]: if "alternate_ids" not in item: continue imdb_id = str(item["alternate_ids"]["imdb"]) poster = "http://content6.flixster.com/" + item["posters"]["original"][ 93:] if SETTING("infodialog_onclick") != "false": path = PLUGIN_BASE + 'extendedinfo&&imdb_id=%s' % imdb_id else: search_string = "%s %s trailer" % (item["title"], str( item["year"])) path = PLUGIN_BASE + "playtrailer&&title=%s&&imdb_id=%s" % ( search_string, imdb_id) movies.append({ 'title': item["title"], 'imdb_id': imdb_id, 'thumb': poster, 'poster': poster, 'Runtime': item["runtime"], 'duration': item["runtime"], 'duration(h)': format_time(item["runtime"], "h"), 'duration(m)': format_time(item["runtime"], "m"), 'year': item["year"], 'path': path, 'Premiered': item["release_dates"].get("theater", ""), 'mpaa': item["mpaa_rating"], 'Rating': item["ratings"]["audience_score"] / 10.0, 'Plot': item["synopsis"] }) return local_db.merge_with_local_movie_info(movies, False)
def extended_movie_info(movie_id=None, dbid=None, cache_time=14): if not movie_id: return None params = {"append_to_response": ALL_MOVIE_PROPS, "language": SETTING("LanguageID"), "include_image_language": "en,null,%s" % SETTING("LanguageID")} if Login.check_login(): params["session_id"] = Login.get_session_id() response = get_data(url="movie/%s" % (movie_id), params=params, cache_days=cache_time) if not response: notify("Could not get movie information") return {} mpaa = "" set_name = "" set_id = "" genres = [i["name"] for i in response["genres"]] Studio = [i["name"] for i in response["production_companies"]] authors = [i["name"] for i in response['credits']['crew'] if i["department"] == "Writing"] directors = [i["name"] for i in response['credits']['crew'] if i["department"] == "Directing"] us_cert = dictfind(response['releases']['countries'], "iso_3166_1", "US") if us_cert: mpaa = us_cert["certification"] elif response['releases']['countries']: mpaa = response['releases']['countries'][0]['certification'] movie_set = fetch(response, "belongs_to_collection") if movie_set: set_name = fetch(movie_set, "name") set_id = fetch(movie_set, "id") artwork = get_image_urls(poster=response.get("poster_path"), fanart=response.get("backdrop_path")) path = PLUGIN_BASE + 'youtubevideo&&id=%s' % fetch(response, "id") movie = {'title': fetch(response, 'title'), 'Label': fetch(response, 'title'), 'Tagline': fetch(response, 'tagline'), 'duration': fetch(response, 'runtime'), 'duration(h)': format_time(fetch(response, 'runtime'), "h"), 'duration(m)': format_time(fetch(response, 'runtime'), "m"), 'mpaa': mpaa, 'Director': " / ".join(directors), 'writer': " / ".join(authors), 'Budget': millify(fetch(response, 'budget')), 'Revenue': millify(fetch(response, 'revenue')), 'Homepage': fetch(response, 'homepage'), 'Set': set_name, 'SetId': set_id, 'id': fetch(response, 'id'), 'imdb_id': fetch(response, 'imdb_id'), 'Plot': clean_text(fetch(response, 'overview')), 'OriginalTitle': fetch(response, 'original_title'), 'Country': fetch(response, 'original_language'), 'genre': " / ".join(genres), 'Rating': round(response['vote_average'], 1) if response.get('vote_average') else "", 'Votes': fetch(response, 'vote_count'), 'Adult': str(fetch(response, 'adult')), 'Popularity': fetch(response, 'popularity'), 'Status': translate_status(fetch(response, 'status')), 'path': path, 'release_date': fetch(response, 'release_date'), 'Premiered': fetch(response, 'release_date'), 'Studio': " / ".join(Studio), 'year': get_year(fetch(response, 'release_date'))} movie.update(artwork) videos = handle_videos(response["videos"]["results"]) if "videos" in response else [] account_states = response.get("account_states") if dbid: local_item = local_db.get_movie(dbid) movie.update(local_item) else: movie = local_db.merge_with_local_movie_info([movie])[0] movie['Rating'] = round(response['vote_average'], 1) if response.get('vote_average') else "", listitems = {"actors": handle_people(response["credits"]["cast"]), "similar": handle_movies(response["similar"]["results"]), "lists": handle_misc(response["lists"]["results"]), "studios": handle_misc(response["production_companies"]), "releases": handle_misc(response["releases"]["countries"]), "crew": handle_people(response["credits"]["crew"]), "genres": handle_misc(response["genres"]), "keywords": handle_misc(response["keywords"]["keywords"]), "reviews": handle_misc(response["reviews"]["results"]), "videos": videos, "images": handle_images(response["images"]["posters"]), "backdrops": handle_images(response["images"]["backdrops"])} return (movie, listitems, account_states)
def extended_movie_info(movie_id=None, dbid=None, cache_time=14): if not movie_id: return None params = {"append_to_response": ALL_MOVIE_PROPS, "language": SETTING("LanguageID"), "include_image_language": "en,null,%s" % SETTING("LanguageID")} if Login.check_login(): params["session_id"] = Login.get_session_id() response = get_data(url="movie/%s" % (movie_id), params=params, cache_days=cache_time) if not response: notify("Could not get movie information") return {} mpaa = "" set_name = "" set_id = "" genres = [i["name"] for i in response["genres"]] Studio = [i["name"] for i in response["production_companies"]] authors = [i["name"] for i in response['credits']['crew'] if i["department"] == "Writing"] directors = [i["name"] for i in response['credits']['crew'] if i["department"] == "Directing"] us_cert = dictfind(response['releases']['countries'], "iso_3166_1", "US") if us_cert: mpaa = us_cert["certification"] elif response['releases']['countries']: mpaa = response['releases']['countries'][0]['certification'] movie_set = fetch(response, "belongs_to_collection") if movie_set: set_name = fetch(movie_set, "name") set_id = fetch(movie_set, "id") artwork = get_image_urls(poster=response.get("poster_path"), fanart=response.get("backdrop_path")) path = PLUGIN_BASE + 'youtubevideo&&id=%s' % fetch(response, "id") movie = {'title': fetch(response, 'title'), 'label': fetch(response, 'title'), 'path': path, 'Tagline': fetch(response, 'tagline'), 'duration': fetch(response, 'runtime'), 'mpaa': mpaa, 'Director': " / ".join(directors), 'writer': " / ".join(authors), 'Plot': clean_text(fetch(response, 'overview')), 'OriginalTitle': fetch(response, 'original_title'), 'Country': fetch(response, 'original_language'), 'genre': " / ".join(genres), 'Rating': fetch(response, 'vote_average'), 'Premiered': fetch(response, 'release_date'), 'Votes': fetch(response, 'vote_count'), 'Adult': str(fetch(response, 'adult')), 'Popularity': fetch(response, 'popularity'), 'Status': translate_status(fetch(response, 'status')), 'Set': set_name, 'SetId': set_id, 'id': fetch(response, 'id'), 'imdb_id': fetch(response, 'imdb_id'), 'duration(h)': format_time(fetch(response, 'runtime'), "h"), 'duration(m)': format_time(fetch(response, 'runtime'), "m"), 'Budget': millify(fetch(response, 'budget')), 'Revenue': millify(fetch(response, 'revenue')), 'Homepage': fetch(response, 'homepage'), 'Studio': " / ".join(Studio), 'year': get_year(fetch(response, 'release_date'))} movie.update(artwork) videos = handle_videos(response["videos"]["results"]) if "videos" in response else [] account_states = response.get("account_states") if dbid: local_item = local_db.get_movie(dbid) movie.update(local_item) else: movie = local_db.merge_with_local_movie_info([movie])[0] movie['Rating'] = fetch(response, 'vote_average') # hack to get tmdb rating instead of local one listitems = {"actors": handle_people(response["credits"]["cast"]), "similar": handle_movies(response["similar"]["results"]), "lists": handle_misc(response["lists"]["results"]), "studios": handle_misc(response["production_companies"]), "releases": handle_misc(response["releases"]["countries"]), "crew": handle_people(response["credits"]["crew"]), "genres": handle_misc(response["genres"]), "keywords": handle_misc(response["keywords"]["keywords"]), "reviews": handle_misc(response["reviews"]["results"]), "videos": videos, "images": handle_images(response["images"]["posters"]), "backdrops": handle_images(response["images"]["backdrops"])} return (movie, listitems, account_states)