summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-03-23 17:21:15 +0100
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-03-23 17:21:15 +0100
commitc67110356829f517d59ddd7c516dae6e13d08908 (patch)
tree86f3b3003bf559879481cd4153acc4250fb18faf
parentMerge pull request #1276 from immenz/Branch_AntiVir (diff)
parent[ExtractArchive] extract archive even if first part is not in package (diff)
downloadpyload-c67110356829f517d59ddd7c516dae6e13d08908.tar.xz
Merge pull request #1278 from immenz/dev_extract
[ExtractArchive] extract archive even if first part is not in package
-rw-r--r--module/plugins/hooks/ExtractArchive.py6
-rw-r--r--module/plugins/internal/Extractor.py16
-rw-r--r--module/plugins/internal/UnRar.py5
3 files changed, 19 insertions, 8 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 0c163078c..d9af2dd49 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -106,7 +106,7 @@ class ArchiveQueue(object):
class ExtractArchive(Hook):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.34"
+ __version__ = "1.35"
__config__ = [("activated" , "bool" , "Activated" , True ),
("fullpath" , "bool" , "Extract with full paths" , True ),
@@ -328,7 +328,9 @@ class ExtractArchive(Hook):
success = False
continue
- files_ids.remove((fname, fid, fout)) #: don't let other extractors spam log
+ # remove processed file and related multiparts from list
+ files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \
+ if fname not in archive.getDeleteFiles()]
self.logDebug("Extracted files: %s" % new_files)
self.setPermissions(new_files)
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py
index f32329e37..dad57dc7f 100644
--- a/module/plugins/internal/Extractor.py
+++ b/module/plugins/internal/Extractor.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import os
+import re
from module.PyFile import PyFile
@@ -19,7 +20,7 @@ class PasswordError(Exception):
class Extractor:
__name__ = "Extractor"
- __version__ = "0.21"
+ __version__ = "0.22"
__description__ = """Base extractor plugin"""
__license__ = "GPLv3"
@@ -35,7 +36,7 @@ class Extractor:
@classmethod
def isArchive(cls, filename):
name = os.path.basename(filename).lower()
- return any(name.endswith(ext) for ext in cls.EXTENSIONS) and not cls.isMultipart(filename)
+ return any(name.endswith(ext) for ext in cls.EXTENSIONS)
@classmethod
@@ -57,7 +58,16 @@ class Extractor:
:param files_ids: List of filepathes
:return: List of targets, id tuple list
"""
- return [(fname, id, fout) for fname, id, fout in files_ids if cls.isArchive(fname)]
+ targets = []
+ processed = []
+
+ for fname, id, fout in files_ids:
+ if cls.isArchive(fname):
+ pname = re.sub(cls.re_multipart, '', fname) if cls.isMultipart(fname) else os.path.splitext(fname)[0]
+ if pname not in processed:
+ processed.append(pname)
+ targets.append((fname, id, fout))
+ return targets
def __init__(self, manager, filename, out,
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 2ba6ff90d..b75e21f57 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -22,7 +22,7 @@ def renice(pid, value):
class UnRar(Extractor):
__name__ = "UnRar"
- __version__ = "1.16"
+ __version__ = "1.17"
__description__ = """Rar extractor plugin"""
__license__ = "GPLv3"
@@ -82,8 +82,7 @@ class UnRar(Extractor):
def isMultipart(cls, filename):
multipart = cls.re_multipart.search(filename)
if multipart:
- # First Multipart file (part1.rar for *.part1-9.rar format or *.rar for .r1-9 format) handled as normal Archive
- return False if (multipart.group(1) == "part" and int(multipart.group(2)) == 1 and not multipart.group(3)) else True
+ return True if not multipart.group(3) else False
return False