From 0c079cd625a835279f3b319e7c64e23fa39f3385 Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 10 Apr 2014 14:57:46 +0200 Subject: Upstore: using the improved ReCaptcha class (cherry picked from commit 5c8ab19be496ad3cda7e3fed5a5dc678a9272cd6) --- module/plugins/hoster/UpstoreNet.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index d2b3e0529..9d1c4b3dd 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -9,7 +9,7 @@ class UpstoreNet(SimpleHoster): __name__ = "UpstoreNet" __type__ = "hoster" __pattern__ = r"https?://(?:www\.)?upstore\.net/" - __version__ = "0.01" + __version__ = "0.02" __description__ = """Upstore.Net File Download Hoster""" __author_name__ = ("igel") @@ -17,7 +17,6 @@ class UpstoreNet(SimpleHoster): FILE_OFFLINE_PATTERN = r'File not found' WAIT_PATTERN = r"var sec = (\d+)" - RECAPTCHA_PATTERN = r"Recaptcha.create.*?'(.*?)'" CHASH_PATTERN = r'' DIRECT_LINK_PATTERN = r'' @@ -32,30 +31,27 @@ class UpstoreNet(SimpleHoster): post_data = {'hash': chash, 'free': 'Slow download'} self.html = self.load(self.pyfile.url, post=post_data, decode=True) + # STAGE 2: solv captcha and wait + # first get the infos we need: recaptcha key and wait time + recaptcha = ReCaptcha(self) + if not recaptcha.detect_key(self.html): + self.parseError("could not find recaptcha pattern") + self.logDebug("using captcha key " + recaptcha.recaptcha_key) # try the captcha 5 times for i in xrange(5): - # STAGE 2: solv captcha and wait - # first get the infos we need: recaptcha key and wait time - m = re.search(self.RECAPTCHA_PATTERN, self.html) - if not m: - self.parseError("could not find recaptcha pattern") - recaptcha_key = m.group(1) - self.logDebug("using captcha key " + recaptcha_key) - recaptcha = ReCaptcha(self) - m = re.search(self.WAIT_PATTERN, self.html) if not m: self.parseError("could not find wait pattern") wait_time = m.group(1) + # then, do the waiting + self.wait(wait_time) + # then, handle the captcha - challenge, code = recaptcha.challenge(recaptcha_key) + challenge, code = recaptcha.challenge() post_data['recaptcha_challenge_field'] = challenge post_data['recaptcha_response_field'] = code - # then, do the waiting - self.wait(wait_time) - self.html = self.load(self.pyfile.url, post=post_data, decode=True) # STAGE 3: get direct link -- cgit v1.2.3