def onClick(self, control): global source global query global page global maxpage global genre_id global genre_name global year global person_id global person_name global keyword_id global list_id global list_name movieid = "" movieid = self.get_movieid_from_control(control) do_movies = False do_tv = False do_people = False popular = 32101 top_rated = 32102 upcoming = 32103 now_playing = 32104 favorites = 33105 watchlist = 33106 rated = 33107 list_btn = 33108 query_btn = 81 previous = 32116 next = 32117 tv_shows = 32114 people = 32115 genre_btn = 82 year_btn = 83 person_btn = 84 if movieid != "": from resources.lib import movie movie.movie_id = movieid movie_window = movie.movieWindow("script-movieDetailWindow.xml", addon_path, "default") movie_window.doModal() del movie_window if control == popular and source != "popular": source = "popular" page = 1 do_movies = True if control == top_rated and source != "top_rated": source = "top_rated" do_movies = True page = 1 if control == upcoming and source != "upcoming": source = "upcoming" do_movies = True page = 1 if control == now_playing and source != "now_playing": source = "now_playing" do_movies = True page = 1 if control == favorites and source != "favorites": do_movies = True source = "favorites" page = 1 if control == watchlist and source != "watchlist": do_movies = True source = "watchlist" page = 1 if control == rated and source != "rated": do_movies = True source = "rated" page = 1 if control == query_btn: source = "query" do_movies = True page = 1 if control == genre_btn: source = "genre" page = 1 genre_id = "" do_movies = True if control == year_btn: source = "years" page = 1 year = "" do_movies = True if control == person_btn: source = "person" page = 1 person_id = "" person_name = "" do_movies = True if control == list_btn: source = "list" list_id = "" page = 1 do_movies = True if control == next: if page < maxpage: page = page + 1 do_movies = True if control == previous: if page > 1: page = page - 1 do_movies = True if control == tv_shows: do_tv = True if control == people: do_people = True if do_movies: ans = True if source == "query": self.getControl(80).setVisible(True) if control == query_btn: k = xbmc.Keyboard("", "Enter Movie Title to Search For") k.doModal() query = k.getText() if query != "": movies = tmdb.search_movies(query, page) maxpage = movies["total_pages"] movies = movies["results"] if maxpage > page: movies.append(tmdb.search_movies(query, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "favorites": if self.session_id == "": session_id = utils.get_login() if session_id != "": self.session_id = session_id if self.session_id != "": movies = tmdb.get_favorite_movies(self.session_id, page) total_pages = movies["total_pages"] maxpage = total_pages movies = movies["results"] if total_pages > page: movies.append(tmdb.get_favorite_movies(self.session_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "watchlist": if self.session_id == "": session_id = utils.get_login() if session_id != "": self.session_id = session_id if self.session_id != "": movies = tmdb.get_watchlist_movies(self.session_id, page) total_pages = movies["total_pages"] maxpage = total_pages movies = movies["results"] if total_pages > page: movies.append(tmdb.get_watchlist_movies(self.session_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "rated": if self.session_id == "": session_id = utils.get_login() if session_id != "": self.session_id = session_id if self.session_id != "": movies = tmdb.get_rated_movies(self.session_id, page) total_pages = movies["total_pages"] maxpage = total_pages movies = movies["results"] if total_pages > page: movies.append(tmdb.get_rated_movies(self.session_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "list": if self.session_id == "": session_id = utils.get_login() if session_id != "": self.session_id = session_id if self.session_id != "" and list_id == "": dg = dialogWindow("dialog_select.xml", addon_path, "Default") dg.mode = "list" dg.doModal() if list_name == "Add New": k = xbmc.Keyboard("", "Enter List Name") k.doModal() name = k.getText() if name != "" and (k.isConfirmed()): k = xbmc.Keyboard("", "Enter List Description") k.doModal() description = k.getText() if k.isConfirmed(): res = tmdb.add_list(name, description, addon.getSetting("session_id")) if res: dialog = xbmcgui.Dialog() dialog.notification( "themoviedb.org Browser", "List " + name + " Successfully Added", xbmcgui.NOTIFICATION_INFO, 5000, ) else: dialog = xbmcgui.Dialog() dialog.notification( "themoviedb.org Browser", "Failed Add " + name, xbmcgui.NOTIFICATION_ERROR, 5000 ) if list_id != "": movies = tmdb.get_movie_list(list_id) movies = movies["items"] pages = len(movies) / 20 if len(movies) % 20 > 0: pages = pages + 1 total_pages = pages maxpage = total_pages list_movies = [] if page > 1: for i in range((page * 20) - 20, (page * 20) + 1): if i < len(movies): list_movies.append(movies[i]) movies = list_movies show_movies(movies, source, page) elif source == "genre": if genre_id == "": dg = dialogWindow("dialog_select.xml", addon_path, "Default") dg.mode = "genre" dg.doModal() if genre_id != "": movies = tmdb.get_movies_by_genre(genre_id, page) total_pages = movies["total_pages"] movies = movies["results"] maxpage = total_pages if total_pages > page: movies.append(tmdb.get_movies_by_genre(genre_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "years": if year == "": kb = xbmc.Keyboard("", "Enter Year") kb.doModal() year = kb.getText() movies = tmdb.get_movies_by_year(year, page) total_pages = movies["total_pages"] movies = movies["results"] maxpage = total_pages if total_pages > page: movies.append(tmdb.get_movies_by_year(year, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "similar": movies = tmdb.get_similar_movies(similar_id, page) total_pages = movies["total_pages"] movies = movies["results"] maxpage = total_pages if total_pages > page: movies.append(tmdb.get_similar_movies(similar_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "keyword": movies = tmdb.getMoviesByKeyword(keyword_id, page) total_pages = movies["total_pages"] movies = movies["results"] maxpage = total_pages if total_pages > page: movies.append(tmdb.getMoviesByKeyword(keyword_id, page + 1)["results"][0]) show_movies(movies, source, page) elif source == "person": if person_id == "": kb = xbmc.Keyboard("", "Enter Persons Name") kb.doModal() person_name = kb.getText() if person_name != "": dg = dialogWindow("dialog_select.xml", addon_path, "Default") dg.mode = "people" dg.doModal() movies = tmdb.getMoviesByActor(person_id, page) pages = len(movies) / 20 if len(movies) % 20 > 0: pages = pages + 1 total_pages = pages xbmc.log(str(len(movies))) maxpage = total_pages movies = sorted(movies, key=lambda k: k["release_date"], reverse=True) person_movies = [] if page > 1: for i in range((page * 20) - 20, (page * 20) + 1): if i < len(movies): person_movies.append(movies[i]) movies = person_movies show_movies(movies, source, page) elif source in ("Production", "Directing", "Writing"): person = tmdb.get_person(person_id) crew_movies = person["movie_credits"]["crew"] movies = [] for movie in crew_movies: if movie["department"] == source: movies.append(movie) pages = len(movies) / 20 if len(movies) % 20 > 0: pages = pages + 1 total_pages = pages maxpage = total_pages movies = sorted(movies, key=lambda k: k["release_date"], reverse=True) person_movies = [] if page > 1: for i in range((page * 20) - 20, (page * 20) + 1): if i < len(movies): person_movies.append(movies[i]) movies = person_movies show_movies(movies, source, page) else: query = "" xbmc.log(source) movies = tmdb.get_movies(source, page) total_pages = movies["total_pages"] maxpage = 10 if source == "upcoming" or source == "now_playing": maxpage = movies["total_pages"] movies = movies["results"] if total_pages > page: movies.append(tmdb.get_movies(source, page + 1)["results"][0]) show_movies(movies, source, page) elif do_tv: from resources.lib import tvshows tvshows.source = "popular" tvshows.startup() elif do_people: from resources.lib import people people.source = "popular" people.startup()
def onClick(self,control): if control == 115: li=xbmcgui.ListItem li=self.getControl(115).getSelectedItem() label=li.getLabel() if self.getControl(116).isSelected()==True: mode='movies' else: mode='tv' if 'Actor' in label: self.mode='actor_'+ mode if mode=='movies': self.show_person_movies(self.current_person) else: self.show_person_tv(self.current_person) if 'Director' in label: self.mode='director_'+ mode if mode=='movies': self.show_director_movies(self.current_person) else: self.show_director_tv(self.current_person) if 'Producer' in label: self.mode='producer_'+ mode if mode=='movies': self.show_producer_movies(self.current_person) else: self.show_producer_tv(self.current_person) if 'Writer' in label: self.mode='writer_'+ mode if mode=='movies': self.show_writer_movies(self.current_person) else: self.show_writer_tv(self.current_person) if control in(200,201,202,203,204,205,206,207,208,209): movie_id='' tv_id='' if self.mode=='actor_movies':movie_id=self.movie_cast[control-200]['id'] if self.mode=='director_movies':movie_id=self.movie_direction[control-200]['id'] if self.mode=='producer_movies':movie_id=self.movie_production[control-200]['id'] if self.mode=='writer_movies':movie_id=self.movie_writing[control-200]['id'] if movie_id!='': from resources.lib import movie movie.movie_id=movie_id movie_window = movie.movieWindow('script-movieDetailWindow.xml', addon_path,'default') movie_window.doModal() del movie_window if control==116: self.mode='actor_movies' self.getControl(117).setSelected(False) self.getControl(116).setSelected(True) self.update_mode() if control==117: self.mode='actor_tv' self.getControl(117).setSelected(True) self.getControl(116).setSelected(False) self.update_mode() if control==129: #Webpage url=self.current_person['homepage'] url=urllib.quote_plus(url) xbmc.Player().play('plugin://plugin.program.chrome.launcher/?url=' + url + '&mode=showSite&stopPlayback=no') if control==104: iw = imageWindow('image.xml', addon_path,'default') iw.images=self.posters iw.image_index=self.poster_index iw.doModal() del iw if control == 105 or control == 106: if control==105: if self.poster_index==0: self.poster_index=len(self.posters)-1 else: self.poster_index=self.poster_index-1 if control==106: if self.poster_index==len(self.posters)-1: self.poster_index=0 else: self.poster_index=self.poster_index+1 self.getControl(102).setImage('') self.getControl(107).setLabel(str(self.poster_index+1) + ' of ' + str(len(self.posters))) self.getControl(101).setLabel('Loading') self.getControl(102).setImage('http://image.tmdb.org/t/p/original' +self.posters[self.poster_index]) self.getControl(901).setImage('http://image.tmdb.org/t/p/original' +self.posters[self.poster_index]) if control==5020: department='' if 'movies' in self.mode: from resources.lib import movies movies.person_id=self.current_person['id'] movies.person_name=self.current_person['name'] movies.page=1 if self.mode=='actor_movies': movies.source='person' movies.show_movies_by_person(self.current_person['id']) if self.mode=='director_movies':department='Directing' if self.mode=='producer_movies':department='Production' if self.mode=='writer_movies':department='Writing' if department!='': movies.show_movies_from_person(self.current_person['id'],department)