Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtractArchives - add an option to excludefiles #351

Merged
merged 5 commits into from
Nov 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions module/plugins/hooks/ExtractArchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 ;)", ""),
("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"]

Expand Down Expand Up @@ -177,7 +178,7 @@ def extract(self, ids, thread=None):
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()

Expand Down
5 changes: 3 additions & 2 deletions module/plugins/internal/AbstractExtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def getTargets(files_ids):
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
Expand All @@ -42,6 +42,7 @@ def __init__(self, m, file, out, fullpath, overwrite, renice):
self.out = out
self.fullpath = fullpath
self.overwrite = overwrite
self.excludefiles = excludefiles
self.renice = renice
self.files = [] # Store extracted files here

Expand Down Expand Up @@ -90,4 +91,4 @@ def getDeleteFiles(self):

def getExtractedFiles(self):
"""Populate self.files at some point while extracting"""
return self.files
return self.files
9 changes: 6 additions & 3 deletions module/plugins/internal/UnRar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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)
Expand Down Expand Up @@ -185,7 +185,11 @@ def call_unrar(self, command, *xargs, **kwargs):
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%s" % word )

# assume yes on all queries
args.append("-y")

Expand All @@ -195,7 +199,6 @@ def call_unrar(self, command, *xargs, **kwargs):
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))
Expand Down