diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-02 12:37:56 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-02 12:37:56 +0100 |
commit | 9ad979dc5b3753e2982855495b240b3da37c3be4 (patch) | |
tree | edb8488d538402153a8ba19f0b8a879b8af40f1a | |
parent | New addon RestartSlow (diff) | |
download | pyload-9ad979dc5b3753e2982855495b240b3da37c3be4.tar.xz |
[SkipRev] Updated
-rw-r--r-- | module/plugins/hooks/SkipRev.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py new file mode 100644 index 000000000..3b3b450fe --- /dev/null +++ b/module/plugins/hooks/SkipRev.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.Hook import Hook +from module.plugins.Plugin import SkipDownload + + +class SkipRev(Hook): + __name__ = "SkipRev" + __type__ = "hook" + __version__ = "0.08" + + __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True) + ("tokeep", "int" , "Min number of rev files to keep for package" , 1), + ("unskip", "bool", "Restart a skipped rev when download fails" , True)] + + __description__ = """Skip files ending with extension rev""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + event_map = [("downloadStarts", skipRev)] + + REV = re.compile(r'\.part(\d+)\.rev$') + + + def skipRev(self, pyfile, url, filename): + if REV.search(pyfile.name) is None or pyfile.getStatusName is "unskipped": + return + + tokeep = self.getConfig("tokeep") + + if tokeep > 0: + saved = [True if link.hasStatus("finished") or link.hasStatus("downloading") and REV.search(link.name) \ + for link in pyfile.package().getChildren()].count(True) + + if saved < tokeep: + return + + raise SkipDownload("SkipRev") + + + def downloadFailed(self, pyfile): + if self.getConfig("auto") is False: + + if self.getConfig("unskip") is False: + return + + if REV.search(pyfile.name) is None: + return + + for link in pyfile.package().getChildren(): + if link.hasStatus("skipped") and REV.search(link.name): + link.setCustomStatus("unskipped", "queued") + break |