summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-16 23:04:15 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-16 23:04:15 +0100
commit8bb189cf5495b293cf574e5049c34a64ae36ffe1 (patch)
tree934b5a0a2cc798a19f3e5fdb9235b295ca638c16 /module/plugins
parent[SkipRev] Another fix (diff)
downloadpyload-8bb189cf5495b293cf574e5049c34a64ae36ffe1.tar.xz
Spare code cosmetics
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hooks/ExtractArchive.py18
-rw-r--r--module/plugins/hoster/UnrestrictLi.py2
-rw-r--r--module/plugins/internal/UnRar.py9
3 files changed, 15 insertions, 14 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index fc77dbdf6..895aee51f 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -195,6 +195,7 @@ class ExtractArchive(Hook):
if targets:
self.logDebug("Targets for %s: %s" % (plugin.__name__, targets))
matched = True
+
for target, fid in targets:
if target in processed:
self.logDebug(basename(target), "skipped")
@@ -206,8 +207,10 @@ class ExtractArchive(Hook):
try:
klass = plugin(self, target, out, fullpath, overwrite, excludefiles, renice)
klass.init()
- password = p.password.strip().splitlines()
- new_files = self._extract(klass, fid, password, thread)
+
+ passwords = p.password.strip().splitlines()
+ new_files = self._extract(klass, fid, passwords, thread)
+
except Exception, e:
self.logError(basename(target), e)
success = False
@@ -256,13 +259,7 @@ class ExtractArchive(Hook):
self.logInfo(basename(plugin.file), _("Password protected"))
self.logDebug("Passwords", passwords)
- pwlist = copy(self.getPasswords())
- # remove already supplied pws from list (only local)
- for pw in passwords:
- if pw in pwlist:
- pwlist.remove(pw)
-
- for pw in passwords + pwlist:
+ for pw in set(passwords) + set(self.getPasswords()):
try:
self.logDebug("Try password", pw)
if plugin.checkPassword(pw):
@@ -270,6 +267,7 @@ class ExtractArchive(Hook):
self.addPassword(pw)
success = True
break
+
except WrongPassword:
self.logDebug("Password was wrong")
@@ -297,8 +295,10 @@ class ExtractArchive(Hook):
except ArchiveError, e:
self.logError(basename(plugin.file), _("Archive Error"), e)
+
except CRCError:
self.logError(basename(plugin.file), _("CRC Mismatch"))
+
except Exception, e:
if self.core.debug:
print_exc()
diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py
index d5c3ddc15..786e25a9a 100644
--- a/module/plugins/hoster/UnrestrictLi.py
+++ b/module/plugins/hoster/UnrestrictLi.py
@@ -20,7 +20,7 @@ def secondsToMidnight(gmt=0):
if hasattr(td, 'total_seconds'):
res = td.total_seconds()
- else:
+ else: #@NOTE: work-around for python 2.5 and 2.6 missing timedelta.total_seconds
res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
return int(res)
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index c15a4c96e..716a62613 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -22,7 +22,7 @@ def renice(pid, value):
class UnRar(AbtractExtractor):
__name__ = "UnRar"
- __version__ = "0.19"
+ __version__ = "0.20"
__description__ = """Rar extractor plugin"""
__license__ = "GPLv3"
@@ -32,7 +32,7 @@ class UnRar(AbtractExtractor):
CMD = "unrar"
# there are some more uncovered rar formats
- re_version = re.compile(r'UNRAR ([\w .]+?) freeware')
+ re_version = re.compile(r'UNRAR ([\w .]+?)')
re_splitfile = re.compile(r'(.*)\.part(\d+)\.rar$', re.I)
re_partfiles = re.compile(r'.*\.(rar|r\d+)', re.I)
re_filelist = re.compile(r'(.+)\s+(\d+)\s+(\d+)\s+')
@@ -91,7 +91,7 @@ class UnRar(AbtractExtractor):
out, err = p.communicate()
if self.re_wrongpwd.search(err):
self.passwordProtected = True
- self.headerProtected = True
+ self.headerProtected = True
return True
# output only used to check if passworded files are present
@@ -124,7 +124,7 @@ class UnRar(AbtractExtractor):
return True
- def extract(self, progress, password=None):
+ def extract(self, progress, password=""):
command = "x" if self.fullpath else "e"
p = self.call_unrar(command, self.file, self.out, password=password)
@@ -156,6 +156,7 @@ class UnRar(AbtractExtractor):
raise CRCError
elif "CRC failed" in err:
raise WrongPassword
+
if err.strip(): #: raise error if anything is on stderr
raise ArchiveError(err.strip())
if p.returncode: