def get_movies(movie_type): movies = ItemList(content_type="movies") url = '%s.json?apikey=%s' % (movie_type, RT_KEY) results = utils.get_JSON_response(BASE_URL + url, folder="RottenTomatoes") if "error" in results: utils.notify("Error", results["error"]) 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"]) if addon.bool_setting("infodialog_onclick"): 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) movie = VideoItem(label=item.get('title'), path=path) movie.set_infos({'title': item["title"], 'mediatype': "movie", 'duration': item["runtime"] * 60, 'year': item["year"], 'premiered': item["release_dates"].get("theater", ""), 'rating': item["ratings"]["audience_score"] / 10.0, 'plot': item["synopsis"], 'imdbnumber': imdb_id, 'mpaa': item["mpaa_rating"]}) movie.set_properties({'imdb_id': imdb_id}) movie.set_artwork({'thumb': item["posters"]["original"], 'poster': item["posters"]["original"]}) movies.append(movie) return local_db.merge_with_local(media_type="movie", items=movies, library_first=False)
def handle_movies(results): movies = ItemList(content_type="movies") path = 'extendedinfo&&id=%s' if addon.bool_setting( "infodialog_onclick") else "playtrailer&&id=%s" for i in results: item = i["movie"] if "movie" in i else i trailer = "%syoutubevideo&&id=%s" % ( PLUGIN_BASE, utils.extract_youtube_id(item["trailer"])) movie = VideoItem(label=item["title"], path=PLUGIN_BASE + path % item["ids"]["tmdb"]) movie.set_infos({ 'title': item["title"], 'duration': item["runtime"] * 60 if item["runtime"] else "", 'tagline': item["tagline"], 'mediatype': "movie", 'trailer': trailer, 'year': item["year"], 'mpaa': item["certification"], 'plot': item["overview"], 'imdbnumber': item["ids"]["imdb"], 'premiered': item["released"], 'rating': round(item["rating"], 1), 'votes': item["votes"], 'genre': " / ".join(item["genres"]) }) movie.set_properties({ 'id': item["ids"]["tmdb"], 'imdb_id': item["ids"]["imdb"], 'trakt_id': item["ids"]["trakt"], 'watchers': item.get("watchers"), 'language': item.get("language"), 'homepage': item.get("homepage") }) art_info = tmdb.get_movie(item["ids"]["tmdb"], light=True) movie.set_artwork( tmdb.get_image_urls(poster=art_info.get("poster_path"), fanart=art_info.get("backdrop_path"))) movies.append(movie) movies = local_db.merge_with_local(media_type="movie", items=movies, library_first=False) movies.set_sorts(["mpaa", "duration"]) return movies
def handle_tvshows(results): shows = ItemList(content_type="tvshows") for i in results: item = i["show"] if "show" in i else i airs = item.get("airs", {}) show = VideoItem(label=item["title"], path='%sextendedtvinfo&&tvdb_id=%s' % (PLUGIN_BASE, item['ids']["tvdb"])) show.set_infos({ 'mediatype': "tvshow", 'title': item["title"], 'duration': item["runtime"] * 60, 'year': item["year"], 'premiered': item["first_aired"][:10], 'country': item["country"], 'rating': round(item["rating"], 1), 'votes': item["votes"], 'imdbnumber': item['ids']["imdb"], 'mpaa': item["certification"], 'trailer': item["trailer"], 'status': item.get("status"), 'studio': item["network"], 'genre': " / ".join(item["genres"]), 'plot': item["overview"] }) show.set_properties({ 'id': item['ids']["tmdb"], 'tvdb_id': item['ids']["tvdb"], 'imdb_id': item['ids']["imdb"], 'trakt_id': item['ids']["trakt"], 'language': item["language"], 'aired_episodes': item["aired_episodes"], 'homepage': item["homepage"], 'airday': airs.get("day"), 'airshorttime': airs.get("time"), 'watchers': item.get("watchers") }) show.set_artwork({ 'poster': item["images"]["poster"]["full"], 'banner': item["images"]["banner"]["full"], 'clearart': item["images"]["clearart"]["full"], 'clearlogo': item["images"]["logo"]["full"], 'fanart': item["images"]["fanart"]["full"], 'thumb': item["images"]["poster"]["thumb"] }) shows.append(show) shows = local_db.merge_with_local(media_type="tvshow", items=shows, library_first=False) shows.set_sorts(["mpaa", "duration"]) return shows
def handle_tvshows(results): shows = ItemList(content_type="tvshows") for i in results: item = i["show"] if "show" in i else i airs = item.get("airs", {}) show = VideoItem(label=item["title"], path='%sextendedtvinfo&&tvdb_id=%s' % (PLUGIN_BASE, item['ids']["tvdb"])) show.set_infos({'mediatype': "tvshow", 'title': item["title"], 'duration': item["runtime"] * 60, 'year': item["year"], 'premiered': item["first_aired"][:10], 'country': item["country"], 'rating': round(item["rating"], 1), 'votes': item["votes"], 'imdbnumber': item['ids']["imdb"], 'mpaa': item["certification"], 'trailer': item["trailer"], 'status': item.get("status"), 'studio': item["network"], 'genre': " / ".join(item["genres"]), 'plot': item["overview"]}) show.set_properties({'id': item['ids']["tmdb"], 'tvdb_id': item['ids']["tvdb"], 'imdb_id': item['ids']["imdb"], 'trakt_id': item['ids']["trakt"], 'language': item["language"], 'aired_episodes': item["aired_episodes"], 'homepage': item["homepage"], 'airday': airs.get("day"), 'airshorttime': airs.get("time"), 'watchers': item.get("watchers")}) show.set_artwork({'poster': item["images"]["poster"]["full"], 'banner': item["images"]["banner"]["full"], 'clearart': item["images"]["clearart"]["full"], 'clearlogo': item["images"]["logo"]["full"], 'fanart': item["images"]["fanart"]["full"], 'thumb': item["images"]["poster"]["thumb"]}) shows.append(show) shows = local_db.merge_with_local(media_type="tvshow", items=shows, library_first=False) shows.set_sorts(["mpaa", "duration"]) return shows
def handle_movies(results): movies = ItemList(content_type="movies") path = 'extendedinfo&&id=%s' if addon.bool_setting("infodialog_onclick") else "playtrailer&&id=%s" for i in results: item = i["movie"] if "movie" in i else i trailer = "%syoutubevideo&&id=%s" % (PLUGIN_BASE, utils.extract_youtube_id(item["trailer"])) movie = VideoItem(label=item["title"], path=PLUGIN_BASE + path % item["ids"]["tmdb"]) movie.set_infos({'title': item["title"], 'duration': item["runtime"] * 60, 'tagline': item["tagline"], 'mediatype': "movie", 'trailer': trailer, 'year': item["year"], 'mpaa': item["certification"], 'plot': item["overview"], 'imdbnumber': item["ids"]["imdb"], 'premiered': item["released"], 'rating': round(item["rating"], 1), 'votes': item["votes"], 'genre': " / ".join(item["genres"])}) movie.set_properties({'id': item["ids"]["tmdb"], 'imdb_id': item["ids"]["imdb"], 'trakt_id': item["ids"]["trakt"], 'watchers': item.get("watchers"), 'language': item.get("language"), 'homepage': item.get("homepage")}) movie.set_artwork({'poster': item["images"]["poster"]["full"], 'fanart': item["images"]["fanart"]["full"], 'clearlogo': item["images"]["logo"]["full"], 'clearart': item["images"]["clearart"]["full"], 'banner': item["images"]["banner"]["full"], 'thumb': item["images"]["poster"]["thumb"]}) movies.append(movie) movies = local_db.merge_with_local(media_type="movie", items=movies, library_first=False) movies.set_sorts(["mpaa", "duration"]) return movies