(self, pyfile)
| 33 | LINK_PATTERN = r'<div class="highlight redirecturl">(.+?)<' |
| 34 | |
| 35 | def decrypt(self, pyfile): |
| 36 | pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) |
| 37 | |
| 38 | hosters_priority = [_h for _h in self.config.get( |
| 39 | 'hosters_priority').split('|') if _h] |
| 40 | ignored_hosters = [_h for _h in self.config.get( |
| 41 | 'ignored_hosters').split('|') if _h] |
| 42 | |
| 43 | self.data = self.load(pyfile.url) |
| 44 | |
| 45 | m = re.search(self.OFFLINE_PATTERN, self.data) |
| 46 | if m is not None: |
| 47 | self.offline() |
| 48 | |
| 49 | pack_name, pack_folder = self.get_package_info() |
| 50 | |
| 51 | m = re.search( |
| 52 | r'"(/mstat\.php\?uid=%s.+?)"' % |
| 53 | self.info['pattern']['ID'], |
| 54 | self.data) |
| 55 | if m is None: |
| 56 | self.fail("mstat URL not found") |
| 57 | |
| 58 | self.data = self.load(self.fixurl(m.group(1))) |
| 59 | |
| 60 | hosters_data = {} |
| 61 | for _tr in re.findall(r'<tr>(.+?)</tr>', self.data, re.S): |
| 62 | m = re.search( |
| 63 | r'<a href="(/showlink\.php\?uid=%s.+?)".*&hname=(\w+)' % |
| 64 | self.info['pattern']['ID'], _tr, re.S) |
| 65 | if m is not None: |
| 66 | hosters_data[m.group(2)] = m.group(1) |
| 67 | |
| 68 | choosen_hosters = [] |
| 69 | # priority hosters goes first |
| 70 | for _h in hosters_priority: |
| 71 | if _h in hosters_data and _h not in ignored_hosters: |
| 72 | self.log_debug("Adding '%s' link" % _h) |
| 73 | choosen_hosters.append(_h) |
| 74 | if not self.config.get('grab_all'): |
| 75 | break |
| 76 | |
| 77 | # Now the rest of the hosters |
| 78 | if self.config.get('grab_all') or ( |
| 79 | not self.config.get('grab_all') and not choosen_hosters): |
| 80 | for _h in hosters_data: |
| 81 | if _h not in ignored_hosters and _h not in choosen_hosters: |
| 82 | self.log_debug("Adding '%s' link" % _h) |
| 83 | choosen_hosters.append(_h) |
| 84 | if not self.config.get('grab_all'): |
| 85 | break |
| 86 | |
| 87 | pack_links = [ |
| 88 | self.resolve_hoster( |
| 89 | hosters_data[_h]) for _h in choosen_hosters] |
| 90 | |
| 91 | if pack_links: |
| 92 | self.packages.append((pack_name, pack_links, pack_folder)) |
nothing calls this directly
no test coverage detected