summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/internal
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugins/internal')
-rw-r--r--pyload/plugins/internal/CaptchaService.py174
-rw-r--r--pyload/plugins/internal/SimpleHoster.py2
-rw-r--r--pyload/plugins/internal/XFileSharingPro.py80
3 files changed, 186 insertions, 70 deletions
diff --git a/pyload/plugins/internal/CaptchaService.py b/pyload/plugins/internal/CaptchaService.py
index 26482379d..b2fba0652 100644
--- a/pyload/plugins/internal/CaptchaService.py
+++ b/pyload/plugins/internal/CaptchaService.py
@@ -7,96 +7,204 @@ from random import random
class CaptchaService:
__name__ = "CaptchaService"
- __version__ = "0.06"
+ __version__ = "0.09"
- __description__ = """Captcha service plugin"""
+ __description__ = """Base captcha service plugin"""
__author_name__ = "pyLoad Team"
__author_mail__ = "admin@pyload.org"
+ KEY_PATTERN = None
+
+ key = None
+
def __init__(self, plugin):
self.plugin = plugin
-class ReCaptcha:
- RECAPTCHA_KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P<key>\w+)"
- RECAPTCHA_KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P<key>\w+)[\"']\s*,"
+ def detect_key(self, html=None):
+ if not html:
+ if hasattr(self.plugin, "html") and self.plugin.html:
+ html = self.plugin.html
+ else:
+ errmsg = "%s html missing" % self.__name__
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
- recaptcha_key = None
+ m = re.search(self.KEY_PATTERN, html)
+ if m:
+ self.key = m.group("KEY")
+ self.plugin.logDebug("%s key: %s" % (self.__name__, self.key))
+ return self.key
+ else:
+ self.plugin.logDebug("%s key not found" % self.__name__)
+ return None
- def __init__(self, plugin):
- self.plugin = plugin
+ def challenge(self, key=None):
+ raise NotImplementedError
+
+
+ def result(self, server, challenge):
+ raise NotImplementedError
+
+class ReCaptcha(CaptchaService):
+ __name__ = "ReCaptcha"
+ __version__ = "0.02"
- def detect_key(self, html):
- m = re.search(self.RECAPTCHA_KEY_PATTERN, html)
+ __description__ = """ReCaptcha captcha service plugin"""
+ __author_name__ = "pyLoad Team"
+ __author_mail__ = "admin@pyload.org"
+
+
+ KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P<KEY>\w+?)"
+ KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P<KEY>\w+)[\"']\s*,"
+
+
+ def detect_key(self, html=None):
+ if not html:
+ if hasattr(self.plugin, "html") and self.plugin.html:
+ html = self.plugin.html
+ else:
+ errmsg = "ReCaptcha html missing"
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
+
+ m = re.search(self.KEY_PATTERN, html)
if m is None:
- m = re.search(self.RECAPTCHA_KEY_AJAX_PATTERN, html)
+ m = re.search(self.KEY_AJAX_PATTERN, html)
if m:
- self.recaptcha_key = m.group('key')
- return self.recaptcha_key
+ self.key = m.group("KEY")
+ self.plugin.logDebug("ReCaptcha key: %s" % self.key)
+ return self.key
else:
+ self.plugin.logDebug("ReCaptcha key not found")
return None
def challenge(self, key=None):
if not key:
- if self.recaptcha_key:
- key = self.recaptcha_key
+ if self.key:
+ key = self.key
else:
- raise TypeError("ReCaptcha key not found")
+ errmsg = "ReCaptcha key missing"
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
- js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True)
+ js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True)
try:
- challenge = re.search("challenge : '(.*?)',", js).group(1)
- server = re.search("server : '(.*?)',", js).group(1)
+ challenge = re.search("challenge : '(.+?)',", js).group(1)
+ server = re.search("server : '(.+?)',", js).group(1)
except:
- self.plugin.fail("recaptcha error")
+ self.plugin.parseError("ReCaptcha challenge pattern not found")
+
result = self.result(server, challenge)
return challenge, result
def result(self, server, challenge):
- return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge},
+ return self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge},
cookies=True, forceUser=True, imgtype="jpg")
class AdsCaptcha(CaptchaService):
+ __name__ = "AdsCaptcha"
+ __version__ = "0.02"
+
+ __description__ = """AdsCaptcha captcha service plugin"""
+ __author_name__ = "pyLoad Team"
+ __author_mail__ = "admin@pyload.org"
+
- def challenge(self, src):
- js = self.plugin.req.load(src, cookies=True)
+ ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P<ID>\d+)'
+ KEY_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P<KEY>[\w-]+)'
+
+
+ def detect_key(self, html=None):
+ if not html:
+ if hasattr(self.plugin, "html") and self.plugin.html:
+ html = self.plugin.html
+ else:
+ errmsg = "AdsCaptcha html missing"
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
+
+ m = re.search(self.ID_PATTERN, html)
+ n = re.search(self.KEY_PATTERN, html)
+ if m and n:
+ self.key = (m.group("ID"), m.group("KEY"))
+ self.plugin.logDebug("AdsCaptcha id|key: %s | %s" % self.key)
+ return self.key
+ else:
+ self.plugin.logDebug("AdsCaptcha id or key not found")
+ return None
+
+
+ def challenge(self, key=None): #: key is tuple(CaptchaId, PublicKey)
+ if not key:
+ if self.key:
+ key = self.key
+ else:
+ errmsg = "AdsCaptcha key missing"
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
+
+ CaptchaId, PublicKey = key
+
+ js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True)
try:
- challenge = re.search("challenge: '(.*?)',", js).group(1)
- server = re.search("server: '(.*?)',", js).group(1)
+ challenge = re.search("challenge: '(.+?)',", js).group(1)
+ server = re.search("server: '(.+?)',", js).group(1)
except:
- self.plugin.fail("adscaptcha error")
+ self.plugin.parseError("AdsCaptcha challenge pattern not found")
+
result = self.result(server, challenge)
return challenge, result
def result(self, server, challenge):
- return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={"cid": challenge, "dummy": random()},
+ return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random()},
cookies=True, imgtype="jpg")
class SolveMedia(CaptchaService):
+ __name__ = "SolveMedia"
+ __version__ = "0.02"
- def challenge(self, src):
- html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True)
+ __description__ = """SolveMedia captcha service plugin"""
+ __author_name__ = "pyLoad Team"
+ __author_mail__ = "admin@pyload.org"
+
+
+ KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P<KEY>.+?)"'
+
+
+ def challenge(self, key=None):
+ if not key:
+ if self.key:
+ key = self.key
+ else:
+ errmsg = "SolveMedia key missing"
+ self.plugin.fail(errmsg)
+ raise TypeError(errmsg)
+
+ html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True)
try:
challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">',
html).group(1)
+ server = "http://api.solvemedia.com/papi/media"
except:
- self.plugin.fail("solvemedia error")
- result = self.result(challenge)
+ self.plugin.parseError("SolveMedia challenge pattern not found")
+
+ result = self.result(server, challenge)
return challenge, result
- def result(self, challenge):
- return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge, imgtype="gif")
+ def result(self, server, challenge):
+ return self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif")
diff --git a/pyload/plugins/internal/SimpleHoster.py b/pyload/plugins/internal/SimpleHoster.py
index 75c6fc8e8..399430b9f 100644
--- a/pyload/plugins/internal/SimpleHoster.py
+++ b/pyload/plugins/internal/SimpleHoster.py
@@ -176,7 +176,7 @@ class SimpleHoster(Hoster):
example: OFFLINE_PATTERN = r'File (deleted|not found)'
TEMP_OFFLINE_PATTERN: Checks if the file is temporarily offline
- example: TEMP_OFFLINE_PATTERN = r'Server maintainance'
+ example: TEMP_OFFLINE_PATTERN = r'Server (maintenance|maintainance)'
PREMIUM_ONLY_PATTERN: (optional) Checks if the file can be downloaded only with a premium account
example: PREMIUM_ONLY_PATTERN = r'Premium account required'
diff --git a/pyload/plugins/internal/XFileSharingPro.py b/pyload/plugins/internal/XFileSharingPro.py
index 212ef23ef..0dec852d4 100644
--- a/pyload/plugins/internal/XFileSharingPro.py
+++ b/pyload/plugins/internal/XFileSharingPro.py
@@ -21,7 +21,7 @@ class XFileSharingPro(SimpleHoster):
"""
__name__ = "XFileSharingPro"
__type__ = "hoster"
- __version__ = "0.36"
+ __version__ = "0.37"
__pattern__ = r'^unmatchable$'
@@ -40,7 +40,8 @@ class XFileSharingPro(SimpleHoster):
FILE_NAME_PATTERN = r'<input type="hidden" name="fname" value="(?P<N>[^"]+)"'
FILE_SIZE_PATTERN = r'You have requested .*\((?P<S>[\d\.\,]+) ?(?P<U>\w+)?\)</font>'
- OFFLINE_PATTERN = r'>\w+ (Not Found|file (was|has been) removed)'
+ 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>'
@@ -48,11 +49,11 @@ class XFileSharingPro(SimpleHoster):
LINK_PATTERN = None #: final download url pattern
CAPTCHA_URL_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)'
- RECAPTCHA_URL_PATTERN = r'http://[^"\']+?recaptcha[^"\']+?\?k=([^"\']+)"'
- CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.*?)</div>'
- SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"'
+ CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>'
+ RECAPTCHA_PATTERN = None
+ SOLVEMEDIA_PATTERN = None
- ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.*?)</'
+ ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.+?)</'
def setup(self):
@@ -172,7 +173,7 @@ class XFileSharingPro(SimpleHoster):
self.html = self.load(self.pyfile.url, post=self.getPostParameters())
m = re.search(self.LINK_PATTERN, self.html)
if m is None:
- self.parseError('DIRECT LINK')
+ self.parseError('LINK_PATTERN not found')
self.startDownload(m.group(1))
@@ -193,7 +194,7 @@ class XFileSharingPro(SimpleHoster):
action, inputs = self.parseHtmlForm('F1')
if not inputs:
- self.parseError('TEXTAREA')
+ self.parseError('TEXTAREA not found')
self.logDebug(self.HOSTER_NAME, inputs)
if inputs['st'] == 'OK':
self.html = self.load(action, post=inputs)
@@ -205,7 +206,7 @@ class XFileSharingPro(SimpleHoster):
#get easybytez.com link for uploaded file
m = re.search(self.OVR_LINK_PATTERN, self.html)
if m is None:
- self.parseError('DIRECT LINK (OVR)')
+ self.parseError('OVR_LINK_PATTERN not found')
self.pyfile.url = m.group(1)
header = self.load(self.pyfile.url, just_header=True)
if 'location' in header: # Direct link
@@ -317,35 +318,42 @@ class XFileSharingPro(SimpleHoster):
def handleCaptcha(self, inputs):
- m = re.search(self.RECAPTCHA_URL_PATTERN, self.html)
+ m = re.search(self.CAPTCHA_URL_PATTERN, self.html)
if m:
- recaptcha_key = unquote(m.group(1))
- self.logDebug("RECAPTCHA KEY: %s" % recaptcha_key)
- recaptcha = ReCaptcha(self)
- inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key)
+ captcha_url = m.group(1)
+ inputs['code'] = self.decryptCaptcha(captcha_url)
return 1
- else:
- m = re.search(self.CAPTCHA_URL_PATTERN, self.html)
- if m:
- captcha_url = m.group(1)
- inputs['code'] = self.decryptCaptcha(captcha_url)
- return 2
- else:
- m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL)
- if m:
- captcha_div = m.group(1)
- 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", inputs['code'], numerals)
- return 3
- else:
- m = re.search(self.SOLVEMEDIA_PATTERN, self.html)
- if m:
- captcha_key = m.group(1)
- captcha = SolveMedia(self)
- inputs['adcopy_challenge'], inputs['adcopy_response'] = captcha.challenge(captcha_key)
- return 4
+
+ m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL)
+ if m:
+ captcha_div = m.group(1)
+ 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", inputs['code'], numerals)
+ return 2
+
+ recaptcha = ReCaptcha(self)
+ try:
+ captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1)
+ except:
+ captcha_key = recaptcha.detect_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
+
+ solvemedia = SolveMedia(self)
+ try:
+ captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1)
+ except:
+ captcha_key = solvemedia.detect_key()
+
+ if captcha_key:
+ inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key)
+ return 4
+
return 0