summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/MergeFiles.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/MergeFiles.py')
-rw-r--r--module/plugins/hooks/MergeFiles.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index a859092fb..e6f8bb26f 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -2,22 +2,24 @@
import os
import re
-import traceback
+
+from traceback import print_exc
from module.plugins.Hook import Hook, threaded
from module.utils import save_join, fs_encode
class MergeFiles(Hook):
- __name__ = "MergeFiles"
- __type__ = "hook"
+ __name__ = "MergeFiles"
+ __type__ = "hook"
__version__ = "0.12"
- __config__ = [("activated", "bool", "Activated", False)]
+ __config__ = [("activated", "bool", "Activated", True)]
__description__ = """Merges parts splitted with hjsplit"""
- __author_name__ = "and9000"
- __author_mail__ = "me@has-no-mail.com"
+ __license__ = "GPLv3"
+ __authors__ = [("and9000", "me@has-no-mail.com")]
+
BUFFER_SIZE = 4096
@@ -26,12 +28,13 @@ class MergeFiles(Hook):
# nothing to do
pass
+
@threaded
def packageFinished(self, pack):
files = {}
fid_dict = {}
for fid, data in pack.getChildren().iteritems():
- if re.search("\.[0-9]{3}$", data['name']):
+ if re.search("\.\d{3}$", data['name']):
if data['name'][:-4] not in files:
files[data['name'][:-4]] = []
files[data['name'][:-4]].append(data['name'])
@@ -44,11 +47,11 @@ class MergeFiles(Hook):
download_folder = save_join(download_folder, pack.folder)
for name, file_list in files.iteritems():
- self.logInfo("Starting merging of %s" % name)
+ self.logInfo(_("Starting merging of"), name)
final_file = open(save_join(download_folder, name), "wb")
for splitted_file in file_list:
- self.logDebug("Merging part %s" % splitted_file)
+ self.logDebug("Merging part", splitted_file)
pyfile = self.core.files.getFile(fid_dict[splitted_file])
pyfile.setStatus("processing")
try:
@@ -64,13 +67,13 @@ class MergeFiles(Hook):
else:
break
s_file.close()
- self.logDebug("Finished merging part %s" % splitted_file)
+ self.logDebug("Finished merging part", splitted_file)
except Exception, e:
- print traceback.print_exc()
+ print_exc()
finally:
pyfile.setProgress(100)
pyfile.setStatus("finished")
pyfile.release()
final_file.close()
- self.logInfo("Finished merging of %s" % name)
+ self.logInfo(_("Finished merging of"), name)