def onInit(self): global list_count if self.mode=='trailer': self.getControl(1).setLabel('[B]Trailers[/B]') for trailer in self.curr_movie['trailers']['youtube']: li=xbmcgui.ListItem(trailer['name']) li.setProperty('url','plugin://plugin.video.youtube/?action=play_video&videoid='+trailer['source']) self.getControl(300).addItem(li) elif self.mode=='keyword': self.getControl(1).setLabel('[B]Serch for Movies by Keywords[/B]') for keyword in self.curr_movie['keywords']['keywords']: li=xbmcgui.ListItem(keyword['name']) li.setProperty('id',str(keyword['id'])) self.getControl(300).addItem(li) elif self.mode=='genre': self.getControl(1).setLabel('[B]Search for Movies by Genre[/B]') for genre in self.curr_movie['genres']: li=xbmcgui.ListItem(genre['name']) li.setProperty('id',str(genre['id'])) self.getControl(300).addItem(li) elif self.mode=='list': list_count=0 self.getControl(1).setLabel('[B]Add Movie to Lists[/B]') lists=tmdb.get_users_lists(addon.getSetting('session_id'),1) lists_results=lists['results'] for list in lists_results: li=xbmcgui.ListItem(list['name'] +' ('+ str(list['item_count'])+')') li.setProperty('id',str(list['id'])) li.setProperty('name',list['name']) if tmdb.is_in_list(list['id'],self.curr_movie['id'])['item_present']: list_count=list_count+1 li.setIconImage('film-icon.png') li.setProperty('in_list','true') else: li.setIconImage('film-icon-disable.png') li.setProperty('in_list','false') self.getControl(300).addItem(li) if lists['total_pages']> 1: for i in range(2,lists['total_pages']): l=tmdb.get_users_lists(addon.getSetting('session_id'),i) for list in l['results']: li=xbmcgui.ListItem(list['name'] +' ('+ str(list['item_count'])+')') li.setProperty('id',str(list['id'])) li.setProperty('name',list['name']) if tmdb.is_in_list(list['id'],self.curr_movie['id'])['item_present']: list_count=list_count+1 li.setIconImage('film-icon.png') li.setProperty('in_list','true') else: li.setIconImage('film-icon-disable.png') li.setProperty('in_list','false') self.getControl(300).addItem(li) self.setFocus(self.getControl(300))
def movie_on_list(movie_id,session_id): lists=tmdb.get_users_lists(addon.getSetting('session_id'),1) lists_results=lists['results'] in_list='' for list in lists_results: if tmdb.is_in_list(list['id'],movie_id)['item_present']: in_list=True break if lists['total_pages']> 1 and not in_list: for i in range(2,lists['total_pages']): l=tmdb.get_users_lists(addon.getSetting('session_id'),i) for list in l['results']: if tmdb.is_in_list(list['id'],movie_id)['item_present']: in_list=True break return in_list
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')
def onInit(self): global person_name if self.mode == "genre": self.getControl(1).setLabel("[B]Search for Movies by Genre[/B]") for genre in tmdb.get_genres(): li = xbmcgui.ListItem(genre["name"]) li.setProperty("id", str(genre["id"])) self.getControl(300).addItem(li) if self.mode == "people": self.getControl(1).setLabel("[B]Select Person[/B]") for person in tmdb.search_people(person_name, 1)["results"]: li = xbmcgui.ListItem(person["name"]) li.setProperty("id", str(person["id"])) if person["profile_path"] == None: li.setIconImage("no-profile-w92.jpg") else: li.setIconImage("http://image.tmdb.org/t/p/w45" + person["profile_path"]) self.getControl(300).addItem(li) if self.mode == "list": li = xbmcgui.ListItem("Add New") li.setProperty("id", "") self.getControl(300).addItem(li) self.getControl(1).setLabel("[B]Your Movie Lists[/B]") lists = tmdb.get_users_lists(addon.getSetting("session_id"), 1) lists_results = lists["results"] for list in lists_results: li = xbmcgui.ListItem(list["name"] + " (" + str(list["item_count"]) + ")") li.setProperty("id", str(list["id"])) self.getControl(300).addItem(li) if lists["total_pages"] > 1: for i in range(2, lists["total_pages"]): l = tmdb.get_users_lists(addon.getSetting("session_id"), i) for list in l["results"]: li = xbmcgui.ListItem(list["name"] + " (" + str(list["item_count"]) + ")") li.setProperty("id", str(list["id"])) self.getControl(300).addItem(li) if self.mode == "context_list": list_count = 0 self.getControl(1).setLabel("[B]Add/Remove Movie from Lists[/B]") lists = tmdb.get_users_lists(addon.getSetting("session_id"), 1) lists_results = lists["results"] for list in lists_results: li = xbmcgui.ListItem(list["name"] + " (" + str(list["item_count"]) + ")") li.setProperty("id", str(list["id"])) li.setProperty("name", list["name"]) if tmdb.is_in_list(list["id"], self.curr_movie["id"])["item_present"]: list_count = list_count + 1 li.setIconImage("film-icon.png") li.setProperty("in_list", "true") else: li.setIconImage("film-icon-disable.png") li.setProperty("in_list", "false") self.getControl(300).addItem(li) if lists["total_pages"] > 1: for i in range(2, lists["total_pages"]): l = tmdb.get_users_lists(addon.getSetting("session_id"), i) for list in l["results"]: li = xbmcgui.ListItem(list["name"] + " (" + str(list["item_count"]) + ")") li.setProperty("id", str(list["id"])) li.setProperty("name", list["name"]) if tmdb.is_in_list(list["id"], self.curr_movie["id"])["item_present"]: list_count = list_count + 1 li.setIconImage("film-icon.png") li.setProperty("in_list", "true") else: li.setIconImage("film-icon-disable.png") li.setProperty("in_list", "false") self.getControl(300).addItem(li) self.setFocus(self.getControl(300))