(self, pyfile)
| 30 | self.req.setOption("timeout", 300) |
| 31 | |
| 32 | def decrypt(self, pyfile): |
| 33 | retries = 5 |
| 34 | |
| 35 | post_dict = { |
| 36 | 'link_cache': "on", |
| 37 | 'pro_links': pyfile.url, |
| 38 | 'modo_links': "text"} |
| 39 | self.data = self.load('http://linkdecrypter.com/', post=post_dict) |
| 40 | |
| 41 | while retries: |
| 42 | m = re.search(self.TEXTAREA_PATTERN, self.data, re.S) |
| 43 | if m is not None: |
| 44 | self.links = [x for x in m.group( |
| 45 | 1).splitlines() if '[LINK-ERROR]' not in x] |
| 46 | |
| 47 | m = re.search(self.CAPTCHA_PATTERN, self.data) |
| 48 | if m is not None: |
| 49 | captcha_url = 'http://linkdecrypter.com/' + m.group(1) |
| 50 | result_type = "positional" if "getPos" in m.group( |
| 51 | 2) else "textual" |
| 52 | |
| 53 | m = re.search(r'<p><i><b>(.+?)</b></i></p>', self.data) |
| 54 | msg = m.group(1) if m else "" |
| 55 | self.log_info(_("Captcha protected link"), result_type, msg) |
| 56 | |
| 57 | captcha = self.captcha.decrypt( |
| 58 | captcha_url, output_type=result_type) |
| 59 | if result_type == "positional": |
| 60 | captcha = "%d|%d" % captcha |
| 61 | self.data = self.load( |
| 62 | 'http://linkdecrypter.com/', |
| 63 | post={ |
| 64 | 'captcha': captcha}) |
| 65 | retries -= 1 |
| 66 | |
| 67 | elif self.PASSWORD_PATTERN in self.data: |
| 68 | password = self.get_password() |
| 69 | if password: |
| 70 | self.log_info(_("Password protected link")) |
| 71 | self.data = self.load('http://linkdecrypter.com/', |
| 72 | post={'password': password}) |
| 73 | else: |
| 74 | self.fail(_("Missing password")) |
| 75 | |
| 76 | else: |
| 77 | retries -= 1 |
| 78 | self.data = self.load('http://linkdecrypter.com/') |
nothing calls this directly
no test coverage detected