summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/internal/SimpleHoster.py3
-rw-r--r--module/plugins/internal/XFSHoster.py35
2 files changed, 22 insertions, 16 deletions
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 80ec2669b..95b52a017 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -19,6 +19,7 @@ from module.utils import fixup, parseFileSize
statusMap = dict((v, k) for k, v in _statusMap.iteritems())
+#@TODO: Remove in 0.4.10 and redirect to self.error instead
def _error(self, reason, type):
if not reason and not type:
type = "unknown"
@@ -479,7 +480,7 @@ class SimpleHoster(Hoster):
self.retry(max_tries=max_tries, reason=_("Download limit reached"))
- def parseHtmlForm(self, attr_str='', input_names={}):
+ def parseHtmlForm(self, attr_str="", input_names={}):
return parseHtmlForm(attr_str, self.html, input_names)
diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py
index 30864ef02..2aaf18b1a 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.24"
+ __version__ = "0.26"
__pattern__ = r'^unmatchable$'
@@ -33,10 +33,10 @@ class XFSHoster(SimpleHoster):
TEXT_ENCODING = False
COOKIES = [(HOSTER_DOMAIN, "lang", "english")]
CHECK_DIRECT_LINK = None
- MULTI_HOSTER = False
+ MULTI_HOSTER = True #@NOTE: Should be default to False for safe, but I'm lazy...
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">|<[Tt]itle>.*?Download )(?P<N>.+?)(\s*<|")'
+ NAME_PATTERN = r'(>Filename:</b></td><td nowrap>|name="fname" value="|<span class="name">)(?P<N>.+?)(\s*<|")'
SIZE_PATTERN = r'(>Size:</b></td><td>|>File:.*>|<span class="size">)(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)'
OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)'
@@ -46,14 +46,17 @@ class XFSHoster(SimpleHoster):
PREMIUM_ONLY_PATTERN = r'>This file is available for Premium Users only'
ERROR_PATTERN = r'(?:class=["\']err["\'].*?>|<[Cc]enter><b>|>Error</td>|>\(ERROR:)(?:\s*<.+?>\s*)*(.+?)(?:["\']|<|\))'
- OVR_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)'
- LINK_PATTERN = None #: final download url pattern
+ LEECH_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)'
+ LINK_PATTERN = None #: final download url pattern
CAPTCHA_PATTERN = r'(https?://[^"\']+?/captchas?/[^"\']+)'
CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>'
RECAPTCHA_PATTERN = None
SOLVEMEDIA_PATTERN = None
+ FORM_PATTERN = None
+ FORM_INPUTS_MAP = None #: dict passed as input_names to parseHtmlForm
+
def setup(self):
self.chunkLimit = 1
@@ -143,7 +146,7 @@ class XFSHoster(SimpleHoster):
#only tested with easybytez.com
self.html = self.load("http://www.%s/" % self.HOSTER_DOMAIN)
- action, inputs = self.parseHtmlForm('')
+ action, inputs = self.parseHtmlForm()
upload_id = "%012d" % int(random() * 10 ** 12)
action += upload_id + "&js_on=1&utype=prem&upload_type=url"
@@ -184,11 +187,11 @@ class XFSHoster(SimpleHoster):
self.fail(stmsg)
#get easybytez.com link for uploaded file
- m = re.search(self.OVR_LINK_PATTERN, self.html)
+ m = re.search(self.LEECH_LINK_PATTERN, self.html)
if m is None:
- self.error(_("OVR_LINK_PATTERN not found"))
+ self.error(_("LEECH_LINK_PATTERN not found"))
- header = self.load(m.group(1).strip(), just_header=True, decode=True) #@TODO: Remove .strip() in 0.4.10
+ header = self.load(m.group(1), just_header=True, decode=True)
if 'location' in header: #: Direct download link
self.link = header['location']
@@ -257,10 +260,10 @@ class XFSHoster(SimpleHoster):
def getPostParameters(self):
- if hasattr(self, "FORM_PATTERN"):
- action, inputs = self.parseHtmlForm(self.FORM_PATTERN)
+ if self.FORM_PATTERN or self.FORM_INPUTS_MAP:
+ action, inputs = self.parseHtmlForm(self.FORM_PATTERN or "", self.FORM_INPUTS_MAP or {})
else:
- action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")})
+ action, inputs = self.parseHtmlForm(input_names={'op': re.compile(r'^download')})
if not inputs:
action, inputs = self.parseHtmlForm('F1')
@@ -311,8 +314,8 @@ class XFSHoster(SimpleHoster):
m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S)
if m:
captcha_div = m.group(1)
+ numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div))
self.logDebug(captcha_div)
- numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div))
inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))])
self.logDebug("Captcha code: %s" % inputs['code'], numerals)
return 2
@@ -322,9 +325,10 @@ class XFSHoster(SimpleHoster):
captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1)
except:
captcha_key = recaptcha.detect_key()
+ else:
+ self.logDebug("ReCaptcha key: %s" % captcha_key)
if captcha_key:
- self.logDebug("ReCaptcha key: %s" % captcha_key)
inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key)
return 3
@@ -333,9 +337,10 @@ class XFSHoster(SimpleHoster):
captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1)
except:
captcha_key = solvemedia.detect_key()
+ else:
+ self.logDebug("SolveMedia key: %s" % captcha_key)
if captcha_key:
- self.logDebug("SolveMedia key: %s" % captcha_key)
inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key)
return 4