def _download( self ): try: selected = [ l for l in self.listitems if l.isSelected() ] t_selected, t_movies = len( selected ), len( self.listitems ) if selected and xbmcgui.Dialog().yesno( self.heading, Language( 32122 ), Language( 32123 ) % ( t_selected, t_movies ), Language( 32124 ) ): is_cached_thumb = False if t_selected > 1: # if multi download to user folder heading = Language( 32126 ) + ( Language( 32127 ), Language( 32128 ) )[ self.thumb_type == "thumb" ] dpath = xbmc.translatePath( get_browse_dialog( heading=heading ) ) if not dpath and not path_exists( dpath ): return overwrite = xbmcgui.Dialog().yesno( Language( 32135 ), Language( 32136 ) ) else: # otherwise, download to cached thumb overwrite = True is_cached_thumb = True dpath = "" self.control_list.getListItem( 0 ).setThumbnailImage( "DefaultVideoCover.png" ) DIALOG_PROGRESS.create( self.heading ) diff = 100.0 / t_selected percent = 0 for count, listitem in enumerate( selected ): self.control_list.selectItem( int( listitem.getProperty( "indexItem" ) ) ) url = listitem.getProperty( "url" ) dest = "" if not is_cached_thumb: dest = _unicode( os.path.join( dpath, os.path.basename( url ) ) ) percent += diff if not overwrite: if self.art.get( self.thumb_type ) or ( dest and path_exists( dest ) ): listitem.select( False ) continue line1 = Language( 32125 ) % ( count+1, t_selected, percent ) DIALOG_PROGRESS.update( int( percent ), line1, url, dest ) if is_cached_thumb: print ( "image://" + urllib.quote_plus( url ) ) ok = xbmcart.setArt( self.idset, "set", self.thumb_type, url ) if ok: c_art = xbmcart.copyArtToCache( url ) self.control_list.getListItem( 0 ).setThumbnailImage( "image://" + urllib.quote_plus( url ) ) self.movieset_update = True listitem.select( False ) break # download file for extra thumbs or fanarts try: ok = xbmcvfs.copy( url, dest ) print "%r xbmcvfs.copy( %r, %r )" % ( ok, url, dest ) except: LOGGER.error.LOG( url ) dest = None LOGGER.error.print_exc() listitem.select( False ) if DIALOG_PROGRESS.iscanceled(): break self._close_dialog() except: LOGGER.error.print_exc() if xbmc.getCondVisibility( "Window.IsVisible(progressdialog)" ): xbmc.executebuiltin( "Dialog.Close(progressdialog)" ) self.select_all = False
def _download(self): try: selected = [l for l in self.listitems if l.isSelected()] t_selected, t_movies = len(selected), len(self.listitems) if selected and xbmcgui.Dialog().yesno( self.heading, Language(32122), Language(32123) % (t_selected, t_movies), Language(32124)): is_cached_thumb = False if t_selected > 1: # if multi download to user folder heading = Language(32126) + (Language( 32127), Language(32128))[self.thumb_type == "thumb"] dpath = xbmc.translatePath( get_browse_dialog(heading=heading)) if not dpath and not path_exists(dpath): return overwrite = xbmcgui.Dialog().yesno(Language(32135), Language(32136)) else: # otherwise, download to cached thumb overwrite = True is_cached_thumb = True dpath = "" self.control_list.getListItem(0).setThumbnailImage( "DefaultVideoCover.png") DIALOG_PROGRESS.create(self.heading) diff = 100.0 / t_selected percent = 0 for count, listitem in enumerate(selected): self.control_list.selectItem( int(listitem.getProperty("indexItem"))) url = listitem.getProperty("url") dest = "" if not is_cached_thumb: dest = _unicode( os.path.join(dpath, os.path.basename(url))) percent += diff if not overwrite: if self.art.get( self.thumb_type) or (dest and path_exists(dest)): listitem.select(False) continue line1 = Language(32125) % (count + 1, t_selected, percent) DIALOG_PROGRESS.update(int(percent), line1, url, dest) if is_cached_thumb: print("image://" + urllib.quote_plus(url)) ok = xbmcart.setArt(self.idset, "set", self.thumb_type, url) if ok: c_art = xbmcart.copyArtToCache(url) self.control_list.getListItem(0).setThumbnailImage( "image://" + urllib.quote_plus(url)) self.movieset_update = True listitem.select(False) break # download file for extra thumbs or fanarts try: ok = xbmcvfs.copy(url, dest) print "%r xbmcvfs.copy( %r, %r )" % (ok, url, dest) except: LOGGER.error.LOG(url) dest = None LOGGER.error.print_exc() listitem.select(False) if DIALOG_PROGRESS.iscanceled(): break self._close_dialog() except: LOGGER.error.print_exc() if xbmc.getCondVisibility("Window.IsVisible(progressdialog)"): xbmc.executebuiltin("Dialog.Close(progressdialog)") self.select_all = False
def onClick( self, controlID ): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getProperty( "url" ) if l2 == "browse": heading = ( LangXBMC( 20019 ), LangXBMC( 20437 ) )[ self.thumb_type == "fanart" ] ipath = xbmc.translatePath( get_browse_dialog( heading=heading, dlg_type=2 ) ) if ipath and path_exists( ipath ): listitem = self.control_list.getListItem( 0 ) listitem.setThumbnailImage( "DefaultVideoCover.png" ) # Frodo ok = xbmcart.setArt( self.idset, "set", self.thumb_type, ipath ) listitem.setThumbnailImage( "image://" + urllib.quote_plus( ipath ) ) self.movieset_update = ok elif l2 == "current": listitem.select( True ) # Frodo if xbmcgui.Dialog().yesno( LangXBMC( 122 ), LangXBMC( 125 ) ): listitem.setThumbnailImage( "DefaultVideoCover.png" ) ok = xbmcart.setArt( self.idset, "set", self.thumb_type, "" ) self.movieset_update = ok listitem.select( False ) elif l2 == "more": uris = [ "5666565996413149985", "5666567085447739761", "5666592955527206641", "5666593860416415425", "5666611392669713825", "5680591064557830705", ] choice = [ "Movie Boxset 3D (0 - M)", "Movie Boxset 3D (N - Z)", "Movie Boxset Clearcase (0 - M)", "Movie Boxset Clearcase (N - Z)", "Movie Boxset Diamond (0 - M)", "Movie Boxset Diamond (N - Z)", ] selected = xbmcgui.Dialog().select( "Movie Sets Arts", choice ) if selected == -1: return xbmc.executebuiltin( 'ActivateWindow(busydialog)' ) o_json = getMoreOnGooglePlus( uris[ selected ] ) xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' ) lis = [] selectItem = 0 for i, s in enumerate( o_json ): iconimage = s[ 2 ][ 0 ] name = urllib.unquote_plus( urllib.unquote_plus( os.path.basename( iconimage )[ :-4 ] ) ) li = xbmcgui.ListItem( name, "", "DefaultPicture.png", iconimage ) li.setProperty( "url", iconimage ) lis.append( li ) l1, l2 = li.getLabel().lower(), self.heading.lower() if l2 == l1 or l2 in l1 or l1 in l2: selectItem = i # toggle list control self.control_list.setEnabled( 0 ) self.control_list.setVisible( 0 ) self.getControl( self.CONTROL_LIST_451 ).reset() self.getControl( self.CONTROL_LIST_451 ).addItems( lis ) self.getControl( self.CONTROL_LIST_451 ).setEnabled( 1 ) self.getControl( self.CONTROL_LIST_451 ).setVisible( 1 ) self.getControl( self.CONTROL_LIST_451 ).selectItem( selectItem ) self.setFocus( self.getControl( self.CONTROL_LIST_451 ) ) self.getControl( self.CONTROL_BUTTON_CREATE ).setEnabled( 0 ) self.getControl( self.CONTROL_BUTTON_OK ).setEnabled( 0 ) else: listitem.select( not listitem.isSelected() ) if controlID == self.CONTROL_LIST_451: listitem = self.getControl( self.CONTROL_LIST_451 ).getSelectedItem() listitem.setProperty( "indexItem", str( self.indexItem ) ) label = " - ".join( [ LangXBMC( 22082 ).strip( "." ).strip(), listitem.getLabel() ] ) listitem.setLabel( label ) self.listitems.append( listitem ) self.control_list.addItem( listitem ) self.control_list.selectItem( self.indexItem+2 ) self.indexItem +=1 # toggle list control self.getControl( self.CONTROL_LIST_451 ).reset() self.getControl( self.CONTROL_LIST_451 ).setEnabled( 0 ) self.getControl( self.CONTROL_LIST_451 ).setVisible( 0 ) self.control_list.setEnabled( 1 ) self.control_list.setVisible( 1 ) self.setFocus( self.control_list ) self.getControl( self.CONTROL_BUTTON_CREATE ).setEnabled( 1 ) self.getControl( self.CONTROL_BUTTON_OK ).setEnabled( 1 ) elif controlID == self.CONTROL_BUTTON_CREATE: self.select_all = not self.select_all for listitem in self.listitems: listitem.select( self.select_all ) elif controlID == self.CONTROL_BUTTON_CANCEL: self._close_dialog() elif controlID == self.CONTROL_BUTTON_OK: self._download() except: LOGGER.error.print_exc() if xbmc.getCondVisibility( "Window.IsVisible(busydialog)" ): xbmc.executebuiltin( 'Dialog.Close(busydialog,true)' )
def onClick(self, controlID): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getProperty("url") if l2 == "browse": heading = (LangXBMC(20019), LangXBMC(20437))[self.thumb_type == "fanart"] ipath = xbmc.translatePath( get_browse_dialog(heading=heading, dlg_type=2)) if ipath and path_exists(ipath): listitem = self.control_list.getListItem(0) listitem.setThumbnailImage("DefaultVideoCover.png") # Frodo ok = xbmcart.setArt(self.idset, "set", self.thumb_type, ipath) listitem.setThumbnailImage("image://" + urllib.quote_plus(ipath)) self.movieset_update = ok elif l2 == "current": listitem.select(True) # Frodo if xbmcgui.Dialog().yesno(LangXBMC(122), LangXBMC(125)): listitem.setThumbnailImage("DefaultVideoCover.png") ok = xbmcart.setArt(self.idset, "set", self.thumb_type, "") self.movieset_update = ok listitem.select(False) elif l2 == "more": uris = [ "5666565996413149985", "5666567085447739761", "5666592955527206641", "5666593860416415425", "5666611392669713825", "5680591064557830705", ] choice = [ "Movie Boxset 3D (0 - M)", "Movie Boxset 3D (N - Z)", "Movie Boxset Clearcase (0 - M)", "Movie Boxset Clearcase (N - Z)", "Movie Boxset Diamond (0 - M)", "Movie Boxset Diamond (N - Z)", ] selected = xbmcgui.Dialog().select("Movie Sets Arts", choice) if selected == -1: return xbmc.executebuiltin('ActivateWindow(busydialog)') o_json = getMoreOnGooglePlus(uris[selected]) xbmc.executebuiltin('Dialog.Close(busydialog,true)') lis = [] selectItem = 0 for i, s in enumerate(o_json): iconimage = s[2][0] name = urllib.unquote_plus( urllib.unquote_plus( os.path.basename(iconimage)[:-4])) li = xbmcgui.ListItem(name, "", "DefaultPicture.png", iconimage) li.setProperty("url", iconimage) lis.append(li) l1, l2 = li.getLabel().lower(), self.heading.lower() if l2 == l1 or l2 in l1 or l1 in l2: selectItem = i # toggle list control self.control_list.setEnabled(0) self.control_list.setVisible(0) self.getControl(self.CONTROL_LIST_451).reset() self.getControl(self.CONTROL_LIST_451).addItems(lis) self.getControl(self.CONTROL_LIST_451).setEnabled(1) self.getControl(self.CONTROL_LIST_451).setVisible(1) self.getControl( self.CONTROL_LIST_451).selectItem(selectItem) self.setFocus(self.getControl(self.CONTROL_LIST_451)) self.getControl(self.CONTROL_BUTTON_CREATE).setEnabled(0) self.getControl(self.CONTROL_BUTTON_OK).setEnabled(0) else: listitem.select(not listitem.isSelected()) if controlID == self.CONTROL_LIST_451: listitem = self.getControl( self.CONTROL_LIST_451).getSelectedItem() listitem.setProperty("indexItem", str(self.indexItem)) label = " - ".join( [LangXBMC(22082).strip(".").strip(), listitem.getLabel()]) listitem.setLabel(label) self.listitems.append(listitem) self.control_list.addItem(listitem) self.control_list.selectItem(self.indexItem + 2) self.indexItem += 1 # toggle list control self.getControl(self.CONTROL_LIST_451).reset() self.getControl(self.CONTROL_LIST_451).setEnabled(0) self.getControl(self.CONTROL_LIST_451).setVisible(0) self.control_list.setEnabled(1) self.control_list.setVisible(1) self.setFocus(self.control_list) self.getControl(self.CONTROL_BUTTON_CREATE).setEnabled(1) self.getControl(self.CONTROL_BUTTON_OK).setEnabled(1) elif controlID == self.CONTROL_BUTTON_CREATE: self.select_all = not self.select_all for listitem in self.listitems: listitem.select(self.select_all) elif controlID == self.CONTROL_BUTTON_CANCEL: self._close_dialog() elif controlID == self.CONTROL_BUTTON_OK: self._download() except: LOGGER.error.print_exc() if xbmc.getCondVisibility("Window.IsVisible(busydialog)"): xbmc.executebuiltin('Dialog.Close(busydialog,true)')