(self, pyfile)
| 38 | COOKIES = [("upstore.net", "lang", "en")] |
| 39 | |
| 40 | def handle_free(self, pyfile): |
| 41 | #: STAGE 1: get link to continue |
| 42 | post_data = {'hash': self.info['pattern']['ID'], |
| 43 | 'free': 'Slow download'} |
| 44 | self.data = self.load(pyfile.url, post=post_data) |
| 45 | |
| 46 | #: STAGE 2: solve captcha and wait |
| 47 | #: First get the infos we need: self.captcha key and wait time |
| 48 | m = re.search(self.WAIT_PATTERN, self.data) |
| 49 | if m is None: |
| 50 | self.error(_("Wait pattern not found")) |
| 51 | |
| 52 | #: prepare the waiting |
| 53 | wait_time = int(m.group(1)) |
| 54 | self.set_wait(wait_time) |
| 55 | |
| 56 | #: then, handle the captcha |
| 57 | recaptcha = ReCaptcha(self.pyfile) |
| 58 | |
| 59 | captcha_key = recaptcha.detect_key() |
| 60 | if captcha_key is None: |
| 61 | self.fail(_("captcha key not found")) |
| 62 | |
| 63 | self.captcha = recaptcha |
| 64 | |
| 65 | post_data = {'hash': self.info['pattern']['ID'], |
| 66 | 'free': 'Get download link'} |
| 67 | post_data['g-recaptcha-response'], _ = recaptcha.challenge(captcha_key) |
| 68 | |
| 69 | #: then, do the waiting |
| 70 | self.wait() |
| 71 | |
| 72 | self.data = self.load(pyfile.url, post=post_data) |
| 73 | |
| 74 | # check whether the captcha was wrong |
| 75 | if "Captcha check failed" in self.data: |
| 76 | self.captcha.invalid() |
| 77 | |
| 78 | else: |
| 79 | self.captcha.correct() |
| 80 | |
| 81 | # STAGE 3: get direct link or wait time |
| 82 | self.check_errors() |
| 83 | |
| 84 | m = re.search(self.LINK_FREE_PATTERN, self.data) |
| 85 | if m is not None: |
| 86 | self.link = m.group(1) |
nothing calls this directly
no test coverage detected