summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-22 01:37:33 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-22 01:37:33 +0100
commite6c7bc85b5a18bef90ea0f3a3c235d3849c28b89 (patch)
treec78b82b0ac3bc2721d4746ebc16aca78a6be8776 /module/plugins
parent[MultiHoster] Fix __name__ (diff)
downloadpyload-e6c7bc85b5a18bef90ea0f3a3c235d3849c28b89.tar.xz
[XFSHoster] Improvements
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/internal/XFSHoster.py71
1 files changed, 37 insertions, 34 deletions
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index d2a771507..0c428c032 100644
--- a/module/plugins/internal/XFSHoster.py
+++ b/module/plugins/internal/XFSHoster.py
@@ -16,7 +16,7 @@ from module.utils import html_unescape
class XFSHoster(SimpleHoster):
__name__ = "XFSHoster"
__type__ = "hoster"
- __version__ = "0.19"
+ __version__ = "0.20"
__pattern__ = r'^unmatchable$'
@@ -35,6 +35,7 @@ class XFSHoster(SimpleHoster):
TEXT_ENCODING = False
COOKIES = [(HOSTER_DOMAIN, "lang", "english")]
CHECK_DIRECT_LINK = None
+ MULTI_HOSTER = False
INFO_PATTERN = r'<tr><td align=right><b>Filename:</b></td><td nowrap>(?P<N>[^<]+)</td></tr>\s*.*?<small>\((?P<S>[^<]+)\)</small>'
NAME_PATTERN = r'(>Filename:</b></td><td nowrap>|name="fname" value="|<span class="name">)(?P<N>.+?)(\s*<|")'
@@ -43,18 +44,18 @@ class XFSHoster(SimpleHoster):
OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)'
TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)'
- WAIT_PATTERN = r'<span id="countdown_str">.*?>(\d+)</span>|id="countdown" value=".*?(\d+).*?"'
+ WAIT_PATTERN = r'<span id="countdown_str">.*?>(\d+)</span>|id="countdown" value=".*?(\d+).*?"'
+ PREMIUM_ONLY_PATTERN = r'>This file is available for Premium Users only'
+ ERROR_PATTERN = r'(?:class=["\']err["\'].*?>|<[Cc]enter><b>|>Error</td></tr>\s*<tr><td align=center>\s*(?:<.+?>)?)(.+?)(?:["\']|</)|>\(ERROR:(.+?)\)'
OVR_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)'
LINK_PATTERN = None #: final download url pattern
- CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)'
+ CAPTCHA_PATTERN = r'(https?://[^"\']+?/captchas?/[^"\']+)'
CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>'
RECAPTCHA_PATTERN = None
SOLVEMEDIA_PATTERN = None
- ERROR_PATTERN = r'(?:class=["\']err["\'][^>]*>|<[Cc]enter><b>)(.+?)(?:["\']|</)|>\(ERROR:(.+?)\)'
-
def setup(self):
self.chunkLimit = 1
@@ -73,23 +74,14 @@ class XFSHoster(SimpleHoster):
pattern = r'(https?://(www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<]'
self.LINK_PATTERN = pattern % self.HOSTER_DOMAIN.replace('.', '\.')
- if self.CHECK_DIRECT_LINK is None:
- self.CHECK_DIRECT_LINK = bool(self.premium)
-
- self.captcha = None
- self.errmsg = None
+ self.captcha = None
+ self.errmsg = None
self.passwords = self.getPassword().splitlines()
- if (self.__pattern__ != self.core.pluginManager.hosterPlugins[self.__name__]['pattern']
- and re.match(self.__pattern__, self.pyfile.url) is None):
- self.logInfo(_("Multi hoster detected"))
- if self.premium:
- self.logDebug(_("Looking for download link..."))
- self.handleOverriden()
- else:
- self.fail(_("Only premium users can use url leech feature"))
+ super(XFSHoster, self).prepare()
- return super(XFSHoster, self).prepare()
+ if self.CHECK_DIRECT_LINK is None:
+ self.directDL = bool(self.premium)
def handleFree(self):
@@ -134,8 +126,11 @@ class XFSHoster(SimpleHoster):
self.req.http.c.setopt(FOLLOWLOCATION, 1)
m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I)
- if m and not "op=" in m.group(1):
- break
+ if m:
+ if 'down_direct' in data and data['down_direct']:
+ break
+ else:
+ self.error(_("Direct download link detected but not found"))
m = re.search(self.LINK_PATTERN, self.html, re.S)
if m:
@@ -149,7 +144,7 @@ class XFSHoster(SimpleHoster):
return m.group(1).strip() #@TODO: Remove .strip() in 0.4.10
- def handleOverriden(self):
+ def handleMulti(self):
#only tested with easybytez.com
self.html = self.load("http://www.%s/" % self.HOSTER_DOMAIN)
@@ -201,12 +196,17 @@ class XFSHoster(SimpleHoster):
header = self.load(m.group(1).strip(), just_header=True, decode=True) #@TODO: Remove .strip() in 0.4.10
if 'location' in header: #: Direct download link
- self.download(header['location'], ref=True, cookies=True, disposition=True)
+ self.link = header['location']
else:
self.fail(_("Download link not found"))
def checkErrors(self):
+ m = re.search(self.PREMIUM_ONLY_PATTERN, self.html)
+ if m:
+ self.info['error'] = "premium-only"
+ return
+
m = re.search(self.ERROR_PATTERN, self.html)
if m is None:
@@ -217,10 +217,13 @@ class XFSHoster(SimpleHoster):
self.logWarning(re.sub(r"<.*?>", " ", self.errmsg))
if 'wait' in self.errmsg:
- wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in
- re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)])
+ wait_time = sum([int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in
+ re.findall(r'(\d+)\s*(hr|hour|min|sec)', self.errmsg, re.I)])
self.wait(wait_time, True)
+ elif 'country' in self.errmsg:
+ self.fail(_("Downloads are disabled for your country"))
+
elif 'captcha' in self.errmsg:
self.invalidCaptcha()
@@ -250,6 +253,11 @@ class XFSHoster(SimpleHoster):
else:
self.retry(wait_time=60, reason=self.errmsg)
+ if self.errmsg:
+ self.info['error'] = self.errmsg
+ else:
+ self.info.pop('error', None)
+
return self.errmsg
@@ -274,31 +282,26 @@ class XFSHoster(SimpleHoster):
if self.passwords:
inputs['password'] = self.passwords.pop(0)
else:
- self.fail(_("No or invalid passport"))
+ self.fail(_("Missing password"))
if not self.premium:
m = re.search(self.WAIT_PATTERN, self.html)
if m:
wait_time = int(m.group(1))
self.setWait(wait_time, False)
- else:
- wait_time = 0
self.captcha = self.handleCaptcha(inputs)
- if wait_time:
- self.wait()
+ self.wait()
else:
inputs['referer'] = self.pyfile.url
if self.premium:
inputs['method_premium'] = "Premium Download"
- if 'method_free' in inputs:
- del inputs['method_free']
+ inputs.pop('method_free', None)
else:
inputs['method_free'] = "Free Download"
- if 'method_premium' in inputs:
- del inputs['method_premium']
+ inputs.pop('method_premium', None)
return inputs