diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-10 20:01:17 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-10 20:01:17 +0100 |
commit | ebb9910a25dbf0fc0d16242e9b4e9ffaa418656e (patch) | |
tree | d84d60bd71c1848387a7ff14fb73f583080b9365 | |
parent | [FilerNet] Fix WAIT_PATTERN (diff) | |
download | pyload-ebb9910a25dbf0fc0d16242e9b4e9ffaa418656e.tar.xz |
[SimpleHoster] Improve checkFile routine
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 3a38c4eea..ac25423fc 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.20" + __version__ = "1.21" __pattern__ = r'^unmatchable$' @@ -499,7 +499,7 @@ class SimpleHoster(Hoster): self.download(link, ref=False, disposition=disposition) - def checkFile(self): + def checkFile(self, rules={}): if self.cTask and not self.lastDownload: self.invalidCaptcha() self.retry(10, reason=_("Wrong captcha")) @@ -509,24 +509,28 @@ class SimpleHoster(Hoster): self.error(self.pyfile.error or _("No file downloaded")) else: - rules = {'empty file': re.compile(r'\A\Z'), - 'html file' : re.compile(r'\A\s*<!DOCTYPE html'), - 'html error': re.compile(r'\A\s*(<.+>)?\d{3}(\Z|\s+)')} + errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z')}) - if hasattr(self, 'ERROR_PATTERN'): - rules['error'] = re.compile(self.ERROR_PATTERN) + if errmsg: + self.lastDownload = "" + else: + for r, p in [('html file' , re.compile(r'\A\s*<!DOCTYPE html' )), + ('html error', re.compile(r'\A\s*(<.+>)?\d{3}(\Z|\s+)'))]: + if r not in rules: + rules[r] = p - if hasattr(self, 'WAIT_PATTERN'): - rules['wait error'] = re.compile(self.WAIT_PATTERN) + for r, a in [('error' , 'ERROR_PATTERN'), + ('wait error', 'WAIT_PATTERN' )]: + if r not in rules and hasattr(self, a): + rules[r] = getattr(self, a) - check = self.checkDownload(rules) - if check: #@TODO: Move to hoster in 0.4.10 - errmsg = check.strip().capitalize() + errmsg = self.checkDownload(rules, delete=not self.core.debug).strip().capitalize() if self.lastCheck: errmsg += " | " + self.lastCheck.group(0).strip() - self.lastDownload = "" - self.retry(10, 60, errmsg) + if errmsg: + self.logWarning("Bad file", "Waiting 1 minute and retry") + self.retry(3, 60, errmsg) def checkErrors(self): |