From 1bcdfb409ded0c369735c413b33f2e344b36bd7a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 1 Dec 2014 20:00:14 +0100 Subject: Fixes --- module/plugins/hoster/Keep2shareCc.py | 25 +++++++++++-------------- module/plugins/internal/SimpleHoster.py | 4 ++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index a374cc481..7ca29701a 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -36,24 +36,21 @@ class Keep2shareCc(SimpleHoster): CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' - ERROR_BLOCK_PATTERN = r'Downloading is not possible
.+?' - TEMP_ERROR_PATTERN = r'Download count files exceed|Traffic limit exceed|Free account does not allow to download more than one file at the same time' - ERROR_PATTERN = r'Free user can\'t download large files|You no can access to this file|This download available only for premium users|This is private file' + TEMP_ERROR_PATTERN = r'>\s*(Download count files exceed|Traffic limit exceed|Free account does not allow to download more than one file at the same time)' + ERROR_PATTERN = r'>\s*(Free user can\'t download large files|You no can access to this file|This download available only for premium users|This is private file)' def checkErrors(self): - m = re.search(self.ERROR_BLOCK_PATTERN, self.html, re.S) + m = re.search(self.TEMP_ERROR_PATTERN, self.html) if m: - e = self.info['error'] = m.group(0) - - m = re.search(self.TEMP_ERROR_PATTERN, self.html) - if m: - self.wantReconnect = True - self.retry(wait_time=30 * 60, reason=m.group(0)) + self.info['error'] = m.group(1) + self.wantReconnect = True + self.retry(wait_time=30 * 60, reason=m.group(0)) - m = re.search(self.ERROR_PATTERN, self.html) - if m: - self.error(e) + m = re.search(self.ERROR_PATTERN, self.html) + if m: + e = self.info['error'] = m.group(1) + self.error(e) m = re.search(self.WAIT_PATTERN, self.html) if m: @@ -131,7 +128,7 @@ class Keep2shareCc(SimpleHoster): def _getDownloadLink(self, url): p = urlparse(self.pyfile.url) base = "%s://%s" % (p.scheme, p.netloc) - link = _isDirectLink(url) + link = _isDirectLink(self, url, self.premium) return urljoin(base, link) if link else "" diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 736d15f3a..cf03a1242 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -123,7 +123,7 @@ def _isDirectLink(self, url, resumable=True): location = header['location'] if resumable: #: sometimes http code may be wrong... - if self.load(location, ref=True, cookies=True, just_header=True, decode=True)['location']: + if 'location' in self.load(location, ref=True, cookies=True, just_header=True, decode=True): return "" else: if not 'code' in header or header['code'] != 302: @@ -388,7 +388,7 @@ class SimpleHoster(Hoster): self.checkFile() - def checkFile(self) + def checkFile(self): if self.checkDownload({'empty': re.compile(r"^$")}) is "empty": #@TODO: Move to hoster in 0.4.10 self.fail(_("Empty file")) -- cgit v1.2.3