From 7f357700f340db51a0de65a8dcc0726a6965ecd3 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Tue, 10 Mar 2015 22:37:29 +0100
Subject: [SimpleHoster] Improve checkFile routine (2)

---
 module/plugins/internal/SimpleHoster.py | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index ac25423fc..393af86f5 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.21"
+    __version__ = "1.22"
 
     __pattern__ = r'^unmatchable$'
 
@@ -509,24 +509,27 @@ class SimpleHoster(Hoster):
             self.error(self.pyfile.error or _("No file downloaded"))
 
         else:
-            errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z')})
+            errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z'),
+                                         'Html error': re.compile(r'\A(\s*<.+>)?([\w\s]*([Ee]rror|ERROR)\s*:?)?\s*\d{3}(\Z|\s+)')})
 
-            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 not errmsg:
+                for r, p in [('Html file'    , re.compile(r'\A\s*<!DOCTYPE html')                              ),
+                             ('Unknown error', re.compile(r'[Aa]n error occured while processing your request'))]:
                     if r not in rules:
                         rules[r] = p
 
-                for r, a in [('error'     , 'ERROR_PATTERN'),
-                             ('wait error', 'WAIT_PATTERN' )]:
+                for r, a in [('Error'       , "ERROR_PATTERN"       ),
+                             ('Premium only', "PREMIUM_ONLY_PATTERN"),
+                             ('Wait error'  , "WAIT_PATTERN"        )]:
                     if r not in rules and hasattr(self, a):
                         rules[r] = getattr(self, a)
 
-                errmsg = self.checkDownload(rules, delete=not self.core.debug).strip().capitalize()
-                if self.lastCheck:
-                    errmsg += " | " + self.lastCheck.group(0).strip()
+                errmsg = self.checkDownload(rules).strip().capitalize()
+
+            try:
+                errmsg += " | " + self.lastCheck.group(1).strip()
+            except Exception:
+                pass
 
             if errmsg:
                 self.logWarning("Bad file", "Waiting 1 minute and retry")
-- 
cgit v1.2.3