diff options
author | igel-kun <mathiaswe@gmx.de> | 2014-10-05 17:32:38 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-10-05 17:32:38 +0200 |
commit | 4fd7c36b3d0cda16fb68baa378169ad8094ba62e (patch) | |
tree | ba643f21d05623cd40c69af38eedf067499074cf /module | |
parent | Fix pillow import header (diff) | |
download | pyload-4fd7c36b3d0cda16fb68baa378169ad8094ba62e.tar.xz |
[MegasharesCom] Update patterns
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hoster/MegasharesCom.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index c12897ed0..3b6f29536 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -10,21 +10,23 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MegasharesCom(SimpleHoster): __name__ = "MegasharesCom" __type__ = "hoster" - __version__ = "0.24" + __version__ = "0.25" - __pattern__ = r'http://(?:www\.)?megashares.com/.*' + __pattern__ = r'http://(?:www\.)?(d\d{2}\.)?megashares\.com/((index.php)?\?d\d{2}=|dl/)\w+' __description__ = """Megashares.com hoster plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + FILE_NAME_PATTERN = r'<h1 class="black xxl"[^>]*title="(?P<N>[^"]+)">' - FILE_SIZE_PATTERN = r'<strong><span class="black">Filesize:</span></strong> (?P<S>[0-9.]+) (?P<U>[kKMG])i?B<br />' - OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted)' + FILE_SIZE_PATTERN = r'<strong><span class="black">Filesize:</span></strong> (?P<S>[\d.]+) (?P<U>\w+)' + OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted|Invalid link)' LINK_PATTERN = r'<div id="show_download_button_%d"[^>]*>\s*<a href="([^"]+)">' - PASSPORT_LEFT_PATTERN = r'Your Download Passport is: <[^>]*>(\w+).*\s*You have\s*<[^>]*>\s*([0-9.]+) ([kKMG]i?B)' - PASSPORT_RENEW_PATTERN = r'Your download passport will renew in\s*<strong>(\d+)</strong>:<strong>(\d+)</strong>:<strong>(\d+)</strong>' + + PASSPORT_LEFT_PATTERN = r'Your Download Passport is: <[^>]*>(\w+).*?You have.*?<[^>]*>.*?([\d.]+) (\w+)' + PASSPORT_RENEW_PATTERN = r'Your download passport will renew(?:.|\n)*?(\d+).*?(\d+).*?(\d+)' REACTIVATE_NUM_PATTERN = r'<input[^>]*id="random_num" value="(\d+)" />' REACTIVATE_PASSPORT_PATTERN = r'<input[^>]*id="passport_num" value="(\w+)" />' REQUEST_URI_PATTERN = r'var request_uri = "([^"]+)";' @@ -35,9 +37,11 @@ class MegasharesCom(SimpleHoster): self.resumeDownload = True self.multiDL = self.premium + def handlePremium(self): self.handleDownload(True) + def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) @@ -45,10 +49,7 @@ class MegasharesCom(SimpleHoster): self.retry(wait_time=5 * 60) self.getFileInfo() - # if self.pyfile.size > 576716800: - # self.fail("This file is too large for free download") - # Reactivate passport if needed m = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) if m: passport_num = m.group(1) @@ -76,20 +77,22 @@ class MegasharesCom(SimpleHoster): self.fail("Failed to reactivate passport") # Check traffic left on passport - m = re.search(self.PASSPORT_LEFT_PATTERN, self.html) + m = re.search(self.PASSPORT_LEFT_PATTERN, self.html, re.M | re.S) if m is None: self.fail('Passport not found') self.logInfo("Download passport: %s" % m.group(1)) - data_left = float(m.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[m.group(3)] + data_left = float(m.group(2)) * 1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[m.group(3)] self.logInfo("Data left: %s %s (%d MB needed)" % (m.group(2), m.group(3), self.pyfile.size / 1048576)) if not data_left: m = re.search(self.PASSPORT_RENEW_PATTERN, self.html) - renew = m.group(1) + m.group(2) + m.group(3) * 60 * 60 if m else 10 * 60 - self.retry(max_tries=15, wait_time=renew, reason="Unable to get passport") + renew = int(m.group(1) + 60 * (m.group(2) + 60 * m.group(3))) if found else 600 + self.logDebug('Waiting %d seconds for a new passport' % renew) + self.retry(wait_time=renew, reason="Passport renewal") self.handleDownload(False) + def handleDownload(self, premium=False): # Find download link; m = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) |