def get_movies(movie_type): movies = [] url = '%s.json?apikey=%s' % (movie_type, RT_KEY) results = utils.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"]) 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 = ListItem(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, 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m")}) 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 get_listitem(self): listitem = xbmcgui.ListItem(label=unicode(self.label) if self.label else "", label2=unicode(self.label2) if self.label2 else "", path=self.path) props = {k: unicode(v) for k, v in self._properties.iteritems() if v} infos = {k.lower(): v for k, v in self._infos.iteritems() if v} if "duration" in infos: props['duration(h)'] = utils.format_time(infos["duration"], "h") props['duration(m)'] = utils.format_time(infos["duration"], "m") for key, value in props.iteritems(): listitem.setProperty(key, unicode(value)) for key, value in self.specials.iteritems(): listitem.setProperty(key, unicode(value)) artwork = {k: v for k, v in self._artwork.iteritems() if v} if artwork: listitem.setArt(artwork) if infos: listitem.setInfo(self.type, infos) for item in self.videoinfo: listitem.addStreamInfo("video", item) for item in self.audioinfo: listitem.addStreamInfo("audio", item) for item in self.subinfo: listitem.addStreamInfo("subtitle", item) listitem.setInfo("video", {"castandrole": [(i["name"], i["role"]) for i in self.cast]}) return listitem
def get_episodes(content): shows = [] url = "" if content == "shows": url = 'calendars/shows/%s/14' % datetime.date.today() elif content == "premieres": url = 'calendars/shows/premieres/%s/14' % datetime.date.today() results = get_data(url=url, params={"extended": "full,images"}, cache_days=0.3) count = 1 if not results: return None for day in results.iteritems(): for episode in day[1]: title = episode["episode"]["title"] if episode["episode"]["title"] else "" label = u"{0} - {1}x{2}. {3}".format(episode["show"]["title"], episode["episode"]["season"], episode["episode"]["number"], title) show = ListItem(label=label, path=PLUGIN_BASE + 'extendedtvinfo&&tvdb_id=%s' % episode["show"]["ids"]["tvdb"]) show.set_infos({'title': title, 'aired': episode["episode"]["first_aired"], 'season': episode["episode"]["season"], 'episode': episode["episode"]["number"], 'tvshowtitle': episode["show"]["title"], 'mediatype': "episode", 'year': episode["show"].get("year"), 'duration': episode["show"]["runtime"] * 60, 'studio': episode["show"]["network"], 'plot': episode["show"]["overview"], 'country': episode["show"]["country"], 'status': episode["show"]["status"], 'trailer': episode["show"]["trailer"], 'imdbnumber': episode["episode"]["ids"]["imdb"], 'rating': episode["show"]["rating"], 'genre': " / ".join(episode["show"]["genres"]), 'mpaa': episode["show"]["certification"]}) show.set_properties({'tvdb_id': episode["episode"]["ids"]["tvdb"], 'id': episode["episode"]["ids"]["tvdb"], 'imdb_id': episode["episode"]["ids"]["imdb"], 'homepage': episode["show"]["homepage"], 'duration(h)': utils.format_time(episode["show"]["runtime"], "h"), 'duration(m)': utils.format_time(episode["show"]["runtime"], "m")}) show.set_artwork({'thumb': episode["episode"]["images"]["screenshot"]["thumb"], 'poster': episode["show"]["images"]["poster"]["full"], 'banner': episode["show"]["images"]["banner"]["full"], 'clearart': episode["show"]["images"]["clearart"]["full"], 'clearlogo': episode["show"]["images"]["logo"]["full"], 'fanart': episode["show"]["images"]["fanart"]["full"]}) shows.append(show) count += 1 if count > 20: break return shows
def handle_movies(results): 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 movie = ListItem(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': utils.convert_youtube_url(item["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"), 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m") }) 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) return movies
def handle_tvshows(results): shows = [] for i in results: item = i["show"] if "show" in i else i airs = item.get("airs", {}) show = ListItem(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"], 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m"), '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) return shows
def get_movies(movie_type): movies = [] url = '%s.json?apikey=%s' % (movie_type, RT_KEY) results = utils.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"]) 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 = ListItem(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, 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m") }) 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 get_listitem(self): listitem = xbmcgui.ListItem(label=unicode(self.label) if self.label else "", label2=unicode(self.label2) if self.label2 else "", path=self.path) props = {k: unicode(v) for k, v in self._properties.iteritems() if v} infos = {k.lower(): v for k, v in self._infos.iteritems() if v} infos["path"] = self.path if "duration" in infos: props['duration(h)'] = utils.format_time(infos["duration"], "h") props['duration(m)'] = utils.format_time(infos["duration"], "m") for key, value in props.iteritems(): listitem.setProperty(key, unicode(value)) for key, value in self.specials.iteritems(): listitem.setProperty(key, unicode(value)) artwork = {k: v for k, v in self._artwork.iteritems() if v} if artwork: listitem.setArt(artwork) if infos: listitem.setInfo(self.type, infos) return listitem
def get_listitem(self): listitem = xbmcgui.ListItem(label=str(self.label) if self.label else "", label2=str(self.label2) if self.label2 else "", path=self.path) props = {k: str(v) for k, v in self._properties.iteritems() if v} infos = {k.lower(): v for k, v in self._infos.iteritems() if v} infos["path"] = self.path if "duration" in infos: props['duration(h)'] = utils.format_time(infos["duration"], "h") props['duration(m)'] = utils.format_time(infos["duration"], "m") for key, value in props.iteritems(): listitem.setProperty(key, str(value)) for key, value in self.specials.iteritems(): listitem.setProperty(key, str(value)) artwork = {k: v for k, v in self._artwork.iteritems() if v} if artwork: listitem.setArt(artwork) if infos: listitem.setInfo(self.type, infos) return listitem
def handle_movies(results): 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 movie = ListItem(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': utils.convert_youtube_url(item["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"), 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m")}) 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) return movies
def get_episodes(content): shows = [] url = "" if content == "shows": url = 'calendars/shows/%s/14' % datetime.date.today() elif content == "premieres": url = 'calendars/shows/premieres/%s/14' % datetime.date.today() results = get_data(url=url, params={"extended": "full,images"}, cache_days=0.3) count = 1 if not results: return None for day in results.iteritems(): for episode in day[1]: title = episode["episode"]["title"] if episode["episode"][ "title"] else "" label = u"{0} - {1}x{2}. {3}".format(episode["show"]["title"], episode["episode"]["season"], episode["episode"]["number"], title) show = ListItem( label=label, path=PLUGIN_BASE + 'extendedtvinfo&&tvdb_id=%s' % episode["show"]["ids"]["tvdb"]) show.set_infos({ 'title': title, 'aired': episode["episode"]["first_aired"], 'season': episode["episode"]["season"], 'episode': episode["episode"]["number"], 'tvshowtitle': episode["show"]["title"], 'mediatype': "episode", 'year': episode["show"].get("year"), 'duration': episode["show"]["runtime"] * 60, 'studio': episode["show"]["network"], 'plot': episode["show"]["overview"], 'country': episode["show"]["country"], 'status': episode["show"]["status"], 'trailer': episode["show"]["trailer"], 'imdbnumber': episode["episode"]["ids"]["imdb"], 'rating': episode["show"]["rating"], 'genre': " / ".join(episode["show"]["genres"]), 'mpaa': episode["show"]["certification"] }) show.set_properties({ 'tvdb_id': episode["episode"]["ids"]["tvdb"], 'id': episode["episode"]["ids"]["tvdb"], 'imdb_id': episode["episode"]["ids"]["imdb"], 'homepage': episode["show"]["homepage"], 'duration(h)': utils.format_time(episode["show"]["runtime"], "h"), 'duration(m)': utils.format_time(episode["show"]["runtime"], "m") }) show.set_artwork({ 'thumb': episode["episode"]["images"]["screenshot"]["thumb"], 'poster': episode["show"]["images"]["poster"]["full"], 'banner': episode["show"]["images"]["banner"]["full"], 'clearart': episode["show"]["images"]["clearart"]["full"], 'clearlogo': episode["show"]["images"]["logo"]["full"], 'fanart': episode["show"]["images"]["fanart"]["full"] }) shows.append(show) count += 1 if count > 20: break return shows
def handle_tvshows(results): shows = [] for i in results: item = i["show"] if "show" in i else i airs = item.get("airs", {}) show = ListItem(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"], 'duration(h)': utils.format_time(item["runtime"], "h"), 'duration(m)': utils.format_time(item["runtime"], "m"), '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) return shows