MCPcopy
hub / github.com/pyload/pyload / handle_free

Method handle_free

module/plugins/hoster/FilerNet.py:36–69  ·  view source on GitHub ↗
(self, pyfile)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 14

ReCaptchaClass · 0.90
parse_html_formMethod · 0.80
compileMethod · 0.80
scan_downloadMethod · 0.80
log_warningMethod · 0.80
_Function · 0.50
retryMethod · 0.45
loadMethod · 0.45
errorMethod · 0.45
challengeMethod · 0.45
downloadMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected