예제 #1
0
    def onContextMenu( self, controlID, listItem ):
        listItem.select( 1 )
        try:
            buttons = []
            selected = -1
            if controlID == self.CONTAINER_MOVIESETS_ID:
                buttons += [ Language( 32100 ), Language( 32221 ), LangXBMC( 646 ), Language( 32330 ),
                             Language( 32120 ), Language( 32130 ) ]

            elif controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                buttons += [ Language( 32100 ), Language( 32220 ), Language( 32110 ), Language( 32330 ) ]

            on_all_movies = self.container_all_movies.size()
            if buttons:
                if on_all_movies: del buttons[ 0 ]
                cm = DialogContextMenu( "script-MovieSets-ContextMenu.xml", ADDON_DIR, buttons=buttons )
                selected = cm.selected
                del cm
                heading = buttons[ selected ]
                if selected >= 0 and on_all_movies:
                    selected += 1

            if selected == 0:
                # Add Container for All Movies
                self.setContainerAllMovies( listItem.getProperty( "idSet" ) )

            elif selected == 1:
                # Edit Set title or Edit movie sorttitle
                title = ""
                if controlID == self.CONTAINER_MOVIESETS_ID:
                    title = listItem.getLabel()
                elif controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                    title = listItem.getLabel2()

                new_title = self.keyboard( title, heading )
                if new_title and new_title != title:
                    if xbmcgui.Dialog().yesno( heading, "Old: %s" % _unicode( title ), "New: %s" % _unicode( new_title ), "", LangXBMC( 222 ), LangXBMC( 186 ) ):
                        if controlID == self.CONTAINER_MOVIESETS_ID:
                            idSet = listItem.getProperty( "idSet" )
                            OK = DATABASE.editMovieSetTitle( new_title, idSet )
                            if OK:
                                # don't reload containers, set label only :)
                                listItem.setLabel( new_title )

                        if controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                            idMovie = listItem.getProperty( "idMovie" )
                            OK = DATABASE.editMovieSortTitle( new_title, idMovie )
                            if OK:
                                idSet = listItem.getProperty( "idSet" )
                                self.moviesets[ str( idSet ) ] = self.getMoviesInSet( idSet )
                                self.setContainerMoviesInSet( self.moviesets[ str( idSet ) ], idMovie )

            elif selected == 2:
                # Remove current movieset
                if controlID == self.CONTAINER_MOVIESETS_ID:
                    strSet = listItem.getLabel()
                    if xbmcgui.Dialog().yesno( Language( 32141 ), LangXBMC( 433 ) % _unicode( strSet ) ):
                        idSet = listItem.getProperty( "idSet" )
                        OK = DATABASE.deleteSet( idSet )
                        if OK:
                            self.setContainers( "0" )

                # Remove movie to current movieset
                if controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                    strTitle = listItem.getLabel()
                    strSet   = self.container_moviesets.getSelectedItem().getLabel()
                    if xbmcgui.Dialog().yesno( Language( 32112 ), LangXBMC( 750 ), Language( 32113 ) % _unicode( strTitle ), Language( 32114 ) % _unicode( strSet ) ):
                        idSet   = listItem.getProperty( "idSet" )
                        idMovie = listItem.getProperty( "idMovie" )
                        OK = DATABASE.deleteMovieOfSet( idMovie, idSet )
                        if OK:
                            self.moviesets[ str( idSet ) ] = self.getMoviesInSet( idSet )
                            self.setContainerMoviesInSet( self.moviesets[ str( idSet ) ], "0" )

            elif selected == 3:
                # Create new movieset
                self.createNewSet()

            elif selected in [ 4, 5 ]:
                # Set movieset fanart or Set movieset thumb
                listItem.setIconImage( "" )
                listItem.setProperty( "fanart_image", "" )
                xbmc.sleep( 500 )
                #time.sleep( .5 )
                from dialogs import browser
                self.movieset_update = browser( notaction=True,
                    heading=listItem.getLabel(),
                    idset=listItem.getProperty( "idSet" ),
                    type=( "fanart", "thumb" )[ selected - 4 ]
                    )
                del browser
                self.setIconFanartImages( listItem.getProperty( "idSet" ), listItem )
        except:
            LOGGER.error.exc_info( sys.exc_info(), self )
        try: listItem.select( 0 )
        except: pass
예제 #2
0
    def onClick( self, controlID ):
        try:
            if controlID == 250:
                icon = xbmc.getInfoLabel( "Container(250).ListItem.Icon" )
                w, h = xbmc.getInfoLabel( "Container(250).ListItem.Label" ).split( "x" )
                choices = [ self.getLabelImageSize( w, h, to ) for to in self.config[ "profile_sizes" ][ ::-1 ] ] + [ LangXBMC( 21452 ), LangXBMC( 222 ) ]
                selected = xbmcgui.Dialog().select( Language( 32040 ), choices )
                if selected > -1:
                    if choices[ selected ] == LangXBMC( 21452 ):
                        #browse thumb
                        if dialogs.browser( search_name=self.actor_search, type="thumb" ):
                            globals().update( { "CONTAINER_REFRESH": True } )
                            self.setContainer()

                    elif choices[ selected ] != LangXBMC( 222 ):
                        icon = icon.split( "/" )
                        icon[ icon.index( self.config[ "profile_sizes" ][ 2 ] ) ] = self.config[ "profile_sizes" ][ ::-1 ][ selected ]
                        new_icon = tmdbAPI.download( "/".join( icon ), xbmc.translatePath( "special://temp" ) )
                        ok = False
                        if new_icon:
                            ok = self.copyThumb( new_icon, force=True )
                            if not ok:
                                import shutil
                                try: shutil.copy( new_icon, xbmc.translatePath( "".join( TBN.get_thumb( self.actor[ "name" ] ) ) ) )
                                except: pass
                                else: ok = True
                                del shutil
                        if ok:
                            self.tbn_added = False
                            msg = Language( 32041 )
                            globals().update( { "CONTAINER_REFRESH": True } )
                        else:
                            msg = Language( 32042 )
                        xbmcgui.Dialog().ok( xbmc.getInfoLabel( "ListItem.Title" ), msg )

            elif controlID == 150:
                listitem = self.getControl( 150 ).getSelectedItem()
                movie_id = listitem.getProperty( "id" )
                if not movie_id: return
                LibraryHasMovie = listitem.getProperty( "LibraryHasMovie" ) == "1"
                HasMovieJson = xbmcvfs.exists( ADDON.getAddonInfo( "profile" ) + "movies/%s.json" % movie_id )

                listitem.select( 1 )
                buttons = []
                if LibraryHasMovie:
                    buttons.append( LangXBMC( 208 ) )
                if HasMovieJson:
                    buttons.append( Language( 32051 ) )
                buttons += [ LangXBMC( 13346 ), Language( 32050 ) ]

                # show context menu
                selected = dialogs.contextmenu( buttons )
                listitem.select( 0 )

                if selected == 0 and LibraryHasMovie:
                    file = listitem.getProperty( "file" )
                    if file: xbmc.executebuiltin( "PlayMedia(%s)" % file )
                    return

                if LibraryHasMovie:
                    selected -= 1

                if not HasMovieJson:
                    selected += 1

                if selected == 0 and HasMovieJson:
                    # get trailers from movie cache
                    trailers = tmdbAPI.load_movie_info( movie_id ).get( "trailers" ) or [{}]
                    trailers = trailers[ 0 ].get( "youtube" )
                    if trailers:
                        selected = -1
                        if len( trailers ) == 1: selected = 0
                        else: selected = xbmcgui.Dialog().select( "%s [%s]" % ( Language( 32051 ), lang.upper() ), [ "%s (%s)" % ( trailer[ "name" ], trailer[ "size" ] ) for trailer in trailers ] )
                        if selected > -1:
                            url = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailers[ selected ][ "source" ]
                            self._close_dialog()
                            xbmc.executebuiltin( "ClearProperty(script.metadata.actors.isactive)" )
                            xbmc.executebuiltin( 'Dialog.Close(all,true)' )
                            xbmc.Player().play( url, listitem )
                    else:
                        #no trailers found
                        metautils.notification( listitem.getLabel(), Language( 32052 ).encode( "utf-8" ) )

                elif selected == 1:
                    self.movie_info()

                elif selected == 2:
                    import webbrowser
                    url = "http://www.themoviedb.org/movie/%s?language=%s" % ( movie_id, ADDON.getSetting( "language" ).lower() )
                    webbrowser.open( url )
                    del webbrowser

            elif self.button_filmo_bio and controlID == 5:
                # toggle button Filmography/Biography
                if self.button_filmo_bio.getLabel() == LangXBMC( 21887 ):
                    label, visible = Language( 32010 ), 0
                else:
                    label, visible = LangXBMC( 21887 ), 1
                self.button_filmo_bio.setLabel( label )
                self.getControl( 150 ).setVisible( visible )

            elif controlID == 6:
                # refresh button
                actor = dialogs.select( self, True )
                if actor:
                    self.actor = actor
                    self.setContainer( True )

            elif controlID == 8:
                # show user movies acting, tvshows acting, movies directing, discography
                if self.videodb:
                    if len( self.videodb ) == 1:
                        selected = 0
                    else:
                        selected = xbmcgui.Dialog().select( self.actor[ "name" ], [ i[ 0 ] for i in self.videodb ] )

                    if selected > -1:
                        path_db = self.videodb[ selected ][ 1 ]
                        if metautils.LIBRARY_TYPE:
                            command = "Container.Update(%s,replace)" % path_db
                        else:
                            window = ( "Videos", "MusicLibrary" ) [ "musicdb" in path_db ]
                            command = "ActivateWindow(%s,%s,return)" % ( window, path_db )
                        if xbmc.getCondVisibility( "Window.IsVisible(12003)" ):
                            xbmc.executebuiltin( 'Dialog.Close(12003,true)' )
                        self._close_dialog()
                        xbmc.executebuiltin( command )

            elif controlID == 11:
                #  edit profile from site
                if xbmcgui.Dialog().yesno( "themoviedb.org", Language( 32035 ), Language( 32036 ), "", LangXBMC( 222 ), LangXBMC( 21435 ).strip( "- " ) ):
                    import webbrowser
                    webbrowser.open( "http://www.themoviedb.org/person/%i" % self.actor[ "id" ] )
                    del webbrowser

            elif controlID in [ 10, 20 ]:
                #browse fanart or thumb
                type = ( "thumb", "fanart" )[ controlID == 20 ]
                if type == "thumb" and self.getControl( 250 ).size():
                    self.setFocusId( 250 )

                elif dialogs.browser( search_name=self.actor_search, type=type ):
                    globals().update( { "CONTAINER_REFRESH": True } )
                    self.setContainer()

            elif controlID == 25:
                globals().update( { "PARENT_DIR": Stack( 0 ) } )
                # show addon settings
                self._close_dialog()
                ADDON.openSettings()
                from sys import argv
                xbmc.executebuiltin( 'RunScript(%s)' % ",".join( argv ) )
        except:
            print_exc()
예제 #3
0
 def browse( self, type ):
     from dialogs import browser
     self.movieset_update = browser( heading=self.heading, idset=self.idSet, type=type )#self.movieset_update or w.movieset_update
     xbmc.sleep( 100 )
     xbmc.executebuiltin( "Action(ParentDir)" )
     del browser
예제 #4
0
    def onContextMenu(self, controlID, listItem):
        listItem.select(1)
        try:
            buttons = []
            selected = -1
            if controlID == self.CONTAINER_MOVIESETS_ID:
                buttons += [
                    Language(32100),
                    Language(32221),
                    LangXBMC(646),
                    Language(32330),
                    Language(32120),
                    Language(32130)
                ]

            elif controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                buttons += [
                    Language(32100),
                    Language(32220),
                    Language(32110),
                    Language(32330)
                ]

            on_all_movies = self.container_all_movies.size()
            if buttons:
                if on_all_movies: del buttons[0]
                cm = DialogContextMenu("script-MovieSets-ContextMenu.xml",
                                       ADDON_DIR,
                                       buttons=buttons)
                selected = cm.selected
                del cm
                heading = buttons[selected]
                if selected >= 0 and on_all_movies:
                    selected += 1

            if selected == 0:
                # Add Container for All Movies
                self.setContainerAllMovies(listItem.getProperty("idSet"))

            elif selected == 1:
                # Edit Set title or Edit movie sorttitle
                title = ""
                if controlID == self.CONTAINER_MOVIESETS_ID:
                    title = listItem.getLabel()
                elif controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                    title = listItem.getLabel2()

                new_title = self.keyboard(title, heading)
                if new_title and new_title != title:
                    if xbmcgui.Dialog().yesno(heading,
                                              "Old: %s" % _unicode(title),
                                              "New: %s" % _unicode(new_title),
                                              "", LangXBMC(222),
                                              LangXBMC(186)):
                        if controlID == self.CONTAINER_MOVIESETS_ID:
                            idSet = listItem.getProperty("idSet")
                            OK = DATABASE.editMovieSetTitle(new_title, idSet)
                            if OK:
                                # don't reload containers, set label only :)
                                listItem.setLabel(new_title)

                        if controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                            idMovie = listItem.getProperty("idMovie")
                            OK = DATABASE.editMovieSortTitle(
                                new_title, idMovie)
                            if OK:
                                idSet = listItem.getProperty("idSet")
                                self.moviesets[str(
                                    idSet)] = self.getMoviesInSet(idSet)
                                self.setContainerMoviesInSet(
                                    self.moviesets[str(idSet)], idMovie)

            elif selected == 2:
                # Remove current movieset
                if controlID == self.CONTAINER_MOVIESETS_ID:
                    strSet = listItem.getLabel()
                    if xbmcgui.Dialog().yesno(Language(32141),
                                              LangXBMC(433) %
                                              _unicode(strSet)):
                        idSet = listItem.getProperty("idSet")
                        OK = DATABASE.deleteSet(idSet)
                        if OK:
                            self.setContainers("0")

                # Remove movie to current movieset
                if controlID == self.CONTAINER_MOVIES_IN_SET_ID:
                    strTitle = listItem.getLabel()
                    strSet = self.container_moviesets.getSelectedItem(
                    ).getLabel()
                    if xbmcgui.Dialog().yesno(
                            Language(32112), LangXBMC(750),
                            Language(32113) % _unicode(strTitle),
                            Language(32114) % _unicode(strSet)):
                        idSet = listItem.getProperty("idSet")
                        idMovie = listItem.getProperty("idMovie")
                        OK = DATABASE.deleteMovieOfSet(idMovie, idSet)
                        if OK:
                            self.moviesets[str(idSet)] = self.getMoviesInSet(
                                idSet)
                            self.setContainerMoviesInSet(
                                self.moviesets[str(idSet)], "0")

            elif selected == 3:
                # Create new movieset
                self.createNewSet()

            elif selected in [4, 5]:
                # Set movieset fanart or Set movieset thumb
                listItem.setIconImage("")
                listItem.setProperty("fanart_image", "")
                xbmc.sleep(500)
                #time.sleep( .5 )
                from dialogs import browser
                self.movieset_update = browser(
                    notaction=True,
                    heading=listItem.getLabel(),
                    idset=listItem.getProperty("idSet"),
                    type=("fanart", "thumb")[selected - 4])
                del browser
                self.setIconFanartImages(listItem.getProperty("idSet"),
                                         listItem)
        except:
            LOGGER.error.exc_info(sys.exc_info(), self)
        try:
            listItem.select(0)
        except:
            pass
예제 #5
0
    def onClick(self, controlID):
        try:
            if controlID == 250:
                icon = xbmc.getInfoLabel("Container(250).ListItem.Icon")
                w, h = xbmc.getInfoLabel(
                    "Container(250).ListItem.Label").split("x")
                choices = [
                    self.getLabelImageSize(w, h, to)
                    for to in self.config["profile_sizes"][::-1]
                ] + [LangXBMC(21452), LangXBMC(222)]
                selected = xbmcgui.Dialog().select(Language(32040), choices)
                if selected > -1:
                    if choices[selected] == LangXBMC(21452):
                        #browse thumb
                        if dialogs.browser(search_name=self.actor_search,
                                           type="thumb"):
                            globals().update({"CONTAINER_REFRESH": True})
                            self.setContainer()

                    elif choices[selected] != LangXBMC(222):
                        icon = icon.split("/")
                        icon[icon.index(
                            self.config["profile_sizes"][2]
                        )] = self.config["profile_sizes"][::-1][selected]
                        new_icon = tmdbAPI.download(
                            "/".join(icon),
                            xbmc.translatePath("special://temp"))
                        ok = False
                        if new_icon:
                            ok = self.copyThumb(new_icon, force=True)
                            if not ok:
                                import shutil
                                try:
                                    shutil.copy(
                                        new_icon,
                                        xbmc.translatePath("".join(
                                            TBN.get_thumb(
                                                self.actor["name"]))))
                                except:
                                    pass
                                else:
                                    ok = True
                                del shutil
                        if ok:
                            self.tbn_added = False
                            msg = Language(32041)
                            globals().update({"CONTAINER_REFRESH": True})
                        else:
                            msg = Language(32042)
                        xbmcgui.Dialog().ok(
                            xbmc.getInfoLabel("ListItem.Title"), msg)

            elif controlID == 150:
                listitem = self.getControl(150).getSelectedItem()
                movie_id = listitem.getProperty("id")
                if not movie_id: return
                LibraryHasMovie = listitem.getProperty(
                    "LibraryHasMovie") == "1"
                HasMovieJson = xbmcvfs.exists(
                    ADDON.getAddonInfo("profile") +
                    "movies/%s.json" % movie_id)

                listitem.select(1)
                buttons = []
                if LibraryHasMovie:
                    buttons.append(LangXBMC(208))
                if HasMovieJson:
                    buttons.append(Language(32051))
                buttons += [LangXBMC(13346), Language(32050)]

                # show context menu
                selected = dialogs.contextmenu(buttons)
                listitem.select(0)

                if selected == 0 and LibraryHasMovie:
                    file = listitem.getProperty("file")
                    if file: xbmc.executebuiltin("PlayMedia(%s)" % file)
                    return

                if LibraryHasMovie:
                    selected -= 1

                if not HasMovieJson:
                    selected += 1

                if selected == 0 and HasMovieJson:
                    # get trailers from movie cache
                    trailers = tmdbAPI.load_movie_info(movie_id).get(
                        "trailers") or [{}]
                    trailers = trailers[0].get("youtube")
                    if trailers:
                        selected = -1
                        if len(trailers) == 1: selected = 0
                        else:
                            selected = xbmcgui.Dialog().select(
                                "%s [%s]" % (Language(32051), lang.upper()), [
                                    "%s (%s)" %
                                    (trailer["name"], trailer["size"])
                                    for trailer in trailers
                                ])
                        if selected > -1:
                            url = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailers[
                                selected]["source"]
                            self._close_dialog()
                            xbmc.executebuiltin(
                                "ClearProperty(script.metadata.actors.isactive)"
                            )
                            xbmc.executebuiltin('Dialog.Close(all,true)')
                            xbmc.Player().play(url, listitem)
                    else:
                        #no trailers found
                        metautils.notification(listitem.getLabel(),
                                               Language(32052).encode("utf-8"))

                elif selected == 1:
                    self.movie_info()

                elif selected == 2:
                    import webbrowser
                    url = "http://www.themoviedb.org/movie/%s?language=%s" % (
                        movie_id, ADDON.getSetting("language").lower())
                    webbrowser.open(url)
                    del webbrowser

            elif self.button_filmo_bio and controlID == 5:
                # toggle button Filmography/Biography
                if self.button_filmo_bio.getLabel() == LangXBMC(21887):
                    label, visible = Language(32010), 0
                else:
                    label, visible = LangXBMC(21887), 1
                self.button_filmo_bio.setLabel(label)
                self.getControl(150).setVisible(visible)

            elif controlID == 6:
                # refresh button
                actor = dialogs.select(self, True)
                if actor:
                    self.actor = actor
                    self.setContainer(True)

            elif controlID == 8:
                # show user movies acting, tvshows acting, movies directing, discography
                if self.videodb:
                    if len(self.videodb) == 1:
                        selected = 0
                    else:
                        selected = xbmcgui.Dialog().select(
                            self.actor["name"], [i[0] for i in self.videodb])

                    if selected > -1:
                        path_db = self.videodb[selected][1]
                        if metautils.LIBRARY_TYPE:
                            command = "Container.Update(%s,replace)" % path_db
                        else:
                            window = ("Videos",
                                      "MusicLibrary")["musicdb" in path_db]
                            command = "ActivateWindow(%s,%s,return)" % (
                                window, path_db)
                        if xbmc.getCondVisibility("Window.IsVisible(12003)"):
                            xbmc.executebuiltin('Dialog.Close(12003,true)')
                        self._close_dialog()
                        xbmc.executebuiltin(command)

            elif controlID == 11:
                #  edit profile from site
                if xbmcgui.Dialog().yesno("themoviedb.org", Language(32035),
                                          Language(32036), "", LangXBMC(222),
                                          LangXBMC(21435).strip("- ")):
                    import webbrowser
                    webbrowser.open("http://www.themoviedb.org/person/%i" %
                                    self.actor["id"])
                    del webbrowser

            elif controlID in [10, 20]:
                #browse fanart or thumb
                type = ("thumb", "fanart")[controlID == 20]
                if type == "thumb" and self.getControl(250).size():
                    self.setFocusId(250)

                elif dialogs.browser(search_name=self.actor_search, type=type):
                    globals().update({"CONTAINER_REFRESH": True})
                    self.setContainer()

            elif controlID == 25:
                globals().update({"PARENT_DIR": Stack(0)})
                # show addon settings
                self._close_dialog()
                ADDON.openSettings()
                from sys import argv
                xbmc.executebuiltin('RunScript(%s)' % ",".join(argv))
        except:
            print_exc()