def getMovieInfo( self, refresh=False ): try: if self.movie: self.moviethumb = self.movie[ "thumbnail" ] self.moviefanart = self.movie[ "fanart" ] self.library = False self.online_info = "http://www.themoviedb.org/movie/%s?language=%s" % ( self.movieid.replace( "idTMDB=", "" ), ADDON.getSetting( "language" ).lower() ) elif "idTMDB" in self.movieid: self.allow_refresh = True movieid = self.movieid.replace( "idTMDB=", "" ) self.movie = tmdbAPI.load_movie_info( movieid ) if refresh or not self.movie: xbmc.executebuiltin( 'ActivateWindow(busydialog)' ) js, lang = tmdbAPI.get_movie( movieid, ADDON.getSetting( "language" ).lower() ) self.movie = tmdbAPI.save_movie_info( js ) xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' ) self.moviethumb = self.movie[ "thumbnail" ] self.moviefanart = self.movie[ "fanart" ] self.library = False self.online_info = "http://www.themoviedb.org/movie/%s?language=%s" % ( movieid, ADDON.getSetting( "language" ).lower() ) else: self.movie = metautils.get_library_movie_details( self.movieid ) self.moviefanart = self.movie[ "art" ].get( "fanart", "" ) self.moviethumb = self.movie[ "art" ].get( "poster", "" ) if self.moviethumb == "": self.moviethumb = self.movie[ "art" ].get( "thumb", "" ) self.online_info = "" self.library = True #print self.movie #s_json = metautils.json.dumps( details, sort_keys=True, indent=2 ) except: xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' ) print_exc() raise
def load_movie_info( self, mid ): movie = False try: movieid = mid.replace( "idTMDB=", "" ) movie = tmdbAPI.load_movie_info( movieid ) if not movie: xbmc.executebuiltin( 'ActivateWindow(busydialog)' ) js, lang = tmdbAPI.get_movie( movieid, ADDON.getSetting( "language" ).lower() ) movie = tmdbAPI.save_movie_info( js ) xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' ) except: xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' ) print_exc() raise return movie
def getMovieInfo(self, refresh=False): try: if "idTMDB" in self.movieid: self.allow_refresh = True movieid = self.movieid.replace("idTMDB=", "") self.movie = tmdbAPI.load_movie_info(movieid) if refresh or not self.movie: xbmc.executebuiltin('ActivateWindow(busydialog)') js, lang = tmdbAPI.get_movie( movieid, ADDON.getSetting("language").lower()) self.movie = tmdbAPI.save_movie_info(js) xbmc.executebuiltin('Dialog.Close(busydialog,true)') self.online_info = "http://www.themoviedb.org/movie/%s?language=%s" % ( movieid, ADDON.getSetting("language").lower()) else: self.movie = metautils.get_library_movie_details(self.movieid) self.online_info = "" #print self.movie #s_json = metautils.json.dumps( details, sort_keys=True, indent=2 ) except: xbmc.executebuiltin('Dialog.Close(busydialog,true)') print_exc() raise
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 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()