summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-09 01:52:24 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-09 01:52:24 +0200
commitda1180bc2d428ad52fbbecda8473fc1fb7267438 (patch)
tree1565947cf7b67e21e28f0c27df2f9dd3e91bb1ca /module/plugins/internal
parentNew plugin: TNTVillageScambioeticoOrg (diff)
downloadpyload-da1180bc2d428ad52fbbecda8473fc1fb7267438.tar.xz
[SimpleHoster] Improve checkFile
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/DeadCrypter.py2
-rw-r--r--module/plugins/internal/DeadHoster.py2
-rw-r--r--module/plugins/internal/SimpleHoster.py52
3 files changed, 26 insertions, 30 deletions
diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py
index 28ead4c23..ef0d12b91 100644
--- a/module/plugins/internal/DeadCrypter.py
+++ b/module/plugins/internal/DeadCrypter.py
@@ -11,7 +11,7 @@ class DeadCrypter(Crypter):
__pattern__ = r'^unmatchable$'
- __description__ = """ Crypter is no longer available """
+ __description__ = """Crypter is no longer available"""
__license__ = "GPLv3"
__authors__ = [("stickell", "l.stickell@yahoo.it")]
diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py
index 6dc860eea..accb15a78 100644
--- a/module/plugins/internal/DeadHoster.py
+++ b/module/plugins/internal/DeadHoster.py
@@ -11,7 +11,7 @@ class DeadHoster(Hoster):
__pattern__ = r'^unmatchable$'
- __description__ = """ Hoster is no longer available """
+ __description__ = """Hoster is no longer available"""
__license__ = "GPLv3"
__authors__ = [("zoidberg", "zoidberg@mujmail.cz")]
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 6f2dc8a6c..2454a5072 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -239,7 +239,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.63"
+ __version__ = "1.64"
__pattern__ = r'^unmatchable$'
__config__ = [("use_premium", "bool", "Use premium account if available" , True),
@@ -581,47 +581,43 @@ class SimpleHoster(Hoster):
def checkFile(self):
+ lastDownload = fs_encode(self.lastDownload)
+
if self.cTask and not self.lastDownload:
self.invalidCaptcha()
self.retry(10, reason=_("Wrong captcha"))
- elif not self.lastDownload or not os.path.exists(fs_encode(self.lastDownload)):
+ elif not self.lastDownload or not os.path.exists(lastDownload):
self.lastDownload = ""
self.error(self.pyfile.error or _("No file downloaded"))
else:
- self.logDebug(_("Checking last downloaded file with built-in rules"))
- errmsg = self.checkDownload({'Empty file': re.compile(r'\A((.|)(\2|\s)*)\Z')})
-
- if errmsg:
- return
-
- self.logDebug(_("Checking last downloaded file with custom rules"))
-
- if self.CHECK_FILE:
- rules = [(r, getattr(self, a)) for r, a in (("IP blocked" , "IP_BLOCKED_PATTERN" ),
- ("Download limit", "DL_LIMIT_PATTERN" ),
- ("Size limit" , "SIZE_LIMIT_PATTERN" ),
- ("Error" , "ERROR_PATTERN" ),
- ("Premium only" , "PREMIUM_ONLY_PATTERN"),
- ("Wait error" , "WAIT_PATTERN" )) if hasattr(self, a)]
- self.FILE_ERRORS.extend(rules)
+ #@TODO: Move to Hoster in 0.4.10
+ if os.stat(lastDownload).st_size < 1 or self.checkDownload({'Empty file': re.compile(r'\A((.|)(\2|\s)*)\Z')}):
+ self.error(_("Empty file"))
+ self.logDebug("Checking last downloaded file with built-in rules")
for r, p in self.FILE_ERRORS:
errmsg = self.checkDownload({r: re.compile(p)})
+ if errmsg is not None:
+ errmsg = errmsg.strip().capitalize()
- if not errmsg:
- continue
-
- errmsg = errmsg.strip().capitalize()
+ try:
+ errmsg += " | " + self.lastCheck.group(1).strip()
+ except Exception:
+ pass
- try:
- errmsg += " | " + self.lastCheck.group(1).strip()
- except Exception:
- pass
+ self.logWarning("Check result: " + errmsg, "Waiting 1 minute and retry")
+ self.wantReconnect = True
+ self.retry(wait_time=60, reason=errmsg)
+ else:
+ if self.CHECK_FILE:
+ self.logDebug("Checking last downloaded file with custom rules")
+ with open(lastDownload, "rb") as f:
+ self.html = f.read(50000) #@TODO: Recheck in 0.4.10
+ self.checkErrors()
- self.logWarning("Check result: " + errmsg, "Waiting 1 minute and retry")
- self.retry(3, 60, errmsg)
+ self.logDebug("No file errors found")
def checkErrors(self):