diff options
Diffstat (limited to 'pyload/threads/DecrypterThread.py')
-rw-r--r-- | pyload/threads/DecrypterThread.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/pyload/threads/DecrypterThread.py b/pyload/threads/DecrypterThread.py index a0bebdfbf..c7a01683a 100644 --- a/pyload/threads/DecrypterThread.py +++ b/pyload/threads/DecrypterThread.py @@ -3,13 +3,14 @@ from time import sleep -from pyload.Api import LinkStatus, DownloadStatus as DS +from pyload.Api import LinkStatus, DownloadStatus as DS, ProgressInfo, ProgressType from pyload.utils import uniqify, accumulate from pyload.plugins.Base import Abort, Retry from pyload.plugins.Crypter import Package from BaseThread import BaseThread + class DecrypterThread(BaseThread): """thread for decrypting""" @@ -19,15 +20,22 @@ class DecrypterThread(BaseThread): # [... (plugin, url) ...] self.data = data self.pid = pid + # holds the progress, while running + self.progress = None + self.m.addThread(self) self.start() + def getProgress(self): + return self.progress + def run(self): pack = self.m.core.files.getPackage(self.pid) links, packages = self.decrypt(accumulate(self.data), pack.password) if links: - self.log.info(_("Decrypted %(count)d links into package %(name)s") % {"count": len(links), "name": pack.name}) + self.log.info( + _("Decrypted %(count)d links into package %(name)s") % {"count": len(links), "name": pack.name}) self.m.core.api.addFiles(self.pid, [l.url for l in links]) # TODO: add single package into this one and rename it? @@ -35,17 +43,25 @@ class DecrypterThread(BaseThread): for p in packages: self.m.core.api.addPackage(p.name, p.getURLs(), pack.password) + self.finished() + def decrypt(self, plugin_map, password=None, err=False): result = [] + self.progress = ProgressInfo("BasePlugin", "", _("decrypting"), + 0, 0, len(self.data), self.owner, ProgressType.Decrypting) # TODO QUEUE_DECRYPT - for name, urls in plugin_map.iteritems(): klass = self.m.core.pluginManager.loadClass("crypter", name) plugin = None plugin_result = [] + # updating progress + self.progress.plugin = name + self.progress.name = _("Decrypting %s links") % len(urls) if len(urls) > 1 else urls[0] + #TODO: dependency check, there is a new error code for this + # TODO: decrypting with result yielding if not klass: plugin_result.extend(LinkStatus(url, url, -1, DS.NotPossible, name) for url in urls) self.log.debug("Plugin for decrypting was not loaded") @@ -77,8 +93,12 @@ class DecrypterThread(BaseThread): if plugin: plugin.clean() + self.progress.done += len(urls) result.extend(plugin_result) + # clear the progress + self.progress = None + # generated packages packs = {} # urls without package |