コード例 #1
0
ファイル: windows.py プロジェクト: lordcapulet/script.traktr
    def showContextMenu(self):
        movie = self.movies[self.getControl(MOVIE_LIST).getSelectedPosition()]
        li = self.getControl(MOVIE_LIST).getSelectedItem()
        options = []
        actions = []
        if movie['idMovie'] != -1:
            options.append("Play")
            actions.append('play')
        if self.type != 'watchlist':
            if 'watchlist' in movie:
                if movie['watchlist']:
                    options.append(__language__(137).encode( "utf-8", "ignore" ))
                    actions.append('unwatchlist')
                else:
                    options.append(__language__(136).encode( "utf-8", "ignore" ))
                    actions.append('watchlist')
        else:
            options.append(__language__(137).encode( "utf-8", "ignore" ))
            actions.append('unwatchlist')
        options.append(__language__(138).encode( "utf-8", "ignore" ))
        actions.append('rate')

        select = xbmcgui.Dialog().select(movie['title']+" - "+str(movie['year']), options)
        if select != -1:
            Debug("Select: " + actions[select])
        if select == -1:
            Debug ("menu quit by user")
            return
        elif actions[select] == 'play':
            utilities.playMovieById(movie['idMovie'])
        elif actions[select] == 'unwatchlist':
            if utilities.removeMoviesFromWatchlist([movie]) == None:
                utilities.notification(__language__(200).encode( "utf-8", "ignore" ), __language__(132).encode( "utf-8", "ignore" )) # Failed to remove from watch-list
            else:
                utilities.notification(__language__(200).encode( "utf-8", "ignore" ), __language__(133).encode( "utf-8", "ignore" )) # Successfully removed from watch-list
                li.setProperty('Watchlist','false')
                movie['watchlist'] = False
        elif actions[select] == 'watchlist':
            if utilities.addMoviesToWatchlist([movie]) == None:
                utilities.notification(__language__(200).encode( "utf-8", "ignore" ), __language__(130).encode( "utf-8", "ignore" )) # Failed to added to watch-list
            else:
                utilities.notification(__language__(200).encode( "utf-8", "ignore" ), __language__(131).encode( "utf-8", "ignore" )) # Successfully added to watch-list
                li.setProperty('Watchlist','true')
                movie['watchlist'] = True
        elif actions[select] == 'rate':
            rating.rate_movie(imdbid=movie['imdb_id'], title=movie['title'], year=movie['year'])
コード例 #2
0
ファイル: windows.py プロジェクト: lordcapulet/script.traktr
 def onAction(self, action):
     if action.getId() == 0:
         return
     if action.getId() in (ACTION_PARENT_DIRECTORY, ACTION_PREVIOUS_MENU):
         Debug("Closing MoviesWindow")
         self.close()
     elif action.getId() in (1, 2, 107):
         self.listUpdate()
     elif action.getId() == ACTION_SELECT_ITEM:
         movie = self.movies[self.getControl(MOVIE_LIST).getSelectedPosition()]
         if movie['idMovie'] == -1: # Error
             xbmcgui.Dialog().ok(__language__(200).encode( "utf-8", "ignore" ), movie['title'].encode( "utf-8", "ignore" ) + " " + __language__(150).encode( "utf-8", "ignore" )) # "moviename" not found in your XBMC Library
         else:
             utilities.playMovieById(movie['idMovie'])
     elif action.getId() == ACTION_CONTEXT_MENU:
         self.showContextMenu()
     else:
         Debug("Uncaught action (movies): "+str(action.getId()))