Example #1
0
def remove_favorite(movie_id,session_id):
    movie=tmdb.get_movie(movie_id)
    res=tmdb.update_favorite_movie(movie_id,session_id)
    if res['success']:
        dg=xbmcgui.Dialog()
        dg.notification('themoviedb.org Browser','Successfully Removed '+ movie['title'] + ' from Favorites',xbmcgui.NOTIFICATION_INFO,5000)
    else:
        dg=xbmcgui.Dialog()
        dg.notification('themoviedb.org Browser','Error Removing '+ movie['title'] + ' from Favorites',xbmcgui.NOTIFICATION_ERROR,5000)
Example #2
0
    def onClick(self,control):
        xbmc.log('you clicked '+ str(control))
        global movie_id
        global movie
        global cast_member
        global cast_member_id
        global genre_id
        global current_genre
        global keyword_id
        global current_keyword
        global list_id
        global list_name
        global in_list
        global list_count
        if control in(200,201,202,203,204,205,206,207,208,209):
            if self.mode=='similar':
                movie_id=self.similar[control-200]['id']
                startup()  
            elif self.mode=='cast':
                from resources.lib import person
                person.person_id=self.cast[control-200]['id']
                person.startup()
               
            elif self.mode=='keywords':
               movie_id=self.keywords[control-200]['id']
               startup()  
            elif self.mode=='genre':  
                movie_id=self.genres[control-200]['id']
                startup()
            elif self.mode=='cast_movies':
                movie_id=self.cast_movies[control-200]['id']
                startup()

        if control in (50,51,52,4000):
            dg = dialogWindow('dialog_select.xml',addon_path,'default')
            dg.curr_movie=self.current_movie
            if control==50:dg.mode='trailer'
            if control==51:dg.mode='keyword'
            if control==52:dg.mode='genre'
            if control==4000: #List
                dg.mode='list'
                if self.session_id=='':
                    session_id=utils.get_login()
                    if session_id!='':self.session_id=session_id
            if self.session_id!='' or control in(50,51,52):
                dg.doModal()
            if control==4000:
                if list_id!='':
                    if in_list=='true':
                        res=tmdb.remove_from_list(list_id,self.current_movie['id'],addon.getSetting('session_id'))
                        if res:
                            list_count=list_count-1
                            dialog = xbmcgui.Dialog()
                            dialog.notification('themoviedb.org Browser', 'Successfully Removed ' + self.current_movie['title'] + ' from '+ list_name, xbmcgui.NOTIFICATION_INFO, 5000)
                            if list_count<=0:self.getControl(4010).setImage('film-icon-disable.png')
                        else:
                            dialog = xbmcgui.Dialog()
                            dialog.notification('themoviedb.org Browser', 'Failed to Remove ' + self.current_movie['title'] + ' from ' + list_name, xbmcgui.NOTIFICATION_ERROR, 5000)
                    else:
                        res=tmdb.add_to_list(list_id,self.current_movie['id'],addon.getSetting('session_id'))
                        if res:
                            dialog = xbmcgui.Dialog()
                            dialog.notification('themoviedb.org Browser', 'Successfully Added ' + self.current_movie['title'] + ' to '+ list_name, xbmcgui.NOTIFICATION_INFO, 5000)
                            self.getControl(4010).setImage('film-icon.png')
                        else:
                            dialog = xbmcgui.Dialog()
                            dialog.notification('themoviedb.org Browser', 'Failed to Add ' + self.current_movie['title'] + ' to ' + list_name, xbmcgui.NOTIFICATION_ERROR, 5000)
            if control==51:
                if keyword_id!='':
                    self.mode='keywords'
                    results=tmdb.getMoviesByKeyword(keyword_id,1)
                    self.keywords=results['results']
                    self.total_results=results['total_results']
                    self.show_keywords(self.keywords)
            elif control==52:
                if genre_id!='':
                    self.mode='genre'
                    results=tmdb.get_movies_by_genre(genre_id,1)
                    self.genres=results['results']
                    self.total_results=results['total_results']
                    self.show_genre(self.genres)
                                  
        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 == 122:
            self.getControl(126).setLabel('')
            self.mode='similar'
            str_similar=tmdb.get_similar_movies(self.current_movie['id'],1)
            self.similar=str_similar['results']
            self.total_results=str_similar['total_results']
            self.show_similar(self.similar)

        if control == 124:
            self.getControl(126).setLabel('')
            self.mode = 'cast'
            self.show_cast(self.cast)
                
        if control ==127:
            if self.getControl(127).getLabel()=='Play':
                xbmc.Player().play(self.file)
                xbmc.executebuiltin('Dialog.Close(all,true)')
            else:
                xbmc.executebuiltin("XBMC.RunPlugin('plugin://plugin.video.couchpotato_manager/movies/add?title='" + self.current_movie['title']+ "')'")
        if control == 405 or control == 406:
            if control==405:
                if self.background_index==0:
                    self.background_index=len(self.backgrounds)-1
                else:
                    self.background_index=self.background_index-1
            if control==406 :
                if self.background_index==len(self.backgrounds)-1:
                    self.background_index=0
                else:
                    self.background_index=self.background_index+1

            self.getControl(402).setImage('')
            self.getControl(900).setImage('')
            self.getControl(407).setLabel(str(self.background_index+1) + ' of ' + str(len(self.backgrounds)))
            self.getControl(401).setLabel('Loading')
            self.getControl(402).setImage('http://image.tmdb.org/t/p/original' +self.backgrounds[self.background_index])
            self.getControl(900).setImage('http://image.tmdb.org/t/p/original' +self.backgrounds[self.background_index])


        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==404:
            iw = imageWindow('image.xml', addon_path,'default')
            iw.images=self.backgrounds
            iw.image_index=self.background_index
            iw.doModal()
            del iw
        
        if control==132:
            rw =  ratingWindow('rating_dialog.xml',addon_path,'default')
            rw.curr_movie=self.current_movie
            rw.doModal()
            del rw
            xbmc.sleep(1000)
            states=tmdb.get_movie_account_states(self.current_movie['id'],self.session_id)
            if states['rated']:
                star=round(self.current_movie['vote_average'],2)
                self.getControl(131).setLabel(str(star)+'/10 (' + str(self.current_movie['vote_count']) + ' votes, you voted '+ str(states['rated']['value']) +')')

        if control==129: #Webpage
            url=self.current_movie['homepage']
            url=urllib.quote_plus(url)
            xbmc.Player().play('plugin://plugin.program.chrome.launcher/?url=' + url + '&mode=showSite&stopPlayback=no')

        if control==4001: #Favorite
            if self.session_id=='':
                session_id=utils.get_login()
                if session_id!='':self.session_id=session_id
            if self.session_id!='':
                res=tmdb.update_favorite_movie(self.current_movie['id'],addon.getSetting('session_id'))
                if res['success']:
                    if res['update']:
                        dialog = xbmcgui.Dialog()
                        dialog.notification('themoviedb.org Browser', 'Successfully Added ' + self.current_movie['title'] + ' to Favorites', xbmcgui.NOTIFICATION_INFO, 5000)
                        self.getControl(4011).setImage('favorite-enable.png')
                    else:
                        dialog = xbmcgui.Dialog()
                        dialog.notification('themoviedb.org Browser', 'Successfully Removed ' + self.current_movie['title'] + ' from Favorites', xbmcgui.NOTIFICATION_INFO, 5000)
                        self.getControl(4011).setImage('favorite-disable.png')
                else:
                    dialog = xbmcgui.Dialog()
                    dialog.notification('themoviedb.org Browser','Failed to Update Favorite', xbmcgui.NOTIFICATION_ERROR, 5000)
        if control==5001: #Watchlist
            if self.session_id=='':
                session_id=utils.get_login()
                if session_id!='':self.session_id=session_id
            if self.session_id!='':
                res=tmdb.update_watchlist_movie(self.current_movie['id'],addon.getSetting('session_id'))
                if res['success']:
                    if res['update']:
                        dialog = xbmcgui.Dialog()
                        dialog.notification('themoviedb.org Browser', 'Successfully Added ' + self.current_movie['title'] + ' to Watchlist', xbmcgui.NOTIFICATION_INFO, 5000)
                        self.getControl(5011).setImage('popcorn-enable.png')
                    else:
                        dialog = xbmcgui.Dialog()
                        dialog.notification('themoviedb.org Browser', 'Successfully Removed ' + self.current_movie['title'] + ' from Watchlist', xbmcgui.NOTIFICATION_INFO, 5000)
                        self.getControl(5011).setImage('popcorn-disable.png')
                else:
                    dialog = xbmcgui.Dialog()
                    dialog.notification('themoviedb.org Browser','Failed to Update Watchlist', xbmcgui.NOTIFICATION_ERROR, 5000)
        if control==5020: #Show All
            from resources.lib import movies
            if self.mode=='genre':
                movies.genre_id=genre_id
                movies.genre_name=current_genre
                movies.page=1
                movies.source='genre'
                movies.show_movies_by_genre(genre_id)             
            if self.mode=='similar':
                movies.similar_name=self.current_movie['title']
                movies.similar_id=self.current_movie['id']
                movies.page=1
                movies.source='similar'
                movies.show_similar_movies(self.current_movie['id'])
            if self.mode=='cast_movies':
                movies.person_id=cast_member_id
                movies.person_name=cast_member
                movies.page=1
                movies.source='person'
                movies.show_movies_by_person(cast_member_id)
            if self.mode=='keywords':
                movies.keyword_id=keyword_id
                movies.keyword_name=current_keyword
                movies.page=1
                movies.source='keyword'
                movies.show_movies_by_keyword(keyword_id)