def __init__( self, *args, **kwargs ): self.tbn_added = False self.multiimage_thread = None # get configuration: images path and sizes self.config = tmdbAPI.configuration() # set our person image path self.profile_path = self.config[ "base_url" ] + self.config[ "profile_sizes" ][ 2 ] # set our movie image path self.poster_path = self.config[ "base_url" ] + self.config[ "poster_sizes" ][ 2 ] self.videodb = kwargs.get( "videodb" ) # set our person name self.actor_name = kwargs.get( "actor_name" ) or "" # fix name if called from dialogvideoinfo.xml actor and role _as_ = " %s " % LangXBMC( 20347 ) try: actor, role = self.actor_name.split( _as_.encode( "utf-8" ) ) except: try: actor, role = self.actor_name.split( _as_ ) except: _as_ = metautils.re.search( "(.*?)%s(.*?)" % _as_, self.actor_name ) if _as_: actor, role = _as_.groups() else: actor, role = "", "" #xbmcgui.Dialog().ok( LangXBMC( 20347 ), actor, role ) self.actor_name = actor or self.actor_name # if not name, show keyboard self.actor_search = self.actor_name or metautils.select_actor_from_xbmc( ACTORS ) # Manque un actor_search = "manual" if self.actor_search == "manual": self.actor_search = metautils.keyboard() self.actor_search = self.actor_search # if not again name, call error if not self.actor_search: raise Exception( "No search person: Canceled..." ) # search in database con, cur = actorsdb.getConnection() if self.actor_search.isdigit(): self.actor = actorsdb.getActor( cur, idTMDB=self.actor_search ) else: self.actor = actorsdb.getActor( cur, strActor=self.actor_search ) con.close() OK = bool( self.actor ) if not OK: # if not actor, select choices self.actor = dialogs.select( self ) OK = bool( self.actor ) # if not again name, call error if not OK: raise Exception( "No search person name %r" % self.actor_search ) self.timeperimage = int( float( ADDON.getSetting( "timeperimage" ) ) )
def load_actor_info( self, name ): self.actor = False self.actor_name = name or "" # fix name if called from dialogvideoinfo.xml actor and role _as_ = " %s " % LangXBMC( 20347 ) try: actor, role = self.actor_name.split( _as_.encode( "utf-8" ) ) except: try: actor, role = self.actor_name.split( _as_ ) except: _as_ = metautils.re.search( "(.*?)%s(.*?)" % _as_, self.actor_name ) if _as_: actor, role = _as_.groups() else: actor, role = "", "" self.actor_name = actor or self.actor_name # if not name, show keyboard self.actor_search = self.actor_name or metautils.select_actor_from_xbmc( ACTORS ) if self.actor_search == "manual": self.actor_search = metautils.keyboard() self.actor_search = self.actor_search # if not again name, call error if not self.actor_search: raise Exception( "No search person: Canceled..." ) # search in database con, cur = actorsdb.getConnection() if self.actor_search.isdigit(): self.actor = actorsdb.getActor( cur, idTMDB=self.actor_search ) else: self.actor = actorsdb.getActor( cur, strActor=self.actor_search ) con.close() OK = bool( self.actor ) if not OK: # if not actor, select choices self.actor = dialogs.select( self ) OK = bool( self.actor ) # if not again name, call error if not OK: raise Exception( "No search person name %r" % self.actor_search ) return self.actor
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()
def __init__(self, *args, **kwargs): self.tbn_added = False self.multiimage_thread = None # get configuration: images path and sizes self.config = tmdbAPI.configuration() # set our person image path self.profile_path = self.config["base_url"] + self.config[ "profile_sizes"][2] # set our movie image path self.poster_path = self.config["base_url"] + self.config[ "poster_sizes"][2] self.videodb = kwargs.get("videodb") # set our person name self.actor_name = kwargs.get("actor_name") or "" # fix name if called from dialogvideoinfo.xml actor and role _as_ = " %s " % LangXBMC(20347) try: actor, role = self.actor_name.split(_as_.encode("utf-8")) except: try: actor, role = self.actor_name.split(_as_) except: _as_ = metautils.re.search("(.*?)%s(.*?)" % _as_, self.actor_name) if _as_: actor, role = _as_.groups() else: actor, role = "", "" #xbmcgui.Dialog().ok( LangXBMC( 20347 ), actor, role ) self.actor_name = actor or self.actor_name # if not name, show keyboard self.actor_search = self.actor_name or metautils.select_actor_from_xbmc( ACTORS) # Manque un actor_search = "manual" if self.actor_search == "manual": self.actor_search = metautils.keyboard() self.actor_search = self.actor_search # if not again name, call error if not self.actor_search: raise Exception("No search person: Canceled...") # search in database con, cur = actorsdb.getConnection() if self.actor_search.isdigit(): self.actor = actorsdb.getActor(cur, idTMDB=self.actor_search) else: self.actor = actorsdb.getActor(cur, strActor=self.actor_search) con.close() OK = bool(self.actor) if not OK: # if not actor, select choices self.actor = dialogs.select(self) OK = bool(self.actor) # if not again name, call error if not OK: raise Exception("No search person name %r" % self.actor_search) self.timeperimage = int(float(ADDON.getSetting("timeperimage")))
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()