(self, pyfile)
| 34 | LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'href="([^"]+)">Get download</a>' |
| 35 | |
| 36 | def handle_free(self, pyfile): |
| 37 | inputs = self.parse_html_form(input_names={'token': re.compile(r'.+')})[1] |
| 38 | if inputs is None or 'token' not in inputs: |
| 39 | self.retry() |
| 40 | |
| 41 | self.data = self.load(pyfile.url, post={'token': inputs['token']}) |
| 42 | |
| 43 | inputs = self.parse_html_form(input_names={'hash': re.compile(r'.+')})[1] |
| 44 | if inputs is None or 'hash' not in inputs: |
| 45 | self.error(_("Unable to detect hash")) |
| 46 | |
| 47 | self.captcha = ReCaptcha(pyfile) |
| 48 | response, challenge = self.captcha.challenge() |
| 49 | |
| 50 | #: Avoid 'Correct catcha' |
| 51 | captcha_task = self.captcha.task |
| 52 | self.captcha.task = None |
| 53 | |
| 54 | self.download(pyfile.url, |
| 55 | post={'g-recaptcha-response': response, |
| 56 | 'hash': inputs['hash']}) |
| 57 | |
| 58 | #: Restore the captcha task |
| 59 | self.captcha.task = captcha_task |
| 60 | |
| 61 | if self.scan_download({'html': re.compile(r'\A\s*<!DOCTYPE html')}) == "html": |
| 62 | self.log_warning( |
| 63 | _("There was HTML code in the downloaded file (%s)...bad captcha? The download will be restarted." % |
| 64 | self.pyfile.name)) |
| 65 | os.remove(self.last_download) |
| 66 | self.retry_captcha() |
| 67 | |
| 68 | else: |
| 69 | self.captcha.correct() |
nothing calls this directly
no test coverage detected