def onClick(self, control): movie_id = self.movie["id"] if control == 300: li = self.getControl(300).getSelectedItem() action = li.getProperty("action") if action == "add_favorite": utils.add_favorite(movie_id, self.session_id) if action == "remove_favorite": utils.remove_favorite(movie_id, self.session_id) if action == "add_watchlist": utils.remove_watchlist(movie_id, self.session_id) if action == "remove_watchlist": utils.remove_watchlist(movie_id, self.session_id) if action == "show_info": from resources.lib import movie movie.movie_id = self.movie["id"] movie.startup() if action == "play": f = utils.find_xbmc_by_title(self.movie["title"], self.movie["release_date"][:4]) if f != "": xbmc.Player().play(f) xbmc.executebuiltin("Dialog.Close(all,true)") if action == "add_couchpotato": xbmc.executebuiltin( "XBMC.RunPlugin('plugin://plugin.video.couchpotato_manager/movies/add?title='" + self.movie["title"] + "')'" ) if action == "manage_list": ds = dialogWindow("dialog_select.xml", addon_path, "Default") ds.mode = "context_list" ds.curr_movie = self.movie ds.doModal() self.close()
def onInit(self): self.getControl(129).setVisible(False) self.getControl(5020).setVisible(False) movie=tmdb.get_movie(movie_id) if use_chrome=='true' and movie['homepage']!='':self.getControl(129).setVisible(True) self.session_id=addon.getSetting('session_id') star=round(movie['vote_average'],2) if self.session_id!='': lists=[] lists_string=tmdb.get_users_lists(addon.getSetting('session_id'),1) lists_results=lists_string['results'] for list in lists_results: lists.append(list['id']) if lists_string['total_pages']> 1: for i in range(2,lists_string['total_pages']): l=tmdb.get_users_lists(addon.getSetting('session_id'),i) for list in l['results']: lists.append(l['id']) for list in lists: if tmdb.is_in_list(list,movie_id)['item_present']: self.getControl(4010).setImage('film-icon.png') break states=tmdb.get_movie_account_states(movie_id,self.session_id) if states['favorite']:self.getControl(4011).setImage('favorite-enable.png') if states['watchlist']:self.getControl(5011).setImage('popcorn-enable.png') if states['rated']: self.getControl(131).setLabel(str(star)+'/10 (' + str(movie['vote_count']) + ' votes, you voted '+ str(states['rated']['value']) +')') else: self.getControl(131).setLabel(str(star)+'/10 (' + str(movie['vote_count']) + ' votes)') else: self.getControl(131).setLabel(str(star)+'/10 (' + str(movie['vote_count']) + ' votes)') self.file=utils.find_xbmc_by_title(movie['title'],movie['release_date'][:4]) if self.file!='': self.getControl(127).setLabel('Play') you_tube_base_url='plugin://plugin.video.youtube/?action=play_video&videoid=' self.posters=[] str_similar=tmdb.get_similar_movies(movie_id,1) similar=str_similar['results'] if self.mode=='similar':self.total_results=str_similar['total_results'] plot=self.getControl(103) tagline=self.getControl(108) runtime=self.getControl(109) title=xbmcgui.ControlButton(20,5,800,30,'','','',0,0,0,title_font,'ff606060','',0,'','ff606060') title=self.addControl(title) title=self.getControl(3001) title.setAnimations([('windowclose', 'effect=fade end=0 time=0',)]) self.current_movie=movie crew = movie['credits']['crew'] cast = movie['credits']['cast'] self.cast= sorted(cast, key=lambda k: k['order']) director='' writer='' genres='' for crew_member in crew: if crew_member['job'] =='Director': director=director+ crew_member['name'] + ", " if crew_member['department'] == 'Writing': writer=writer + crew_member['name'] + ", " director=director[:-2] writer=writer[:-2] studio='' for company in movie['production_companies']: studio=studio+company['name'] + ", " studio=studio[:-2] for genre in movie['genres']: genres=genres + genre['name'] + ' / ' genres=genres[:-3] mpaa='' for release in movie['releases']['countries']: if release['iso_3166_1'] =='US': mpaa=release['certification'] self.getControl(110).setLabel(director) self.getControl(112).setLabel(studio) self.getControl(113).setLabel(genres) self.getControl(114).setLabel(mpaa) self.getControl(115).setLabel(movie['status']) self.getControl(116).setLabel(utils.format_currency(movie['budget'])) self.getControl(117).setLabel(utils.format_currency(movie['revenue'])) self.getControl(118).setLabel(utils.format_date(movie['release_date'])) self.getControl(111).setLabel(writer) title.setLabel(movie['title']) runtime.setLabel(str(movie['runtime']) +' min') tagline.setLabel(movie['tagline']) plot.setText(movie['overview']) self.getControl(102).setImage('') self.backgrounds=[] self.posters=[] if movie['poster_path']!=None: self.posters.append(movie['poster_path']) if movie['images']['posters']>0: for poster in movie['images']['posters']: if poster['iso_639_1']=='en': if poster['file_path'] not in self.posters: self.posters.append(poster['file_path']) xbmc.log('number of posters = ' + str(len(self.posters))) if len(self.posters) > 0: self.getControl(102).setImage('') self.getControl(101).setLabel('Loading') self.getControl(102).setImage('http://image.tmdb.org/t/p/original' +self.posters[0]) self.getControl(901).setImage('http://image.tmdb.org/t/p/original' +self.posters[0]) else: self.getControl(101).setLabel('') if movie['backdrop_path']!=None: self.backgrounds.append(movie['backdrop_path']) if movie['images']['backdrops']>0: for background in movie['images']['backdrops']: if background['file_path'] not in self.backgrounds: self.backgrounds.append(background['file_path']) xbmc.log('number of backgrounds = ' + str(len(self.backgrounds))) if len(self.backgrounds) > 0: self.getControl(402).setImage('') self.getControl(401).setLabel('Loading') self.getControl(402).setImage('http://image.tmdb.org/t/p/original' +self.backgrounds[0]) self.getControl(900).setImage('http://image.tmdb.org/t/p/original' +self.backgrounds[0]) else: self.getControl(401).setLabel('') self.getControl(107).setLabel('1 of ' + str(len(self.posters))) self.getControl(407).setLabel('1 of ' + str(len(self.backgrounds))) self.show_similar(similar) if star >= .5: self.getControl(1001).setImage('half-star-icon-enable.png') if star >= 1: self.getControl(1001).setImage('star-icon-enable.png') if star >= 1.5: self.getControl(1002).setImage('half-star-icon-enable.png') if star >= 1: self.getControl(1002).setImage('star-icon-enable.png') if star >= 2.5: self.getControl(1003).setImage('half-star-icon-enable.png') if star >= 3: self.getControl(1003).setImage('star-icon-enable.png') if star >= 3.5: self.getControl(1004).setImage('half-star-icon-enable.png') if star >= 4: self.getControl(1004).setImage('star-icon-enable.png') if star >=4.5: self.getControl(1005).setImage('half-star-icon-enable.png') if star >= 5: self.getControl(1005).setImage('star-icon-enable.png') if star >= 5.5: self.getControl(1006).setImage('half-star-icon-enable.png') if star >= 6: self.getControl(1006).setImage('star-icon-enable.png') if star >= 6.5: self.getControl(1007).setImage('half-star-icon-enable.png') if star >= 7: self.getControl(1007).setImage('star-icon-enable.png') if star >= 7.5: self.getControl(1008).setImage('half-star-icon-enable.png') if star >= 8: self.getControl(1008).setImage('star-icon-enable.png') if star >= 8.5: self.getControl(1009).setImage('half-star-icon-enable.png') if star >= 9: self.getControl(1009).setImage('star-icon-enable.png') if star >= 9.5: self.getControl(1010).setImage('half-star-icon-enable.png') if star >= 10: self.getControl(1010).setImage('star-icon-enable.png')