From 5b71ec94fabd87c267f1dea446c53ef786e1b8f7 Mon Sep 17 00:00:00 2001
From: AndroKev <neureither.kevin@gmail.com>
Date: Sun, 27 Oct 2013 17:42:19 +0100
Subject: ExtractArchives - add an option to excludefiles

---
 module/plugins/hooks/ExtractArchive.py       | 9 +++++----
 module/plugins/internal/AbstractExtractor.py | 7 ++++---
 module/plugins/internal/UnRar.py             | 8 ++++++--
 3 files changed, 15 insertions(+), 9 deletions(-)

(limited to 'module/plugins')

diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 2cb546fbb..704ef3c6e 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -59,7 +59,7 @@ class ExtractArchive(Hook):
     Provides: unrarFinished (folder, filename)
     """
     __name__ = "ExtractArchive"
-    __version__ = "0.15"
+    __version__ = "0.16"
     __description__ = "Extract different kind of archives"
     __config__ = [("activated", "bool", "Activated", True),
                   ("fullpath", "bool", "Extract full path", True),
@@ -68,11 +68,12 @@ class ExtractArchive(Hook):
                   ("deletearchive", "bool", "Delete archives when done", False),
                   ("subfolder", "bool", "Create subfolder for each package", False),
                   ("destination", "folder", "Extract files to", ""),
+                  ("excludefiles", "str", "Exclude files from unpacking(seperated by ;)", "nfo;log"),
                   ("recursive", "bool", "Extract archives in archvies", True),
                   ("queue", "bool", "Wait for all downloads to be finished", True),
                   ("renice", "int", "CPU Priority", 0)]
-    __author_name__ = ("pyload Team")
-    __author_mail__ = ("admin<at>pyload.org")
+    __author_name__ = ("pyload Team", "AndroKev")
+    __author_mail__ = ("admin<at>pyload.org", "@pyloadforum")
 
     event_list = ["allDownloadsProcessed"]
 
@@ -177,7 +178,7 @@ class ExtractArchive(Hook):
                             continue
                         extracted.append(target)  # prevent extracting same file twice
 
-                        klass = plugin(self, target, out, self.getConfig("fullpath"), self.getConfig("overwrite"),
+                        klass = plugin(self, target, out, self.getConfig("fullpath"), self.getConfig("overwrite"), self.getConfig("excludefiles"),
                                        self.getConfig("renice"))
                         klass.init()
 
diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py
index 2130f910e..2ba2f2edf 100644
--- a/module/plugins/internal/AbstractExtractor.py
+++ b/module/plugins/internal/AbstractExtractor.py
@@ -27,10 +27,10 @@ class AbtractExtractor:
         raise NotImplementedError
 
 
-    def __init__(self, m, file, out, fullpath, overwrite, renice):
+    def __init__(self, m, file, out, fullpath, overwrite, excludefiles, renice):
         """Initialize extractor for specific file
 
-        :param m: ExtractArchive Hook plugin
+        :param m: Extracd pylctArchive Hook plugin
         :param file: Absolute filepath
         :param out: Absolute path to destination directory
         :param fullpath: extract to fullpath
@@ -42,6 +42,7 @@ class AbtractExtractor:
         self.out = out
         self.fullpath = fullpath
         self.overwrite = overwrite
+        self.excludefiles = excludefiles
         self.renice = renice
         self.files = [] # Store extracted files here
 
@@ -90,4 +91,4 @@ class AbtractExtractor:
 
     def getExtractedFiles(self):
         """Populate self.files at some point while extracting"""
-        return self.files
\ No newline at end of file
+        return self.files
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index da8e7cf3d..00f15791a 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -29,7 +29,7 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPas
 
 class UnRar(AbtractExtractor):
     __name__ = "UnRar"
-    __version__ = "0.13"
+    __version__ = "0.14"
 
     # there are some more uncovered rar formats
     re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I)
@@ -185,6 +185,11 @@ class UnRar(AbtractExtractor):
         args = []
         #overwrite flag
         args.append("-o+") if self.overwrite else args.append("-o-")
+        
+        if self.excludefiles != "":
+            for word in self.excludefiles.split(';'):
+                args.append("-x*" + word)
+                
 
         # assume yes on all queries
         args.append("-y")
@@ -195,7 +200,6 @@ class UnRar(AbtractExtractor):
         else:
             args.append("-p-")
 
-
         #NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
         call = [self.CMD, command] + args + list(xargs)
         self.m.logDebug(" ".join(call))
-- 
cgit v1.2.3