summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/internal/SimpleHoster.py86
-rw-r--r--module/plugins/internal/XFSHoster.py66
2 files changed, 77 insertions, 75 deletions
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 0039d3f8e..27327c918 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -244,7 +244,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.42"
+ __version__ = "1.43"
__pattern__ = r'^unmatchable$'
__config__ = [("use_premium", "bool", "Use premium account if available" , True),
@@ -284,6 +284,18 @@ class SimpleHoster(Hoster):
PREMIUM_ONLY_PATTERN: (optional) Check if the file can be downloaded only with a premium account
example: PREMIUM_ONLY_PATTERN = r'Premium account required'
+ HAPPY_HOUR_PATTERN: (optional)
+ example:
+
+ IP_BLOCKED_PATTERN: (optional)
+ example:
+
+ DOWNLOAD_LIMIT_PATTERN: (optional)
+ example:
+
+ SIZE_LIMIT_PATTERN: (optional)
+ example:
+
ERROR_PATTERN: (optional) Detect any error preventing download
example: ERROR_PATTERN = r''
@@ -554,10 +566,39 @@ class SimpleHoster(Hoster):
self.logWarning(_("No html code to check"))
return
- if hasattr(self, 'PREMIUM_ONLY_PATTERN') and not self.premium and re.search(self.PREMIUM_ONLY_PATTERN, self.html):
- self.fail(_("Link require a premium account to be handled"))
+ if hasattr(self, 'IP_BLOCKED_PATTERN') and re.search(self.IP_BLOCKED_PATTERN, self.html):
+ self.fail(_("Connection from your current IP address is not allowed"))
+
+ elif not self.premium:
+ if hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html):
+ self.fail(_("File can be downloaded by premium users only"))
+
+ elif hasattr(self, 'SIZE_LIMIT_PATTERN') and re.search(self.SIZE_LIMIT_PATTERN, self.html):
+ self.fail(_("File too large for free download"))
- elif hasattr(self, 'ERROR_PATTERN'):
+ elif hasattr(self, 'DOWNLOAD_LIMIT_PATTERN') and re.search(self.DOWNLOAD_LIMIT_PATTERN, self.html):
+ m = re.search(self.DOWNLOAD_LIMIT_PATTERN, self.html)
+ try:
+ errmsg = m.group(1).strip()
+ except Exception:
+ errmsg = m.group(0).strip()
+
+ self.logWarning(re.sub(r'<.*?>', " ", self.errmsg))
+ self.info['error'] = errmsg
+
+ if re.search('da(il)?y|today', errmsg, re.I):
+ wait_time = secondsToMidnight(gmt=2)
+ else:
+ wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ re.findall(r'(\d+)\s*(hr|hour|min|sec|)', errmsg, re.I))
+
+ self.wantReconnect = wait_time > 300
+ self.retry(1, wait_time, _("Download limit exceeded"))
+
+ if hasattr(self, 'HAPPY_HOUR_PATTERN') and re.search(self.HAPPY_HOUR_PATTERN, self.html):
+ self.multiDL = True
+
+ if hasattr(self, 'ERROR_PATTERN'):
m = re.search(self.ERROR_PATTERN, self.html)
if m:
try:
@@ -565,19 +606,40 @@ class SimpleHoster(Hoster):
except Exception:
errmsg = m.group(0).strip()
+ self.logWarning(re.sub(r'<.*?>', " ", self.errmsg))
self.info['error'] = errmsg
- if "hour" in errmsg:
- self.wait(1 * 60 * 60, True)
+ if re.search('limit|wait', errmsg, re.I):
+ if re.search("da(il)?y|today", errmsg):
+ wait_time = secondsToMidnight(gmt=2)
+ else:
+ wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ re.findall(r'(\d+)\s*(hr|hour|min|sec|)', errmsg, re.I))
+
+ self.wantReconnect = wait_time > 300
+ self.retry(1, wait_time, _("Download limit exceeded"))
+
+ elif re.search('country', errmsg, re.I):
+ self.fail(_("Connection from your current IP address is not allowed"))
+
+ elif re.search('captcha', errmsg, re.I):
+ self.invalidCaptcha()
+
+ elif re.search('countdown|expired', errmsg, re.I):
+ self.retry(wait_time=60, reason=_("Link expired"))
+
+ elif re.search('maintenance|maintainance', errmsg, re.I):
+ self.tempOffline()
- elif re.search("da(il)?y|today", errmsg):
- self.wait(secondsToMidnight(gmt=2), True)
+ elif re.search('up to', errmsg, re.I):
+ self.fail(_("File too large for free download"))
- elif "minute" in errmsg:
- self.wait(1 * 60)
+ elif re.search('premium', errmsg, re.I):
+ self.fail(_("File can be downloaded by premium users only"))
else:
- self.error(errmsg)
+ self.wantReconnect = True
+ self.retry(wait_time=60, reason=errmsg)
elif hasattr(self, 'WAIT_PATTERN'):
m = re.search(self.WAIT_PATTERN, self.html)
@@ -611,7 +673,7 @@ class SimpleHoster(Hoster):
self.tempOffline()
elif status is 8:
- self.fail(self.info['error'] if 'error' in self.info else "Failed")
+ self.fail(self.info['error'] if 'error' in self.info else _("Failed"))
finally:
self.logDebug("File status: %s" % statusMap[status])
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 5e5d4111f..e8b79c8cd 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -13,7 +13,7 @@ from module.utils import html_unescape
class XFSHoster(SimpleHoster):
__name__ = "XFSHoster"
__type__ = "hoster"
- __version__ = "0.48"
+ __version__ = "0.49"
__pattern__ = r'^unmatchable$'
@@ -79,7 +79,6 @@ class XFSHoster(SimpleHoster):
self.LINK_PATTERN = pattern % self.HOSTER_DOMAIN.replace('.', '\.')
self.captcha = None
- self.errmsg = None
super(XFSHoster, self).prepare()
@@ -149,7 +148,7 @@ class XFSHoster(SimpleHoster):
action, inputs = self.parseHtmlForm('F1')
if not inputs:
- self.retry(reason=self.errmsg or _("TEXTAREA F1 not found"))
+ self.retry(reason=self.info['error'] if 'error' in self.info else _("TEXTAREA F1 not found"))
self.logDebug(inputs)
@@ -178,65 +177,6 @@ class XFSHoster(SimpleHoster):
self.link = header['location']
- def checkErrors(self):
- m = re.search(self.ERROR_PATTERN, self.html)
- if m is None:
- self.errmsg = None
-
- if re.search(self.HAPPY_HOUR_PATTERN, self.html):
- self.multiDL = True
- else:
- self.setup()
-
- else:
- self.errmsg = m.group(1).strip()
-
- self.logWarning(re.sub(r"<.*?>", " ", self.errmsg))
-
- if 'wait' in self.errmsg:
- wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
- re.findall(r'(\d+)\s*(hr|hour|min|sec|)', self.errmsg, re.I))
- self.wait(wait_time, wait_time > 300)
-
- elif 'country' in self.errmsg:
- self.fail(_("Downloads are disabled for your country"))
-
- elif 'captcha' in self.errmsg:
- self.invalidCaptcha()
-
- elif 'premium' in self.errmsg and 'require' in self.errmsg:
- self.fail(_("File can be downloaded by premium users only"))
-
- elif 'limit' in self.errmsg:
- if 'day' in self.errmsg:
- delay = secondsToMidnight(gmt=2)
- retries = 3
- else:
- delay = 1 * 60 * 60
- retries = 24
-
- self.wantReconnect = True
- self.retry(retries, delay, _("Download limit exceeded"))
-
- elif 'countdown' in self.errmsg or 'Expired' in self.errmsg:
- self.retry(reason=_("Link expired"))
-
- elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg:
- self.tempOffline()
-
- elif 'up to' in self.errmsg:
- self.fail(_("File too large for free download"))
-
- else:
- self.wantReconnect = True
- self.retry(wait_time=60, reason=self.errmsg)
-
- if self.errmsg:
- self.info['error'] = self.errmsg
- else:
- self.info.pop('error', None)
-
-
def getPostParameters(self):
if self.FORM_PATTERN or self.FORM_INPUTS_MAP:
action, inputs = self.parseHtmlForm(self.FORM_PATTERN or "", self.FORM_INPUTS_MAP or {})
@@ -246,7 +186,7 @@ class XFSHoster(SimpleHoster):
if not inputs:
action, inputs = self.parseHtmlForm('F1')
if not inputs:
- self.retry(reason=self.errmsg or _("TEXTAREA F1 not found"))
+ self.retry(reason=self.info['error'] if 'error' in self.info else _("TEXTAREA F1 not found"))
self.logDebug(inputs)