diff options
Diffstat (limited to 'module/plugins/hoster/CzshareCom.py')
-rw-r--r-- | module/plugins/hoster/CzshareCom.py | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index a462deaff..4f581651b 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -1,45 +1,32 @@ # -*- 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 <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -# Test links (random.bin): +# +# Test links: # http://czshare.com/5278880/random.bin import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.utils import parseFileSize class CzshareCom(SimpleHoster): __name__ = "CzshareCom" __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download.php\?).*' __version__ = "0.94" + + __pattern__ = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download.php\?).*' + __description__ = """CZshare.com hoster plugin, now Sdilej.cz""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" FILE_NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=[^>]*>(?P<N>[^<]+)</a>' FILE_SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*(?P<S>[0-9., ]+)(?P<U>[kKMG])i?B\s*</div>' - FILE_OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">' + OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">' FILE_SIZE_REPLACEMENTS = [(' ', '')] FILE_URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://sdilej.cz/\1/x/')] + SH_CHECK_TRAFFIC = True FREE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>' @@ -49,19 +36,20 @@ class CzshareCom(SimpleHoster): MULTIDL_PATTERN = r"<p><font color='red'>Z[^<]*PROFI.</font></p>" USER_CREDIT_PATTERN = r'<div class="credit">\s*kredit: <strong>([0-9., ]+)([kKMG]i?B)</strong>\s*</div><!-- .credit -->' + def checkTrafficLeft(self): # check if user logged in - found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: self.account.relogin(self.user) self.html = self.load(self.pyfile.url, cookies=True, decode=True) - found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: return False # check user credit try: - credit = parseFileSize(found.group(1).replace(' ', ''), found.group(2)) + credit = parseFileSize(m.group(1).replace(' ', ''), m.group(2)) self.logInfo("Premium download for %i KiB of Credit" % (self.pyfile.size / 1024)) self.logInfo("User %s has %i KiB left" % (self.user, credit / 1024)) if credit < self.pyfile.size: @@ -88,10 +76,10 @@ class CzshareCom(SimpleHoster): def handleFree(self): # get free url - found = re.search(self.FREE_URL_PATTERN, self.html) - if found is None: - raise PluginParseError('Free URL') - parsed_url = "http://sdilej.cz" + found.group(1) + m = re.search(self.FREE_URL_PATTERN, self.html) + if m is None: + self.parseError('Free URL') + parsed_url = "http://sdilej.cz" + m.group(1) self.logDebug("PARSED_URL:" + parsed_url) # get download ticket and parse html @@ -105,9 +93,9 @@ class CzshareCom(SimpleHoster): self.pyfile.size = int(inputs['size']) except Exception, e: self.logError(e) - raise PluginParseError('Form') + self.parseError('Form') - # get and decrypt captcha + # get and decrypt captcha captcha_url = 'http://sdilej.cz/captcha.php' for _ in xrange(5): inputs['captchastring2'] = self.decryptCaptcha(captcha_url) @@ -122,16 +110,16 @@ class CzshareCom(SimpleHoster): else: self.fail("No valid captcha code entered") - found = re.search("countdown_number = (\d+);", self.html) - self.setWait(int(found.group(1)) if found else 50) + m = re.search("countdown_number = (\d+);", self.html) + self.setWait(int(m.group(1)) if m else 50) # download the file, destination is determined by pyLoad self.logDebug("WAIT URL", self.req.lastEffectiveURL) - found = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) - if not found: - raise PluginParseError('Download URL') + m = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) + if m is None: + self.parseError('Download URL') - url = "http://%s/download.php?%s" % (found.group(1), found.group(2)) + url = "http://%s/download.php?%s" % (m.group(1), m.group(2)) self.wait() self.download(url) |