def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.type = 'Episode' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'), episode=kwargs.get('episode')) if not data: return None self.info, self.data = data self.listitems = [ (1000, self.data['actors'] + self.data['guest_stars']), (750, self.data['crew']), (1350, self.data['images']) ] else: super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.type = 'Episode' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'), episode=kwargs.get('episode')) if not data: return None self.info, self.data = data self.info['ImageFilter'], self.info['ImageColor'] = ImageTools.filter_image(input_img=self.info.get('thumb', ''), radius=25) self.listitems = [ (1150, self.data['videos']), (1000, self.data['actors'] + self.data['guest_stars']), (750, self.data['crew']), (1350, self.data['images']) ]
def change_list_status(self, control_id): tmdb.change_fav_status( media_id=self.info.get_property("id"), media_type=self.TYPE_ALT, status=str(not bool(self.states["favorite"])).lower(), ) self.update_states()
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogSeasonInfo, self).__init__(*args, **kwargs) self.type = 'Season' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_season_info(tvshow_id=self.tvshow_id, season_number=kwargs.get('season')) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(url=self.info.get('poster', '')) self.listitems = [ (2000, self.data['episodes']), (1000, self.data['actors']), (750, self.data['crew']), (1250, self.data['images']) ] else: super(DialogSeasonInfo, self).__init__(*args, **kwargs) self.type = 'Season' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_season_info(tvshow_id=self.tvshow_id, season_number=kwargs.get('season')) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(url=self.info.get('poster', '')) self.info['ImageFilter'], self.info['ImageColor'] = ImageTools.filter_image(input_img=self.info.get('poster', ''), radius=25) self.listitems = [ (2000, self.data['episodes']), (1150, self.data['videos']), (1000, self.data['actors']), (750, self.data['crew']), (1250, self.data['images']) ]
def context_menu(self, control_id): item_id = self.FocusedItem(control_id).getProperty("id") media_type = self.FocusedItem(control_id).getVideoInfoTag().getMediaType() listitems = [addon.LANG(32169)] if media_type == "tvshow" else [addon.LANG(32113)] if self.logged_in: listitems += [addon.LANG(14076)] if not self.type == "tv": listitems += [addon.LANG(32107)] if self.mode == "list": listitems += [addon.LANG(32035)] selection = xbmcgui.Dialog().contextmenu(list=listitems) if selection == 0: rating = utils.input_userrating() if tmdb.set_rating(media_type="tv" if media_type == "tvshow" else "movie", media_id=item_id, rating=rating, dbid=self.FocusedItem(control_id).getVideoInfoTag().getDbId()): xbmc.sleep(2000) self.update(force_update=True) self.setCurrentListPosition(self.position) elif selection == 1: tmdb.change_fav_status(media_id=item_id, media_type=self.type, status="true") elif selection == 2: self.list_dialog(item_id) elif selection == 3: tmdb.change_list_status(list_id=self.list_id, movie_id=item_id, status=False) self.update(force_update=True) self.setCurrentListPosition(self.position)
def remove_list_dialog(self, account_lists): listitems = [ "%s (%i)" % (d["name"], d["item_count"]) for d in account_lists ] index = xbmcgui.Dialog().select(addon.LANG(32138), listitems) if index >= 0: tmdb.remove_list(account_lists[index]["id"]) self.update_states()
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogVideoInfo, self).__init__(*args, **kwargs) self.type = 'Movie' data = TheMovieDB.extended_movie_info(movie_id=kwargs.get('id'), dbid=self.dbid) if not data: return None self.info, self.data = data sets_thread = SetItemsThread(self.info['SetId']) sets_thread.start() if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(self.info.get('poster', '')) sets_thread.join() self.setinfo = sets_thread.setinfo self.data['similar'] = [i for i in self.data['similar'] if i['id'] not in sets_thread.id_list] self.listitems = [ (250, sets_thread.listitems), (1000, self.data['actors']), (750, Utils.merge_dict_lists(self.data['crew'])), (150, self.data['similar']), (550, self.data['studios']), (850, self.data['genres']), (1050, self.data['reviews']), (1250, self.data['images']), (1350, self.data['backdrops']) ] else: super(DialogVideoInfo, self).__init__(*args, **kwargs) self.type = 'Movie' data = TheMovieDB.extended_movie_info(movie_id=kwargs.get('id'), dbid=self.dbid) if not data: return None self.info, self.data = data sets_thread = SetItemsThread(self.info['SetId']) filter_thread = ImageTools.FilterImageThread(self.info.get('thumb', ''), 25) for thread in [sets_thread, filter_thread]: thread.start() if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(self.info.get('poster', '')) sets_thread.join() self.setinfo = sets_thread.setinfo self.data['similar'] = [i for i in self.data['similar'] if i['id'] not in sets_thread.id_list] filter_thread.join() self.info['ImageFilter'] = filter_thread.image self.info['ImageColor'] = filter_thread.imagecolor self.listitems = [ (250, sets_thread.listitems), (150, self.data['similar']), (1150, self.data['videos']), (1000, self.data['actors']), (750, Utils.merge_dict_lists(self.data['crew'])), (550, self.data['studios']), (650, TheMovieDB.merge_with_cert_desc(self.data['releases'], 'movie')), (850, self.data['genres']), (1050, self.data['reviews']), (1250, self.data['images']), (1350, self.data['backdrops']) ]
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 list_dialog(self, movie_id): busy.show_busy() listitems = [addon.LANG(32139)] account_lists = tmdb.get_account_lists() listitems += [ "%s (%i)" % (i["name"], i["item_count"]) for i in account_lists ] listitems.append(addon.LANG(32138)) busy.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == 0: listname = xbmcgui.Dialog().input(heading=addon.LANG(32137), type=xbmcgui.INPUT_ALPHANUM) if listname: xbmc.sleep(1000) tmdb.change_list_status(list_id=tmdb.create_list(listname), movie_id=movie_id, status=True) elif index == len(listitems) - 1: tmdb.remove_list_dialog(tmdb.handle_lists(account_lists)) elif index > 0: tmdb.change_list_status(list_id=account_lists[index - 1]["id"], movie_id=movie_id, status=True)
def get_episodes(content): shows = ItemList(content_type="episodes") 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"}, cache_days=0.3) count = 1 if not results: return None for day in results.iteritems(): for episode in day[1]: ep = episode["episode"] tv = episode["show"] title = ep["title"] if ep["title"] else "" label = u"{0} - {1}x{2}. {3}".format(tv["title"], ep["season"], ep["number"], title) show = VideoItem(label=label, path=PLUGIN_BASE + 'extendedtvinfo&&tvdb_id=%s' % tv["ids"]["tvdb"]) show.set_infos({'title': title, 'aired': ep["first_aired"], 'season': ep["season"], 'episode': ep["number"], 'tvshowtitle': tv["title"], 'mediatype': "episode", 'year': tv.get("year"), 'duration': tv["runtime"] * 60 if tv["runtime"] else "", 'studio': tv["network"], 'plot': tv["overview"], 'country': tv["country"], 'status': tv["status"], 'trailer': tv["trailer"], 'imdbnumber': ep["ids"]["imdb"], 'rating': tv["rating"], 'genre': " / ".join(tv["genres"]), 'mpaa': tv["certification"]}) show.set_properties({'tvdb_id': ep["ids"]["tvdb"], 'id': ep["ids"]["tvdb"], 'imdb_id': ep["ids"]["imdb"], 'homepage': tv["homepage"]}) if tv["ids"].get("tmdb"): art_info = tmdb.get_tvshow(tv["ids"]["tmdb"], light=True) show.set_artwork(tmdb.get_image_urls(poster=art_info.get("poster_path"), fanart=art_info.get("backdrop_path"))) shows.append(show) count += 1 if count > 20: break return shows
def __init__(self, *args, **kwargs): super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.tvshow_id = kwargs.get('tvshow_id') tv_info = tmdb.get_tvshow(self.tvshow_id, light=True) data = tmdb.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'), episode=kwargs.get('episode')) if not data: return None self.info, self.lists, self.states = data self.info.set_info("tvshowtitle", tv_info["name"]) image_info = imagetools.blur(self.info.get_art("thumb")) self.info.update_properties(image_info)
def add_to_list_button(self, control_id): busy.show_busy() account_lists = tmdb.get_account_lists() listitems = ["%s (%i)" % (i["name"], i["item_count"]) for i in account_lists] listitems.insert(0, addon.LANG(32139)) listitems.append(addon.LANG(32138)) busy.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == 0: listname = xbmcgui.Dialog().input(heading=addon.LANG(32137), type=xbmcgui.INPUT_ALPHANUM) if not listname: return None list_id = tmdb.create_list(listname) xbmc.sleep(1000) tmdb.change_list_status(list_id=list_id, movie_id=self.info.get_property("id"), status=True) elif index == len(listitems) - 1: if tmdb.remove_list_dialog(tmdb.handle_lists(account_lists)): self.update_states() elif index > 0: tmdb.change_list_status(account_lists[index - 1]["id"], self.info.get_property("id"), True) self.update_states()
def add_to_list_button(self, control_id): busy.show_busy() account_lists = tmdb.get_account_lists() listitems = [ "%s (%i)" % (i["name"], i["item_count"]) for i in account_lists ] listitems.insert(0, addon.LANG(32139)) listitems.append(addon.LANG(32138)) busy.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == 0: listname = xbmcgui.Dialog().input(heading=addon.LANG(32137), type=xbmcgui.INPUT_ALPHANUM) if not listname: return None list_id = tmdb.create_list(listname) xbmc.sleep(1000) tmdb.change_list_status(list_id=list_id, movie_id=self.info.get_property("id"), status=True) elif index == len(listitems) - 1: if tmdb.remove_list_dialog(tmdb.handle_lists(account_lists)): self.update_states() elif index > 0: tmdb.change_list_status(account_lists[index - 1]["id"], self.info.get_property("id"), True) self.update_states()
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogTVShowInfo, self).__init__(*args, **kwargs) self.type = 'TVShow' data = TheMovieDB.extended_tvshow_info(tvshow_id=kwargs.get( 'tmdb_id', False), dbid=self.dbid) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file( self.info.get('poster', '')) self.listitems = [(250, self.data['seasons']), (150, self.data['similar']), (1000, self.data['actors']), (750, self.data['crew']), (550, self.data['studios']), (1450, self.data['networks']), (850, self.data['genres']), (1250, self.data['images']), (1350, self.data['backdrops'])] else: super(DialogTVShowInfo, self).__init__(*args, **kwargs) self.type = 'TVShow' data = TheMovieDB.extended_tvshow_info(tvshow_id=kwargs.get( 'tmdb_id', False), dbid=self.dbid) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file( self.info.get('poster', '')) self.info['ImageFilter'], self.info[ 'ImageColor'] = ImageTools.filter_image( input_img=self.info.get('poster', ''), radius=25) self.listitems = [(250, self.data['seasons']), (150, self.data['similar']), (1150, self.data['videos']), (1000, self.data['actors']), (750, self.data['crew']), (550, self.data['studios']), (1450, self.data['networks']), (650, TheMovieDB.merge_with_cert_desc( self.data['certifications'], 'tv')), (850, self.data['genres']), (1250, self.data['images']), (1350, self.data['backdrops'])]
def set_genre_filter(self, control_id): params = {"language": addon.setting("LanguageID")} response = tmdb.get_data(url="genre/%s/list" % (self.type), params=params, cache_days=100) selected = [ i["id"] for i in self.filters if i["type"] == "with_genres" ] ids = [item["id"] for item in response["genres"]] labels = [item["name"] for item in response["genres"]] preselect = [ids.index(int(i)) for i in selected[0].split(",")] if selected else [] indexes = xbmcgui.Dialog().multiselect(heading=addon.LANG(32151), options=labels, preselect=preselect) if indexes is None: return None self.filters = [ i for i in self.filters if i["type"] != "with_genres" ] for i in indexes: self.add_filter(key="with_genres", value=ids[i], label=labels[i], reset=False) self.reset()
def update_states(self): xbmc.sleep(2000) # delay because MovieDB takes some time to update _, __, self.states = tmdb.extended_episode_info(tvshow_id=self.tvshow_id, season=self.info.get_info("season"), episode=self.info.get_info("episode"), cache_time=0) super(DialogEpisodeInfo, self).update_states()
def __init__(self, *args, **kwargs): super(DialogMovieInfo, self).__init__(*args, **kwargs) data = tmdb.extended_movie_info(movie_id=kwargs.get('id'), dbid=kwargs.get('dbid')) if not data: return None self.info, self.lists, self.states = data sets_thread = SetItemsThread(self.info.get_property("set_id")) self.omdb_thread = utils.FunctionThread( function=omdb.get_movie_info, param=self.info.get_property("imdb_id")) self.omdb_thread.start() sets_thread.start() self.info.update_properties(imagetools.blur( self.info.get_art("thumb"))) if not self.info.get_info("dbid"): self.info.set_art("poster", utils.get_file(self.info.get_art("poster"))) sets_thread.join() self.info.update_properties( {"set.%s" % k: v for k, v in list(sets_thread.setinfo.items())}) set_ids = [item.get_property("id") for item in sets_thread.listitems] self.lists["similar"] = [ i for i in self.lists["similar"] if i.get_property("id") not in set_ids ] self.lists["sets"] = sets_thread.listitems
def __init__(self, *args, **kwargs): super(DialogActorInfo, self).__init__(*args, **kwargs) data = tmdb.extended_actor_info(actor_id=kwargs.get('id')) if not data: return None self.info, self.lists = data self.info.update_properties(imagetools.blur(self.info.get_art("thumb")))
def update_states(self): xbmc.sleep(2000) # delay because MovieDB takes some time to update _, __, self.states = tmdb.extended_tvshow_info( tvshow_id=self.info.get_property("id"), cache_time=0, dbid=self.dbid) super(DialogTVShowInfo, self).update_states()
def set_rating_dialog(self, control_id): rating = utils.input_userrating() if tmdb.set_rating(media_type=self.TYPE_ALT, media_id=self.get_identifier(), rating=rating, dbid=self.info.get("dbid")): self.update_states()
def open_account_menu(self, control_id): if self.type == "tv": listitems = [addon.LANG(32145)] if self.logged_in: listitems.append(addon.LANG(32144)) else: listitems = [addon.LANG(32135)] if self.logged_in: listitems.append(addon.LANG(32134)) busy.show_busy() if self.logged_in: account_lists = tmdb.get_account_lists() listitems += ["%s (%i)" % (i["name"], i["item_count"]) for i in account_lists] busy.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == -1: pass elif index == 0: self.set_sort("created_at") self.filters = [] self.reset("rating") elif index == 1: self.set_sort("created_at") self.filters = [] self.reset("favorites") else: self.close() dialog = wm.open_video_list(filters=[], mode="list", list_id=account_lists[index - 2]["id"], filter_label=account_lists[index - 2]["name"]) dialog.doModal()
def open_account_menu(self, control_id): if self.type == "tv": listitems = [addon.LANG(32145)] if self.logged_in: listitems.append(addon.LANG(32144)) else: listitems = [addon.LANG(32135)] if self.logged_in: listitems.append(addon.LANG(32134)) wm.show_busy() if self.logged_in: account_lists = tmdb.get_account_lists() listitems += ["%s (%i)" % (i["name"], i["item_count"]) for i in account_lists] wm.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == -1: pass elif index == 0: self.sort = "created_at" self.sort_label = addon.LANG(32157) self.filters = [] self.reset("rating") elif index == 1: self.sort = "created_at" self.sort_label = addon.LANG(32157) self.filters = [] self.reset("favorites") else: self.close() dialog = wm.open_video_list(filters=[], mode="list", list_id=account_lists[index - 2]["id"], filter_label=account_lists[index - 2]["name"]) dialog.doModal()
def set_certification_filter(self, control_id): response = tmdb.get_certification_list(self.type) countries = [key for key in response.keys()] index = xbmcgui.Dialog().select(heading=addon.LANG(21879), list=countries) if index == -1: return None country = countries[index] certs = [ "%s - %s" % (i["certification"], i["meaning"]) for i in response[country] ] index = xbmcgui.Dialog().select(heading=addon.LANG(32151), list=certs) if index == -1: return None cert = certs[index].split(" - ")[0] self.add_filter(key="certification_country", value=country, typelabel=addon.LANG(32153), label=country, reset=False) self.add_filter(key="certification", value=cert, typelabel=addon.LANG(32127), label=cert)
def run(self): if self.set_id: self.listitems, self.setinfo = TheMovieDB.get_set_movies(self.set_id) self.id_list = [item['id'] for item in self.listitems] else: self.id_list = [] self.listitems = [] self.setinfo = {}
def play_episode(self): if self.dbid and int(self.dbid) > 0: dbid = self.dbid url = '' PLAYER.play_from_button(url, listitem=None, window=self, type='episodeid', dbid=dbid) else: url = 'plugin://plugin.video.chappaai/tv/play/%s/%s/%s' % (Utils.fetch(TheMovieDB.get_tvshow_ids(self.tvshow_id), 'tvdb_id'), self.info['season'], self.info['episode']) xbmc.executebuiltin('RunPlugin(%s)' % url)
def update_states(self): xbmc.sleep(2000) # delay because MovieDB takes some time to update info = tmdb.get_episode(tvshow_id=self.tvshow_id, season=self.info.get_info("season"), episode=self.info.get_info("episode"), cache_days=0) self.states = info.get("account_states") super(DialogEpisodeInfo, self).update_states()
def update_states(self): xbmc.sleep(2000) # delay because MovieDB takes some time to update _, __, self.states = tmdb.extended_episode_info( tvshow_id=self.tvshow_id, season=self.info.get_info("season"), episode=self.info.get_info("episode"), cache_time=0) super(DialogEpisodeInfo, self).update_states()
def movie_context_menu(self, control_id): movie_id = self.FocusedItem(control_id).getProperty("id") dbid = self.FocusedItem(control_id).getVideoInfoTag().getDbId() options = [addon.LANG(32113)] if self.logged_in: options.append(addon.LANG(32083)) index = xbmcgui.Dialog().contextmenu(list=options) if index == 0: rating = utils.input_userrating() if rating == -1: return None tmdb.set_rating(media_type="movie", media_id=movie_id, rating=rating, dbid=dbid) xbmc.sleep(2000) tmdb.get_movie(movie_id=movie_id, cache_days=0) elif index == 1: account_lists = tmdb.get_account_lists() if not account_lists: return False listitems = [ "%s (%i)" % (i["name"], i["item_count"]) for i in account_lists ] i = xbmcgui.Dialog().select(addon.LANG(32136), listitems) if i > -1: tmdb.change_list_status(list_id=account_lists[i]["id"], movie_id=movie_id, status=True)
def movie_context_menu(self, control_id): movie_id = self.FocusedItem(control_id).getProperty("id") dbid = self.FocusedItem(control_id).getVideoInfoTag().getDbId() options = [addon.LANG(32113)] if self.logged_in: options.append(addon.LANG(32083)) index = xbmcgui.Dialog().contextmenu(list=options) if index == 0: rating = utils.input_userrating() if rating == -1: return None tmdb.set_rating(media_type="movie", media_id=movie_id, rating=rating, dbid=dbid) xbmc.sleep(2000) tmdb.get_movie(movie_id=movie_id, cache_days=0) elif index == 1: account_lists = tmdb.get_account_lists() if not account_lists: return False listitems = ["%s (%i)" % (i["name"], i["item_count"]) for i in account_lists] i = xbmcgui.Dialog().select(addon.LANG(32136), listitems) if i > -1: tmdb.change_list_status(list_id=account_lists[i]["id"], movie_id=movie_id, status=True)
def fetch_data(self, force=False): sort_by = self.sort + '.' + self.order if self.type == 'tv': temp = 'tv' rated = 'Rated TV shows' starred = 'Starred TV shows' else: temp = 'movies' rated = 'Rated movies' starred = 'Starred movies' if self.mode == 'search': url = 'search/multi?query=%s&page=%i&include_adult=%s&' % (urllib.quote_plus(self.search_str), self.page, xbmcaddon.Addon().getSetting('include_adults')) if self.search_str: self.filter_label = 'Results for: ' + self.search_str else: self.filter_label = '' elif self.mode == 'list': url = 'list/%s?language=%s&' % (str(self.list_id), xbmcaddon.Addon().getSetting('LanguageID')) else: self.set_filter_url() self.set_filter_label() url = 'discover/%s?sort_by=%s&%slanguage=%s&page=%i&include_adult=%s&' % (self.type, sort_by, self.filter_url, xbmcaddon.Addon().getSetting('LanguageID'), int(self.page), xbmcaddon.Addon().getSetting('include_adults')) if force: response = TheMovieDB.get_tmdb_data(url=url, cache_days=0) else: response = TheMovieDB.get_tmdb_data(url=url, cache_days=2) if not response: return None if 'results' not in response: return {'listitems': [], 'results_per_page': 0, 'total_results': 0} if not response['results']: Utils.notify('No results found') if self.mode == 'search': listitems = TheMovieDB.handle_tmdb_multi_search(response['results']) elif self.type == 'movie': listitems = TheMovieDB.handle_tmdb_movies(results=response['results'], local_first=False, sortkey=None) else: listitems = TheMovieDB.handle_tmdb_tvshows(results=response['results'], local_first=False, sortkey=None) info = { 'listitems': listitems, 'results_per_page': response['total_pages'], 'total_results': response['total_results'] } return info
def __init__(self, *args, **kwargs): super(DialogTVShowInfo, self).__init__(*args, **kwargs) data = tmdb.extended_tvshow_info(tvshow_id=kwargs.get('tmdb_id'), dbid=kwargs.get('dbid')) if not data: return None self.info, self.lists, self.states = data if not self.info.get_info("dbid"): self.info.set_art("poster", utils.get_file(self.info.get_art("poster"))) self.info.update_properties(imagetools.blur(self.info.get_art("poster")))
def __init__(self, *args, **kwargs): super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.tvshow_id = kwargs.get('tvshow_id') data = tmdb.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'), episode=kwargs.get('episode')) if not data: return None self.info, self.lists, self.states = data self.info.update_properties(imagetools.blur(self.info.get("thumb")))
def set_rating_dialog(self, control_id): preselect = int(self.states["rated"]["value"]) if (self.states and self.states.get("rated")) else -1 rating = utils.input_userrating(preselect=preselect) if rating == -1: return None if tmdb.set_rating( media_type=self.TYPE_ALT, media_id=self.get_identifier(), rating=rating, dbid=self.info.get_info("dbid") ): self.setProperty("rated", str(rating) if rating > 0 else "") self.update_states()
def __init__(self, *args, **kwargs): super(DialogTVShowInfo, self).__init__(*args, **kwargs) data = tmdb.extended_tvshow_info(tvshow_id=kwargs.get('tmdb_id', False), dbid=self.dbid) if not data: return None self.info, self.lists, self.states = data if not self.info.get_info("dbid"): self.info.set_art("poster", utils.get_file(self.info.get_art("poster"))) self.info.update_properties(imagetools.blur(self.info.get_art("poster")))
def set_keyword_filter(self): result = xbmcgui.Dialog().input(heading='Enter search string', type=xbmcgui.INPUT_ALPHANUM) if not result or result == -1: return None response = TheMovieDB.get_keyword_id(result) if not response: return None self.add_filter('with_keywords', str(response['id']), 'Keyword', response['name']) self.mode = 'filter' self.page = 1 self.update()
def open_credit_dialog(self, credit_id): info = tmdb.get_credit_info(credit_id) listitems = [] if "seasons" in info["media"]: listitems += tmdb.handle_seasons(info["media"]["seasons"]) if "episodes" in info["media"]: listitems += tmdb.handle_episodes(info["media"]["episodes"]) if not listitems: listitems += [{"label": addon.LANG(19055)}] listitem, index = selectdialog.open_selectdialog(header=addon.LANG(32151), listitems=listitems) if listitem["mediatype"] == "episode": wm.open_episode_info(prev_window=self, season=listitems[index]["season"], episode=listitems[index]["episode"], tvshow_id=info["media"]["id"]) elif listitem["mediatype"] == "season": wm.open_season_info(prev_window=self, season=listitems[index]["season"], tvshow_id=info["media"]["id"])
def tvshow_context_menu(self, control_id): tvshow_id = self.FocusedItem(control_id).getProperty("id") dbid = self.FocusedItem(control_id).getVideoInfoTag().getDbId() credit_id = self.FocusedItem(control_id).getProperty("credit_id") options = [addon.LANG(32169)] if credit_id: options.append(addon.LANG(32147)) index = xbmcgui.Dialog().contextmenu(list=options) if index == 0: rating = utils.input_userrating() if rating == -1: return None tmdb.set_rating(media_type="tvshow", media_id=tvshow_id, rating=rating, dbid=dbid) xbmc.sleep(2000) tmdb.get_tvshow(tvshow_id=tvshow_id, cache_days=0) if index == 1: self.open_credit_dialog(credit_id=credit_id)
def __init__(self, *args, **kwargs): super(DialogEpisodeInfo, self).__init__(*args, **kwargs) self.tvshow_id = kwargs.get('tvshow_id') data = tmdb.extended_episode_info(tvshow_id=self.tvshow_id, season=kwargs.get('season'), episode=kwargs.get('episode')) if not data: return None self.info, self.lists, self.states = data self.info.update_properties(imagetools.blur( self.info.get("thumb")))
def set_actor_filter(self, control_id): result = xbmcgui.Dialog().input(heading=addon.LANG(16017), type=xbmcgui.INPUT_ALPHANUM) if not result or result == -1: return None response = tmdb.get_person_info(result) if not response: return None self.add_filter(key="with_people", value=response["id"], label=response["name"])
def open_credit_dialog(self, credit_id): info = tmdb.get_credit_info(credit_id) listitems = [] if "seasons" in info["media"]: listitems += tmdb.handle_seasons(info["media"]["seasons"]) if "episodes" in info["media"]: listitems += tmdb.handle_episodes(info["media"]["episodes"]) if not listitems: listitems += [{"label": addon.LANG(19055)}] listitem, index = selectdialog.open_selectdialog( header=addon.LANG(32151), listitems=listitems) if listitem["mediatype"] == "episode": wm.open_episode_info(prev_window=self, season=listitems[index]["season"], episode=listitems[index]["episode"], tvshow_id=info["media"]["id"]) elif listitem["mediatype"] == "season": wm.open_season_info(prev_window=self, season=listitems[index]["season"], tvshow_id=info["media"]["id"])
def set_rating_dialog(self, control_id): preselect = int(self.states["rated"]["value"]) if (self.states and self.states.get("rated")) else -1 rating = utils.input_userrating(preselect=preselect) if rating == -1: return None if tmdb.set_rating(media_type=self.TYPE_ALT, media_id=self.get_identifier(), rating=rating, dbid=self.info.get_info("dbid")): self.setProperty("rated", str(rating) if rating > 0 else "") self.update_states()
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 if item["runtime"] else "", '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")}) art_info = tmdb.get_tvshow(item["ids"]["tmdb"], light=True) show.set_artwork(tmdb.get_image_urls(poster=art_info.get("poster_path"), fanart=art_info.get("backdrop_path"))) 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 __init__(self, *args, **kwargs): super(DialogSeasonInfo, self).__init__(*args, **kwargs) self.tvshow_id = kwargs.get('id') data = tmdb.extended_season_info(tvshow_id=self.tvshow_id, season_number=kwargs.get('season')) if not data: return None self.info, self.lists = data if not self.info.get_info("dbid"): # need to add comparing for seasons poster = utils.get_file(url=self.info.get_art("poster")) self.info.set_art("poster", poster) self.info.update_properties(imagetools.blur(self.info.get_art("poster")))
def set_genre_filter(self, control_id): params = {"language": addon.setting("LanguageID")} response = tmdb.get_data(url="genre/%s/list" % (self.type), params=params, cache_days=10) ids = [item["id"] for item in response["genres"]] labels = [item["name"] for item in response["genres"]] index = xbmcgui.Dialog().select(heading=addon.LANG(32151), list=labels) if index == -1: return None self.add_filter(key="with_genres", value=str(ids[index]), typelabel=addon.LANG(135), label=labels[index])
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 context_menu(self, control_id): item_id = self.FocusedItem(control_id).getProperty("id") media_type = self.FocusedItem(control_id).getVideoInfoTag().getMediaType() listitems = [addon.LANG(32169)] if media_type == "tvshow" else [addon.LANG(32113)] if self.logged_in: listitems += [addon.LANG(14076)] if not self.type == "tv": listitems += [addon.LANG(32107)] if self.mode == "list": listitems += [addon.LANG(32035)] index = xbmcgui.Dialog().contextmenu(list=listitems) if index == 0: # HACK until we can get userrating from listitem via python rating = utils.get_infolabel("listitem.userrating") rating = utils.input_userrating(preselect=int(rating) if rating.isdigit() else -1) if rating == -1: return None if tmdb.set_rating(media_type="tv" if media_type == "tvshow" else "movie", media_id=item_id, rating=rating, dbid=self.FocusedItem(control_id).getVideoInfoTag().getDbId()): xbmc.sleep(2000) self.update(force_update=True) self.setCurrentListPosition(self.position) elif index == 1: tmdb.change_fav_status(media_id=item_id, media_type=self.type, status="true") elif index == 2: self.list_dialog(item_id) elif index == 3: tmdb.change_list_status(list_id=self.list_id, movie_id=item_id, status=False) self.update(force_update=True) self.setCurrentListPosition(self.position)
def open_list_button(self, control_id): busy.show_busy() movie_lists = tmdb.get_account_lists() listitems = ["%s (%i)" % (i["name"], i["item_count"]) for i in movie_lists] listitems = [addon.LANG(32134), addon.LANG(32135)] + listitems busy.hide_busy() index = xbmcgui.Dialog().select(addon.LANG(32136), listitems) if index == -1: pass elif index < 2: wm.open_video_list(mode="favorites" if index == 0 else "rating") else: wm.open_video_list(mode="list", list_id=movie_lists[index - 2]["id"], filter_label=movie_lists[index - 2]["name"], force=True)
def list_dialog(self, movie_id): busy.show_busy() listitems = [addon.LANG(32139)] account_lists = tmdb.get_account_lists() listitems += ["%s (%i)" % (i["name"], i["item_count"]) for i in account_lists] listitems.append(addon.LANG(32138)) busy.hide_busy() index = xbmcgui.Dialog().select(heading=addon.LANG(32136), list=listitems) if index == 0: listname = xbmcgui.Dialog().input(heading=addon.LANG(32137), type=xbmcgui.INPUT_ALPHANUM) if listname: xbmc.sleep(1000) tmdb.change_list_status(list_id=tmdb.create_list(listname), movie_id=movie_id, status=True) elif index == len(listitems) - 1: tmdb.remove_list_dialog(tmdb.handle_lists(account_lists)) elif index > 0: tmdb.change_list_status(list_id=account_lists[index - 1]["id"], movie_id=movie_id, status=True)
def set_company_filter(self, control_id): result = xbmcgui.Dialog().input(heading=addon.LANG(16017), type=xbmcgui.INPUT_ALPHANUM) if not result or result < 0: return None items = tmdb.search_companies(result) if len(items) > 1: index = selectdialog.open(header=addon.LANG(32151), listitems=items) if index > -1: item = items[index] elif items: item = items[0] else: utils.notify("No company found") self.add_filter(key="with_companies", value=item.get_property("id"), label=item.get_label())
def fetch_data(self, force=False): # TODO: rewrite sort_by = self.sort + "." + self.order temp = "tv" if self.type == "tv" else "movies" if self.mode == "search": self.filter_label = addon.LANG(32146) % self.search_str if self.search_str else "" return tmdb.multi_search(search_str=self.search_str, page=self.page, cache_days=0 if force else 2) elif self.mode == "list": return tmdb.get_list_movies(list_id=self.list_id, force=force) elif self.mode == "favorites": self.filter_label = addon.LANG(32144) if self.type == "tv" else addon.LANG(32134) return tmdb.get_fav_items(media_type=temp, sort_by=sort_by, page=self.page) elif self.mode == "rating": self.filter_label = addon.LANG(32145) if self.type == "tv" else addon.LANG(32135) return tmdb.get_rated_media_items(media_type=temp, sort_by=sort_by, page=self.page, cache_days=0) else: self.set_filter_label() params = {"sort_by": sort_by, "language": addon.setting("LanguageID"), "page": self.page, "include_adult": include_adult} filters = {item["type"]: item["id"] for item in self.filters} response = tmdb.get_data(url="discover/%s" % (self.type), params=utils.merge_dicts(params, filters), cache_days=0 if force else 2) if not response["results"]: utils.notify(addon.LANG(284)) return None if self.type == "movie": itemlist = tmdb.handle_movies(results=response["results"], local_first=False, sortkey=None) else: itemlist = tmdb.handle_tvshows(results=response["results"], local_first=False, sortkey=None) itemlist.set_totals(response["total_results"]) itemlist.set_total_pages(response["total_pages"]) return itemlist
def set_company_filter(self, control_id): result = xbmcgui.Dialog().input(heading=addon.LANG(16017), type=xbmcgui.INPUT_ALPHANUM) if not result or result < 0: return None response = tmdb.search_company(result) if len(response) > 1: selection = xbmcgui.Dialog().select(heading=addon.LANG(32151), list=[i["name"] for i in response]) if selection > -1: response = response[selection] elif response: response = response[0] else: utils.notify("No company found") self.add_filter(key="with_companies", value=str(response["id"]), typelabel=addon.LANG(20388), label=response["name"])
def set_keyword_filter(self, control_id): result = xbmcgui.Dialog().input(heading=addon.LANG(16017), type=xbmcgui.INPUT_ALPHANUM) if not result or result == -1: return None keywords = tmdb.get_keywords(result) if not keywords: return None if len(keywords) > 1: index = xbmcgui.Dialog().select(heading=addon.LANG(32114), list=[item["name"] for item in keywords]) keyword = keywords[index] if index > -1 else None if not keyword: return None else: keyword = keywords[0] self.add_filter(key="with_keywords", value=keyword["id"], label=keyword["name"])
def __init__(self, *args, **kwargs): super(DialogMovieInfo, self).__init__(*args, **kwargs) data = tmdb.extended_movie_info(movie_id=kwargs.get('id'), dbid=kwargs.get('dbid')) if not data: return None self.info, self.lists, self.states = data sets_thread = SetItemsThread(self.info.get_property("set_id")) self.omdb_thread = utils.FunctionThread(function=omdb.get_movie_info, param=self.info.get_property("imdb_id")) self.omdb_thread.start() sets_thread.start() self.info.update_properties(imagetools.blur(self.info.get_art("thumb"))) if not self.info.get_info("dbid"): self.info.set_art("poster", utils.get_file(self.info.get_art("poster"))) sets_thread.join() self.info.update_properties({"set.%s" % k: v for k, v in sets_thread.setinfo.iteritems()}) set_ids = [item.get_property("id") for item in sets_thread.listitems] self.lists["similar"] = [i for i in self.lists["similar"] if i.get_property("id") not in set_ids] self.lists["sets"] = sets_thread.listitems
def set_certification_filter(self, control_id): response = tmdb.get_certification_list(self.type) countries = [key for key in response.keys()] index = xbmcgui.Dialog().select(heading=addon.LANG(21879), list=countries) if index == -1: return None country = countries[index] certs = ["%s - %s" % (i["certification"], i["meaning"]) for i in response[country]] index = xbmcgui.Dialog().select(heading=addon.LANG(32151), list=certs) if index == -1: return None cert = certs[index].split(" - ")[0] self.add_filter(key="certification_country", value=country, label=country, reset=False) self.add_filter(key="certification", value=cert, label=cert)