diff options
| author | 2014-10-23 00:50:23 +0200 | |
|---|---|---|
| committer | 2014-10-23 00:50:23 +0200 | |
| commit | 7b67f68c1636014fe02286da71bdc6c13dc3eeee (patch) | |
| tree | fce6a94fd3091c6f917acafcc53e71bd08097d5c /module | |
| parent | [XFSPAccount] Better HOSTER_URL (diff) | |
| download | pyload-7b67f68c1636014fe02286da71bdc6c13dc3eeee.tar.xz | |
Simplify captcha challenge calls
Diffstat (limited to 'module')
| -rw-r--r-- | module/plugins/hoster/BitshareCom.py | 6 | ||||
| -rw-r--r-- | module/plugins/hoster/CatShareNet.py | 6 | ||||
| -rw-r--r-- | module/plugins/hoster/CrockoCom.py | 9 | ||||
| -rw-r--r-- | module/plugins/hoster/DateiTo.py | 8 | ||||
| -rw-r--r-- | module/plugins/hoster/FilerNet.py | 7 | ||||
| -rw-r--r-- | module/plugins/hoster/KingfilesNet.py | 8 | ||||
| -rw-r--r-- | module/plugins/hoster/LetitbitNet.py | 7 | ||||
| -rw-r--r-- | module/plugins/hoster/LuckyShareNet.py | 6 | ||||
| -rw-r--r-- | module/plugins/hoster/MediafireCom.py | 7 | ||||
| -rw-r--r-- | module/plugins/hoster/RyushareCom.py | 9 | ||||
| -rw-r--r-- | module/plugins/hoster/TurbobitNet.py | 6 | ||||
| -rw-r--r-- | module/plugins/hoster/UpstoreNet.py | 4 | ||||
| -rw-r--r-- | module/plugins/internal/CaptchaService.py | 6 | 
13 files changed, 17 insertions, 72 deletions
| diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 9d2a23625..fe2ff0be6 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -113,14 +113,10 @@ class BitshareCom(SimpleHoster):          if captcha == 1:              self.logDebug("File is captcha protected")              recaptcha = ReCaptcha(self) -            captcha_key = recaptcha.detect_key() -            if captcha_key is None: -                self.error("ReCaptcha captcha key not found")              # Try up to 3 times              for i in xrange(3): -                self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (captcha_key, i + 1)) -                challenge, code = recaptcha.challenge(captcha_key) +                challenge, code = recaptcha.challenge()                  response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",                                       post={"request": "validateCaptcha", "ajaxid": self.ajaxid,                                             "recaptcha_challenge_field": challenge, "recaptcha_response_field": code}) diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py index 9a7824659..315ec712b 100644 --- a/module/plugins/hoster/CatShareNet.py +++ b/module/plugins/hoster/CatShareNet.py @@ -50,11 +50,7 @@ class CatShareNet(SimpleHoster):          recaptcha = ReCaptcha(self) -        captcha_key = recaptcha.detect_key() -        if captcha_key is None: -            self.error("ReCaptcha key not found") - -        challenge, code = recaptcha.challenge(captcha_key) +        challenge, code = recaptcha.challenge()          self.html = self.load(self.pyfile.url,                                post={'recaptcha_challenge_field': challenge,                                      'recaptcha_response_field': code}) diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 15bf25ad2..00b102258 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -43,19 +43,16 @@ class CrockoCom(SimpleHoster):              else:                  break -        recaptcha = ReCaptcha(self) -        captcha_key = recaptcha.detect_key() -        if captcha_key is None: -            self.error("ReCaptcha captcha key not found") -          m = re.search(self.FORM_PATTERN, self.html, re.DOTALL)          if m is None:              self.error('ACTION') +          action, form = m.groups()          inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) +        recaptcha = ReCaptcha(self)          for _ in xrange(5): -            inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) +            inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge()              self.download(action, post=inputs)              check = self.checkDownload({ diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 93840b108..07033a203 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -30,7 +30,6 @@ class DateiTo(SimpleHoster):      def handleFree(self):          url = 'http://datei.to/ajax/download.php'          data = {'P': 'I', 'ID': self.file_info['ID']} -          recaptcha = ReCaptcha(self)          for _ in xrange(10): @@ -52,12 +51,7 @@ class DateiTo(SimpleHoster):              data = dict(x.split('=') for x in m.group(2).split('&'))              if url.endswith('recaptcha.php'): -                captcha_key = recaptcha.detect_key() -                if captcha_key is None: -                    self.error("ReCaptcha key not found") - -                data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge(captcha_key) - +                data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge()          else:              self.fail('Too bad...') diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index 7a8d49378..e02f5a37c 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -54,15 +54,10 @@ class FilerNet(SimpleHoster):          self.logDebug("Hash: " + hash_data)          downloadURL = r'' -          recaptcha = ReCaptcha(self) -        captcha_key = recaptcha.detect_key() -        if captcha_key is None: -            self.parseError("ReCaptcha key not found") -          for _ in xrange(5): -            challenge, response = recaptcha.challenge(captcha_key) +            challenge, response = recaptcha.challenge()              post_data = {'recaptcha_challenge_field': challenge,                           'recaptcha_response_field': response,                           'hash': hash_data} diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index 7211aa378..223241f5a 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -45,13 +45,7 @@ class KingfilesNet(SimpleHoster):          b = self.load(self.pyfile.url, post=post_data, cookies=True, decode=True)          solvemedia = SolveMedia(self) - -        captcha_key = solvemedia.detect_key() -        if captcha_key is None: -            self.error("SolveMedia key not found") - -        self.logDebug("captcha_key", captcha_key) -        captcha_challenge, captcha_response = solvemedia.challenge(captcha_key) +        captcha_challenge, captcha_response = solvemedia.challenge()          # Make the downloadlink appear and load the file          m = re.search(self.RAND_ID_PATTERN, b) diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 002c986e2..9357cc758 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -110,12 +110,7 @@ class LetitbitNet(SimpleHoster):          self.logDebug(response)          recaptcha = ReCaptcha(self) - -        captcha_key = recaptcha.detect_key() -        if captcha_key is None: -            self.error("ReCaptcha key not found") - -        challenge, response = recaptcha.challenge(captcha_key) +        challenge, response = recaptcha.challenge()          post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response,                       "recaptcha_control_field": recaptcha_control_field} diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 4a4d4a047..5e1b6bf60 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -52,12 +52,8 @@ class LuckyShareNet(SimpleHoster):          recaptcha = ReCaptcha(self) -        captcha_key = recaptcha.detect_key() -        if captcha_key is None: -            self.error("ReCaptcha key not found") -          for _ in xrange(5): -            challenge, response = recaptcha.challenge(captcha_key) +            challenge, response = recaptcha.challenge()              rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" %                              (challenge, response, json['hash']), decode=True)              self.logDebug("JSON: " + rep) diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 31b85b433..20ca6753d 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -116,11 +116,6 @@ class MediafireCom(SimpleHoster):      def checkCaptcha(self):          solvemedia = SolveMedia(self) - -        captcha_key = solvemedia.detect_key() -        if captcha_key is None: -            self.error("SolveMedia key not found") - -        captcha_challenge, captcha_response = solvemedia.challenge(captcha_key) +        captcha_challenge, captcha_response = solvemedia.challenge()          self.html = self.load(self.url, post={"adcopy_challenge": captcha_challenge,                                                "adcopy_response": captcha_response}, decode=True) diff --git a/module/plugins/hoster/RyushareCom.py b/module/plugins/hoster/RyushareCom.py index cd77ac4a6..1acc1fd58 100644 --- a/module/plugins/hoster/RyushareCom.py +++ b/module/plugins/hoster/RyushareCom.py @@ -59,13 +59,8 @@ class RyushareCom(XFSPHoster):              self.retry()          for _ in xrange(5): -            captcha = SolveMedia(self) - -            captcha_key = captcha.detect_key() -            if captcha_key is None: -                self.error("SolveMedia key not found") - -            challenge, response = captcha.challenge(captcha_key) +            solvemedia = SolveMedia(self) +            challenge, response = solvemedia.challenge()              inputs['adcopy_challenge'] = challenge              inputs['adcopy_response'] = response diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index ded926010..d0b441fa2 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -72,11 +72,7 @@ class TurbobitNet(SimpleHoster):              if inputs['captcha_type'] == 'recaptcha':                  recaptcha = ReCaptcha(self) -                captcha_key = recaptcha.detect_key() -                if captcha_key is None: -                    self.error("ReCaptcha captcha key not found") - -                inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) +                inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge()              else:                  m = re.search(self.CAPTCHA_PATTERN, self.html)                  if m is None: diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 257a186eb..2e500dc01 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -40,9 +40,7 @@ class UpstoreNet(SimpleHoster):          # STAGE 2: solv captcha and wait          # first get the infos we need: recaptcha key and wait time          recaptcha = ReCaptcha(self) -        if recaptcha.detect_key() is None: -            self.error("ReCaptcha key not found") -        self.logDebug("Using captcha key " + recaptcha.key) +          # try the captcha 5 times          for i in xrange(5):              m = re.search(self.WAIT_PATTERN, self.html) diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 11b34755b..a1ec633e8 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -29,7 +29,7 @@ class CaptchaService:                  html = self.plugin.html              else:                  errmsg = "%s html not found" % self.__name__ -                self.plugin.fail(errmsg) +                self.plugin.fail(errmsg)  #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10                  raise TypeError(errmsg)          m = re.search(self.KEY_PATTERN, html) @@ -72,9 +72,7 @@ class ReCaptcha(CaptchaService):                  self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        m = re.search(self.KEY_PATTERN, html) -        if m is None: -            m = re.search(self.KEY_AJAX_PATTERN, html) +        m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html)          if m:              self.key = m.group("KEY")              self.plugin.logDebug("ReCaptcha key: %s" % self.key) | 
