diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-25 20:19:33 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-25 20:19:33 +0100 |
commit | a74e145f71941c9ee0a02da047167c43e5085b6f (patch) | |
tree | 6cf04236385c792f4e73c8242fb52e4b331b678b /module/plugins/hooks/ExtractArchive.py | |
parent | [MegaRapidoNet] Cleanup (diff) | |
parent | [ExtractArchive] Send2Trash Integration (diff) | |
download | pyload-a74e145f71941c9ee0a02da047167c43e5085b6f.tar.xz |
Merge pull request #1285 from immenz/dev_extract
[ExtractArchive] Send2Trash Integration
Diffstat (limited to 'module/plugins/hooks/ExtractArchive.py')
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d9af2dd49..c0fe22545 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,24 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.35" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive after extraction" , False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.36" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "No;Permanent;Trash" , "Delete archive after extraction" , "No" ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -148,6 +148,7 @@ class ExtractArchive(Hook): self.extractors = [] self.passwords = [] self.repair = False + self.trash = False def coreReady(self): @@ -448,15 +449,29 @@ class ExtractArchive(Hook): pyfile.setProgress(100) pyfile.setStatus("processing") + delfiles = archive.getDeleteFiles() if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) + self.logDebug("Would delete: %s" % ", ".join(delfiles)) - if self.getConfig('delete'): - files = archive.getDeleteFiles() - self.logInfo(_("Deleting %s files") % len(files)) - for f in files: + if self.getConfig('delete') != 'No': + try: + from send2trash import send2trash + if self.getConfig('delete') == "Trash": + self.trash = True + self.logInfo(_("Sending %s files to trash") % len(delfiles)) + except ImportError: + self.logError(name, _("Send2Trash not installed, no files deleted")) + self.trash = False + + if self.getConfig('delete') == "Permanent": + self.trash = False + self.logInfo(_("Deleting %s files") % len(delfiles)) + + for f in delfiles: file = fs_encode(f) - if os.path.exists(file): + if os.path.exists(file) and self.trash: + send2trash(file) + elif os.path.exists: os.remove(file) else: self.logDebug("%s does not exists" % f) |