def onClick(self, controlID): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getLabel2() if l2 == "browse": dpath = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart") heading = (__string__(20019), __string__(20437))[self.thumb_type == "fanart"] ipath = xbmc.translatePath( get_browse_dialog(heading=heading, dlg_type=2)) if ipath and os.path.exists(ipath): listitem = self.control_list.getListItem(0) listitem.setThumbnailImage("DefaultVideoCover.png") filecopy = "FileCopy(%s,%s)" % (ipath, dpath) log.notice.LOG( "%s, %s", xbmc.executehttpapi(filecopy).replace("<li>", ""), filecopy) if os.path.exists(dpath): if self.getControl( self.CONTROL_RADIOBUTTON).isSelected(): dpath = flip_fanart(dpath) listitem.setThumbnailImage( self.get_cached_thumb(dpath)) self.movieset_update = True elif l2 == "current": listitem.select(True) icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart") if not os.path.exists(icon): icon = "" ipath = icon.split("userdata")[-1].replace("\\", "/").strip("/") if icon and xbmcgui.Dialog().yesno(__string__(122), __string__(125), ipath): try: os.remove(icon) listitem.setThumbnailImage("DefaultVideoCover.png") except: log.error.exc_info(sys.exc_info(), self) listitem.select(False) else: listitem.select(not listitem.isSelected()) 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: log.error.exc_info(sys.exc_info(), self)
def onClick(self, controlID): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getLabel2() if l2 == "browse": dpath = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart") 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") OK = xbmcvfs.copy(ipath, dpath) LOGGER.notice.LOG("%s, FileCopy(%s,%s)", repr(OK), ipath, dpath) if path_exists(dpath): if self.getControl( self.CONTROL_RADIOBUTTON).isSelected(): dpath = flip_fanart( dpath, ADDON.getSetting("flipquality")) listitem.setThumbnailImage( self.get_cached_thumb(dpath)) self.movieset_update = True elif l2 == "current": listitem.select(True) icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart") if not path_exists(icon): icon = "" ipath = icon.split("userdata")[-1].replace("\\", "/").strip("/") if icon and xbmcgui.Dialog().yesno(LangXBMC(122), LangXBMC(125), ipath): try: os.remove(icon) listitem.setThumbnailImage("DefaultVideoCover.png") except: LOGGER.error.print_exc() listitem.select(False) else: listitem.select(not listitem.isSelected()) 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()
def setIconFanartImages( self, idSet, listitem ): try: fanart = TBN.get_cached_saga_thumb( idSet, True ) fanart = ( "", fanart )[ path_exists( fanart ) ] listitem.setProperty( "fanart_image", fanart ) except: LOGGER.error.exc_info( sys.exc_info(), self ) try: icon = TBN.get_cached_saga_thumb( idSet ) icon = ( "", icon )[ path_exists( icon ) ] listitem.setIconImage( icon ) except: LOGGER.error.exc_info( sys.exc_info(), self )
def setIconFanartImages(self, idSet, listitem): try: fanart = TBN.get_cached_saga_thumb(idSet, True) fanart = ("", fanart)[path_exists(fanart)] listitem.setProperty("fanart_image", fanart) except: LOGGER.error.exc_info(sys.exc_info(), self) try: icon = TBN.get_cached_saga_thumb(idSet) icon = ("", icon)[path_exists(icon)] listitem.setIconImage(icon) except: LOGGER.error.exc_info(sys.exc_info(), self)
def onInit( self ): try: self.listitem = database.getContainerMovieSets( self.idset )[ 0 ] if not self.listitem: self._close_dialog() else: self.listitem = self.listitem[ 0 ] self.addItem( self.listitem ) self.getControl( 50 ).setVisible( 0 ) self.getControl( 6 ).setLabel( "Manager" ) self.getControl( 12 ).setLabel( __string__( 20413 ) ) #desable trailer button 15 xbmc bug !!! if user click try: self.getControl( 15 ).setEnabled( 0 ) except: pass try: self.getControl( 150 ).setVisible( 0 ) listitems = [] for cast, role, movie in database.getCastAndRoleOfSet( self.idset ): label = " ".join( [ _unicode( cast ), __string__( 20347 ), _unicode( role ), __string__( 1405 ), _unicode( movie ) ] ) icon = TBN.get_cached_actor_thumb( cast ) listitems.append( xbmcgui.ListItem( label, "", icon, icon ) ) self.getControl( 150 ).addItems( listitems ) except: log.error.exc_info( sys.exc_info(), self ) self.getControl( 5 ).setEnabled( 0 ) if self.setfocus: self.setFocusId( self.setfocus ) except: log.error.exc_info( sys.exc_info(), self ) self._close_dialog()
def onInit( self ): try: # set controls label self.getControl( self.CONTROL_HEADING ).setLabel( self.heading ) label = ( __language__( 32121 ), __language__( 32131 ) )[ self.thumb_type == "thumb" ] self.getControl( self.CONTROL_LABEL_PATH ).setLabel( label )#"Select one %s or more for extra%s" #self.getControl( self.CONTROL_RADIOBUTTON ).setLabel( __string__( 13206 ) )#"Overwrite" self.getControl( self.CONTROL_RADIOBUTTON ).setEnabled( self.thumb_type == "fanart" ) self.getControl( self.CONTROL_BUTTON_CREATE ).setLabel( __string__( 188 ) )#"Select All" # get control list self.control_list = self.getControl( self.CONTROL_LIST_450 ) self.control_list.reset() # add listitem current thumb or current fanart icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) if not os.path.exists( icon ): icon = "DefaultVideoCover.png" else: icon = self.get_cached_thumb( icon ) label = ( __string__( 20440 ), __string__( 20016 ) )[ self.thumb_type == "thumb" ] listitem = xbmcgui.ListItem( label, "current", "DefaultVideoCover.png", icon ) self.control_list.addItem( listitem ) # add listitems self.control_list.addItems( self.listitems ) # add listitem browse self.control_list.addItem( xbmcgui.ListItem( __string__( 20153 ), "browse", "DefaultFolder.png" ) ) # desable controls #self.getControl( self.CONTROL_LIST_451 ).setEnabled( 0 ) try: self.getControl( self.CONTROL_LIST_451 ).setVisible( 0 ) except: pass except: log.error.exc_info( sys.exc_info(), self )
def onClick( self, controlID ): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getLabel2() if l2 == "browse": dpath = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) heading = ( __string__( 20019 ), __string__( 20437 ) )[ self.thumb_type == "fanart" ] ipath = xbmc.translatePath( get_browse_dialog( heading=heading, dlg_type=2 ) ) if ipath and os.path.exists( ipath ): listitem = self.control_list.getListItem( 0 ) listitem.setThumbnailImage( "DefaultVideoCover.png" ) filecopy = "FileCopy(%s,%s)" % ( ipath, dpath ) log.notice.LOG( "%s, %s", xbmc.executehttpapi( filecopy ).replace( "<li>", "" ), filecopy ) if os.path.exists( dpath ): if self.getControl( self.CONTROL_RADIOBUTTON ).isSelected(): dpath = flip_fanart( dpath ) listitem.setThumbnailImage( self.get_cached_thumb( dpath ) ) self.movieset_update = True elif l2 == "current": listitem.select( True ) icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) if not os.path.exists( icon ): icon = "" ipath = icon.split( "userdata" )[ -1 ].replace( "\\", "/" ).strip( "/" ) if icon and xbmcgui.Dialog().yesno( __string__( 122 ), __string__( 125 ), ipath ): try: os.remove( icon ) listitem.setThumbnailImage( "DefaultVideoCover.png" ) except: log.error.exc_info( sys.exc_info(), self ) listitem.select( False ) else: listitem.select( not listitem.isSelected() ) 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: log.error.exc_info( sys.exc_info(), self )
def onClick( self, controlID ): try: if controlID == self.CONTROL_LIST_450: listitem = self.control_list.getSelectedItem() l2 = listitem.getLabel2() if l2 == "browse": dpath = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) 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" ) OK = xbmcvfs.copy( ipath, dpath ) LOGGER.notice.LOG( "%s, FileCopy(%s,%s)", repr( OK ), ipath, dpath ) if path_exists( dpath ): if self.getControl( self.CONTROL_RADIOBUTTON ).isSelected(): dpath = flip_fanart( dpath, ADDON.getSetting( "flipquality" ) ) listitem.setThumbnailImage( self.get_cached_thumb( dpath ) ) self.movieset_update = True elif l2 == "current": listitem.select( True ) icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) if not path_exists( icon ): icon = "" ipath = icon.split( "userdata" )[ -1 ].replace( "\\", "/" ).strip( "/" ) if icon and xbmcgui.Dialog().yesno( LangXBMC( 122 ), LangXBMC( 125 ), ipath ): try: os.remove( icon ) listitem.setThumbnailImage( "DefaultVideoCover.png" ) except: LOGGER.error.print_exc() listitem.select( False ) else: listitem.select( not listitem.isSelected() ) 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()
def onInit( self ): try: self.listitem = getContainerMovieSets( self.idset )[ 0 ] if not self.listitem: self._close_dialog() else: self.listitem = self.listitem[ 0 ] self.addItem( self.listitem ) self.getControl( 50 ).setVisible( 0 ) self.getControl( 6 ).setLabel( "Manager" ) self.getControl( 12 ).setLabel( LangXBMC( 20413 ) ) #desable trailer button 15 xbmc bug !!! if user click try: self.getControl( 15 ).setEnabled( 0 ) except: pass con = cur = None if self.actorsdb: con, cur = self.actorsdb.getConnection() try: self.getControl( 150 ).setVisible( 0 ) listitems = [] for idActor, cast, role, movie in DATABASE.getCastAndRoleOfSet( self.idset ): try: # cast est role dans movie label = " ".join( [ _unicode( cast ), LangXBMC( 20347 ), _unicode( role ), LangXBMC( 1405 ), _unicode( movie ) ] ) art = DATABASE.getArtForItem( idActor, "actor" ) icon = "" if art: icon = art.get( "thumb" ) if icon: icon = "image://" + quote_plus( icon ) icon = icon or TBN.get_cached_actor_thumb( cast ) listitem = xbmcgui.ListItem( label, "", icon, icon ) if cur: actor = self.actorsdb.getActor( cur, strActor=cast ) bio = self.clean_bio( actor.get( "biography" ) or "" ) listitem.setInfo( "video", { "title": cast, "plot": bio } ) if actor: actor[ "biography" ] = bio listitem = self.setActorProperties( listitem, actor ) #print actor listitems.append( listitem ) except: LOGGER.error.print_exc() self.getControl( 150 ).addItems( listitems ) except: LOGGER.error.print_exc() self.getControl( 5 ).setEnabled( 0 ) if hasattr( con, "close" ): con.close() if self.setfocus: self.setFocusId( self.setfocus ) except: LOGGER.error.print_exc() self._close_dialog()
def setIconFanartImages( self, idSet, listitem ): art = DATABASE.getArtForItem( idSet ) if art: listitem.setIconImage( art[ "thumb" ] ) listitem.setProperty( "fanart_image", art[ "fanart" ] ) return try: fanart = TBN.get_cached_saga_thumb( idSet, True ) fanart = ( "", fanart )[ path_exists( fanart ) ] listitem.setProperty( "fanart_image", fanart ) except: LOGGER.error.print_exc() try: icon = TBN.get_cached_saga_thumb( idSet ) icon = ( "", icon )[ path_exists( icon ) ] listitem.setIconImage( icon ) except: LOGGER.error.print_exc()
def onInit(self): try: # set controls label self.getControl(self.CONTROL_HEADING).setLabel(self.heading) label = (Language(32121), Language(32131))[self.thumb_type == "thumb"] self.getControl(self.CONTROL_LABEL_PATH).setLabel( label) #"Select one %s or more for extra%s" #self.getControl( self.CONTROL_RADIOBUTTON ).setLabel( LangXBMC( 13206 ) )#"Overwrite" self.getControl(self.CONTROL_RADIOBUTTON).setEnabled( self.thumb_type == "fanart") self.getControl(self.CONTROL_BUTTON_CREATE).setLabel( LangXBMC(188)) #"Select All" # get control list self.control_list = self.getControl(self.CONTROL_LIST_450) self.control_list.reset() # add listitem current thumb or current fanart icon = TBN.get_cached_saga_thumb(self.idset, self.thumb_type == "fanart") if not path_exists(icon): icon = "DefaultVideoCover.png" else: icon = self.get_cached_thumb(icon) label = (LangXBMC(20440), LangXBMC(20016))[self.thumb_type == "thumb"] listitem = xbmcgui.ListItem(label, "current", "DefaultVideoCover.png", icon) self.control_list.addItem(listitem) # add listitems self.control_list.addItems(self.listitems) # add listitem browse self.control_list.addItem( xbmcgui.ListItem(LangXBMC(20153), "browse", "DefaultFolder.png")) self.setFocus(self.control_list) # desable controls try: self.getControl(self.CONTROL_LIST_451).setEnabled(0) except: pass try: self.getControl(self.CONTROL_LIST_451).setVisible(0) except: pass except: LOGGER.error.print_exc()
def onInit(self): try: self.listitem = database.getContainerMovieSets(self.idset)[0] if not self.listitem: self._close_dialog() else: self.listitem = self.listitem[0] self.addItem(self.listitem) self.getControl(50).setVisible(0) self.getControl(6).setLabel("Manager") self.getControl(12).setLabel(__string__(20413)) #desable trailer button 15 xbmc bug !!! if user click try: self.getControl(15).setEnabled(0) except: pass try: self.getControl(150).setVisible(0) listitems = [] for cast, role, movie in database.getCastAndRoleOfSet( self.idset): label = " ".join([ _unicode(cast), __string__(20347), _unicode(role), __string__(1405), _unicode(movie) ]) icon = TBN.get_cached_actor_thumb(cast) listitems.append( xbmcgui.ListItem(label, "", icon, icon)) self.getControl(150).addItems(listitems) except: log.error.exc_info(sys.exc_info(), self) self.getControl(5).setEnabled(0) if self.setfocus: self.setFocusId(self.setfocus) except: log.error.exc_info(sys.exc_info(), self) self._close_dialog()
def onInit( self ): try: # set controls label self.getControl( self.CONTROL_HEADING ).setLabel( self.heading ) label = ( Language( 32121 ), Language( 32131 ) )[ self.thumb_type == "thumb" ] self.getControl( self.CONTROL_LABEL_PATH ).setLabel( label )#"Select one %s or more for extra%s" #self.getControl( self.CONTROL_RADIOBUTTON ).setLabel( LangXBMC( 13206 ) )#"Overwrite" #print ( self.thumb_type == "fanart" ) and not self.art if self.art: self.getControl( self.CONTROL_RADIOBUTTON ).setVisible( 0 ) # hmmm! setEnabled not work on frodo! else: self.getControl( self.CONTROL_RADIOBUTTON ).setEnabled( self.thumb_type == "fanart" ) self.getControl( self.CONTROL_BUTTON_CREATE ).setLabel( LangXBMC( 188 ) )#"Select All" # get control list self.control_list = self.getControl( self.CONTROL_LIST_450 ) self.control_list.reset() # add listitem current thumb or current fanart if not self.art: icon = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) if not path_exists( icon ): icon = "DefaultVideoCover.png" else: icon = self.get_cached_thumb( icon ) else: icon = self.art[ self.thumb_type ] label = ( LangXBMC( 20440 ), LangXBMC( 20016 ) )[ self.thumb_type == "thumb" ] listitem = xbmcgui.ListItem( label, "current", "DefaultVideoCover.png", icon ) self.control_list.addItem( listitem ) # add listitems self.control_list.addItems( self.listitems ) # add listitem browse self.control_list.addItem( xbmcgui.ListItem( LangXBMC( 20153 ), "browse", "DefaultFolder.png" ) ) self.setFocus( self.control_list ) # desable controls try: self.getControl( self.CONTROL_LIST_451 ).setEnabled( 0 ) except: pass try: self.getControl( self.CONTROL_LIST_451 ).setVisible( 0 ) except: pass except: LOGGER.error.print_exc()
def _download( self ): DIALOG_PROGRESS = xbmcgui.DialogProgress() 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 os.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 = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) self.control_list.getListItem( 0 ).setThumbnailImage( "DefaultVideoCover.png" ) def _pbhook( numblocks, blocksize, filesize, ratio=1.0 ): try: pct = int( min( ( numblocks * blocksize * 100 ) / filesize, 100 ) * ratio ) except: pct = 100 DIALOG_PROGRESS.update( pct ) if DIALOG_PROGRESS.iscanceled(): raise IOError DIALOG_PROGRESS.create( self.heading ) diff = 100.0 / t_selected percent = 0 flipfanart = self.getControl( self.CONTROL_RADIOBUTTON ).isSelected() for count, listitem in enumerate( selected ): self.control_list.selectItem( int( listitem.getProperty( "indexItem" ) ) ) url = listitem.getLabel2() if is_cached_thumb: dest = "special://temp/" + os.path.basename( url ) else: dest = os.path.join( dpath, os.path.basename( url ) ) percent += diff line1 = __language__( 32125 ) % ( count+1, t_selected, percent ) DIALOG_PROGRESS.update( 0, line1, url, dest ) if not overwrite and os.path.exists( dest ): listitem.select( False ) continue # download file try: fp, h = urllib.urlretrieve( url, dest, lambda nb, bs, fs: _pbhook( nb, bs, fs ) ) if "denied.png" in h.get( "Content-Disposition", "" ): raise except: self.delete_files.add( dest ) log.error.LOG( dest ) dest = None log.error.exc_info( sys.exc_info(), self ) listitem.select( False ) if DIALOG_PROGRESS.iscanceled(): break #flip source if dest and flipfanart: dest = flip_fanart( dest ) if is_cached_thumb and dest: self.delete_files.add( dest ) filecopy = "FileCopy(%s,%s)" % ( dest, dpath ) log.notice.LOG( "%s, %s", xbmc.executehttpapi( filecopy ).replace( "<li>", "" ), filecopy ) if os.path.exists( dpath ): listitem = self.control_list.getListItem( 0 ) listitem.setThumbnailImage( self.get_cached_thumb( dpath ) ) self.movieset_update = True DIALOG_PROGRESS.update( 100 ) except: log.error.exc_info( sys.exc_info(), self ) _delete_files( self.delete_files ) try: DIALOG_PROGRESS.close() except: pass
def _download(self): DIALOG_PROGRESS = xbmcgui.DialogProgress() 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 os.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 = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart") self.control_list.getListItem(0).setThumbnailImage( "DefaultVideoCover.png") def _pbhook(numblocks, blocksize, filesize, ratio=1.0): try: pct = int( min((numblocks * blocksize * 100) / filesize, 100) * ratio) except: pct = 100 DIALOG_PROGRESS.update(pct) if DIALOG_PROGRESS.iscanceled(): raise IOError DIALOG_PROGRESS.create(self.heading) diff = 100.0 / t_selected percent = 0 flipfanart = self.getControl( self.CONTROL_RADIOBUTTON).isSelected() for count, listitem in enumerate(selected): self.control_list.selectItem( int(listitem.getProperty("indexItem"))) url = listitem.getLabel2() if is_cached_thumb: dest = "special://temp/" + os.path.basename(url) else: dest = os.path.join(dpath, os.path.basename(url)) percent += diff line1 = __language__(32125) % (count + 1, t_selected, percent) DIALOG_PROGRESS.update(0, line1, url, dest) if not overwrite and os.path.exists(dest): listitem.select(False) continue # download file try: fp, h = urllib.urlretrieve( url, dest, lambda nb, bs, fs: _pbhook(nb, bs, fs)) if "denied.png" in h.get("Content-Disposition", ""): raise except: self.delete_files.add(dest) log.error.LOG(dest) dest = None log.error.exc_info(sys.exc_info(), self) listitem.select(False) if DIALOG_PROGRESS.iscanceled(): break #flip source if dest and flipfanart: dest = flip_fanart(dest) if is_cached_thumb and dest: self.delete_files.add(dest) filecopy = "FileCopy(%s,%s)" % (dest, dpath) log.notice.LOG( "%s, %s", xbmc.executehttpapi(filecopy).replace("<li>", ""), filecopy) if os.path.exists(dpath): listitem = self.control_list.getListItem(0) listitem.setThumbnailImage( self.get_cached_thumb(dpath)) self.movieset_update = True DIALOG_PROGRESS.update(100) except: log.error.exc_info(sys.exc_info(), self) _delete_files(self.delete_files) try: DIALOG_PROGRESS.close() except: pass
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 = TBN.get_cached_saga_thumb( self.idset, self.thumb_type == "fanart" ) self.control_list.getListItem( 0 ).setThumbnailImage( "DefaultVideoCover.png" ) def _pbhook( numblocks, blocksize, filesize, ratio=1.0 ): try: pct = int( min( ( numblocks * blocksize * 100 ) / filesize, 100 ) * ratio ) except: pct = 100 DIALOG_PROGRESS.update( pct ) if DIALOG_PROGRESS.iscanceled(): raise IOError DIALOG_PROGRESS.create( self.heading ) diff = 100.0 / t_selected percent = 0 flipfanart = self.getControl( self.CONTROL_RADIOBUTTON ).isSelected() for count, listitem in enumerate( selected ): self.control_list.selectItem( int( listitem.getProperty( "indexItem" ) ) ) url = listitem.getLabel2() if is_cached_thumb: dest = TEMP_DIR + os.path.basename( url ) else: dest = _unicode( os.path.join( dpath, os.path.basename( url ) ) ) percent += diff if not overwrite: if self.art.get( self.thumb_type ) or path_exists( dest ): listitem.select( False ) continue # Frodo if self.art and count == 0: DATABASE.setArtForItem( self.idset, "set", self.thumb_type, url ) listitem.select( False ) if t_selected == 1: break line1 = Language( 32125 ) % ( count+1, t_selected, percent ) DIALOG_PROGRESS.update( 0, line1, url, dest ) # Eden or for extra: download file try: fp, h = urllib.urlretrieve( url, dest, lambda nb, bs, fs: _pbhook( nb, bs, fs ) ) if "denied.png" in h.get( "Content-Disposition", "" ): raise except: self.delete_files.add( dest ) LOGGER.error.LOG( dest ) dest = None LOGGER.error.print_exc() listitem.select( False ) if DIALOG_PROGRESS.iscanceled(): break #flip source if dest and flipfanart: dest = flip_fanart( dest, ADDON.getSetting( "flipquality" ) ) if is_cached_thumb and dest: self.delete_files.add( dest ) OK = xbmcvfs.copy( dest, dpath ) LOGGER.notice.LOG( "%s, FileCopy(%s,%s)", repr( OK ), dest, dpath ) #filecopy = "FileCopy(%s,%s)" % ( dest, dpath ) #LOGGER.notice.LOG( "%s, %s", xbmc.executehttpapi( filecopy ).replace( "<li>", "" ), filecopy ) if path_exists( dpath ): listitem = self.control_list.getListItem( 0 ) listitem.setThumbnailImage( self.get_cached_thumb( dpath ) ) self.movieset_update = True #DIALOG_PROGRESS.update( 100 ) _delete_files( self.delete_files ) except: LOGGER.error.print_exc() if xbmc.getCondVisibility( "Window.IsVisible(progressdialog)" ): xbmc.executebuiltin( "Dialog.Close(progressdialog)" )