From 93592862b520a862c01f80c019e5c4bc43746c19 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 16:54:20 +0200 Subject: [SimpleHoster] Better inline docs + changed "FILE_OFFLINE_PATTERN" to "OFFLINE_PATTERN" --- module/plugins/hoster/MegasharesCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index b73b4943c..5168b177d 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -40,7 +40,7 @@ class MegasharesCom(SimpleHoster): REACTIVATE_PASSPORT_PATTERN = r']*id="passport_num" value="(\w+)" />' REQUEST_URI_PATTERN = r'var request_uri = "([^"]+)";' NO_SLOTS_PATTERN = r'
All download slots for this link are currently filled' - FILE_OFFLINE_PATTERN = r'
(Invalid Link Request|Link has been deleted)' + OFFLINE_PATTERN = r'
(Invalid Link Request|Link has been deleted)' def setup(self): self.resumeDownload = True -- cgit v1.2.3 From 04038a2cf0c4c2d9cc9a0c8e8bf9beb6426afae8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 10 Jul 2014 03:02:26 +0200 Subject: Use parseError instead PluginParseError + unified all download pattern attributes as LINK_PATTERN + removed some old patterns (not used anymore) + other code cosmetics --- module/plugins/hoster/MegasharesCom.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 5168b177d..ac2752daa 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -31,16 +31,18 @@ class MegasharesCom(SimpleHoster): __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" - FILE_NAME_PATTERN = '

]*title="(?P[^"]+)">' - FILE_SIZE_PATTERN = 'Filesize: (?P[0-9.]+) (?P[kKMG])i?B
' - DOWNLOAD_URL_PATTERN = r'
]*>\s*' + FILE_NAME_PATTERN = r'

]*title="(?P[^"]+)">' + FILE_SIZE_PATTERN = r'Filesize: (?P[0-9.]+) (?P[kKMG])i?B
' + OFFLINE_PATTERN = r'
(Invalid Link Request|Link has been deleted)' + + LINK_PATTERN = r'
All download slots for this link are currently filled' - OFFLINE_PATTERN = r'
(Invalid Link Request|Link has been deleted)' + def setup(self): self.resumeDownload = True @@ -102,7 +104,7 @@ class MegasharesCom(SimpleHoster): def handleDownload(self, premium=False): # Find download link; - found = re.search(self.DOWNLOAD_URL_PATTERN % (1 if premium else 2), self.html) + found = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = '%s download URL' % ('Premium' if premium else 'Free') if not found: self.parseError(msg) -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hoster/MegasharesCom.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index ac2752daa..3284865ce 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: zoidberg """ import re -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hoster/MegasharesCom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 3284865ce..2fde7c0d3 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -56,7 +56,8 @@ 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") + # if self.pyfile.size > 576716800: + # self.fail("This file is too large for free download") # Reactivate passport if needed found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hoster/MegasharesCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 2fde7c0d3..e4d9aff8b 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -88,7 +88,7 @@ class MegasharesCom(SimpleHoster): # Check traffic left on passport found = re.search(self.PASSPORT_LEFT_PATTERN, self.html) - if not found: + if found is None: self.fail('Passport not found') self.logInfo("Download passport: %s" % found.group(1)) data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)] @@ -105,7 +105,7 @@ class MegasharesCom(SimpleHoster): # Find download link; found = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = '%s download URL' % ('Premium' if premium else 'Free') - if not found: + if found is None: self.parseError(msg) download_url = found.group(1) -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/hoster/MegasharesCom.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index e4d9aff8b..f8fa338f3 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -60,9 +60,9 @@ class MegasharesCom(SimpleHoster): # self.fail("This file is too large for free download") # Reactivate passport if needed - found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) - if found: - passport_num = found.group(1) + m = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) + if m: + passport_num = m.group(1) request_uri = re.search(self.REQUEST_URI_PATTERN, self.html).group(1) for _ in xrange(5): @@ -87,28 +87,28 @@ class MegasharesCom(SimpleHoster): self.fail("Failed to reactivate passport") # Check traffic left on passport - found = re.search(self.PASSPORT_LEFT_PATTERN, self.html) - if found is None: + m = re.search(self.PASSPORT_LEFT_PATTERN, self.html) + if m is None: self.fail('Passport not found') - self.logInfo("Download passport: %s" % found.group(1)) - data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)] - self.logInfo("Data left: %s %s (%d MB needed)" % (found.group(2), found.group(3), self.pyfile.size / 1048576)) + self.logInfo("Download passport: %s" % m.group(1)) + data_left = float(m.group(2)) * 1024 ** {'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: - found = re.search(self.PASSPORT_RENEW_PATTERN, self.html) - renew = found.group(1) + found.group(2) + found.group(3) * 60 * 60 if found else 10 * 60 + 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") self.handleDownload(False) def handleDownload(self, premium=False): # Find download link; - found = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) + m = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = '%s download URL' % ('Premium' if premium else 'Free') - if found is None: + if m is None: self.parseError(msg) - download_url = found.group(1) + download_url = m.group(1) self.logDebug("%s: %s" % (msg, download_url)) self.download(download_url) -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/MegasharesCom.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index f8fa338f3..c12897ed0 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -1,30 +1,19 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import re + from time import time + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MegasharesCom(SimpleHoster): __name__ = "MegasharesCom" __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?megashares.com/.*' __version__ = "0.24" + + __pattern__ = r'http://(?:www\.)?megashares.com/.*' + __description__ = """Megashares.com hoster plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" -- cgit v1.2.3