From 5fe85e1ec8dd4d54d55491d26a5c41a0bde38176 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 22:21:51 +0100 Subject: [Keep2shareCc] Fix file name --- module/plugins/hoster/Keep2shareCc.py | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 module/plugins/hoster/Keep2shareCc.py (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py new file mode 100644 index 000000000..6791998e2 --- /dev/null +++ b/module/plugins/hoster/Keep2shareCc.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urlparse, urljoin + +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class Keep2shareCc(SimpleHoster): + __name__ = "Keep2shareCc" + __type__ = "hoster" + __version__ = "0.14" + + __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P\w+)' + + __description__ = """Keep2share.cc hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'File: (?P.+)' + SIZE_PATTERN = r'Size: (?P[^<]+)' + OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' + + LINK_PATTERN = r'To download this file with slow speed, use this link' + CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' + WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' + MULTIDL_ERROR = r'Free account does not allow to download more than one file at the same time' + + + def handleFree(self): + self.sanitize_url() + self.html = self.load(self.pyfile.url) + + self.fid = re.search(r'', self.html).group(1) + self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) + + m = re.search(r"function download\(\){.*window\.location\.href = '([^']+)';", self.html, re.S) + if m: # Direct mode + self.startDownload(m.group(1)) + else: + self.handleCaptcha() + + self.wait(30) + + self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.logDebug("Hoster told us to wait for %s" % m.group(1)) + # string to time convert courtesy of https://stackoverflow.com/questions/10663720 + ftr = [3600, 60, 1] + wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) + self.wait(wait_time, True) + self.retry() + + m = re.search(self.MULTIDL_ERROR, self.html) + if m: + # if someone is already downloading on our line, wait 30min and retry + self.logDebug("Already downloading, waiting for 30 minutes") + self.wait(30 * 60, True) + self.retry() + + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + self.startDownload(m.group(1)) + + + def handleCaptcha(self): + recaptcha = ReCaptcha(self) + + for _i in xrange(5): + post_data = {'free': 1, + 'freeDownloadRequest': 1, + 'uniqueId': self.fid, + 'yt0': ''} + + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + captcha_url = urljoin(self.base_url, m.group(1)) + post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) + else: + challenge, response = recaptcha.challenge() + post_data.update({'recaptcha_challenge_field': challenge, + 'recaptcha_response_field': response}) + + self.html = self.load(self.pyfile.url, post=post_data) + + if 'recaptcha' not in self.html: + self.correctCaptcha() + break + else: + self.invalidCaptcha() + else: + self.fail(_("All captcha attempts failed")) + + + def startDownload(self, url): + d = urljoin(self.base_url, url) + self.logDebug("Direct Link: " + d) + self.download(d, disposition=True) + + + def sanitize_url(self): + header = self.load(self.pyfile.url, just_header=True) + if 'location' in header: + self.pyfile.url = header['location'] + p = urlparse(self.pyfile.url) + self.base_url = "%s://%s" % (p.scheme, p.hostname) + + +getInfo = create_getInfo(Keep2shareCc) -- cgit v1.2.3 From a9c7ba9de005a5167fca2ccf8067fbd4e6086fb2 Mon Sep 17 00:00:00 2001 From: z00nx 0 Date: Mon, 10 Nov 2014 23:07:22 +0100 Subject: [Keep2shareCc] Added handling of large file error for free users --- module/plugins/hoster/Keep2shareCc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index 6791998e2..fd8a5524d 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class Keep2shareCc(SimpleHoster): __name__ = "Keep2shareCc" __type__ = "hoster" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P\w+)' @@ -38,6 +38,9 @@ class Keep2shareCc(SimpleHoster): self.fid = re.search(r'', self.html).group(1) self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) + if ">Downloading is not possible" in self.html: + self.fail("Free user can't download large files") + m = re.search(r"function download\(\){.*window\.location\.href = '([^']+)';", self.html, re.S) if m: # Direct mode self.startDownload(m.group(1)) @@ -101,7 +104,6 @@ class Keep2shareCc(SimpleHoster): def startDownload(self, url): d = urljoin(self.base_url, url) - self.logDebug("Direct Link: " + d) self.download(d, disposition=True) -- cgit v1.2.3 From d66784d79ab5159e2480b89056dbf9dadae5a6b7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 1 Dec 2014 18:17:57 +0100 Subject: [Keep2shareCc] Rewrite hoster --- module/plugins/hoster/Keep2shareCc.py | 120 ++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 50 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index fd8a5524d..a374cc481 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -2,16 +2,16 @@ import re -from urlparse import urlparse, urljoin +from urlparse import urljoin, urlparse from module.plugins.internal.CaptchaService import ReCaptcha -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.SimpleHoster import _isDirectLink, SimpleHoster, create_getInfo class Keep2shareCc(SimpleHoster): __name__ = "Keep2shareCc" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P\w+)' @@ -21,75 +21,101 @@ class Keep2shareCc(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://k2s.cc/file/\g")] + + CONTENT_DISPOSITION = True + NAME_PATTERN = r'File: (?P.+)' SIZE_PATTERN = r'Size: (?P[^<]+)' - OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' - LINK_PATTERN = r'To download this file with slow speed, use this link' + OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' + TEMP_OFFLINE_PATTERN = r'Downloading blocked due to' + + LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'"([^"]+url.html?file=.+?)"|window\.location\.href = \'(.+?)\';' + CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' - WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' - MULTIDL_ERROR = r'Free account does not allow to download more than one file at the same time' + 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' - def handleFree(self): - self.sanitize_url() - self.html = self.load(self.pyfile.url) - self.fid = re.search(r'', self.html).group(1) + def checkErrors(self): + m = re.search(self.ERROR_BLOCK_PATTERN, self.html, re.S) + 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)) + + m = re.search(self.ERROR_PATTERN, self.html) + if m: + self.error(e) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.logDebug("Hoster told us to wait for %s" % m.group(1)) + + # string to time convert courtesy of https://stackoverflow.com/questions/10663720 + ftr = [3600, 60, 1] + wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) + + self.wantReconnect = True + self.retry(wait_time=wait_time, reason="Please wait to download this file") + + self.info.pop('error', None) + + + def handleFree(self): + self.fid = re.search(r'', self.html).group(1) self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) - if ">Downloading is not possible" in self.html: - self.fail("Free user can't download large files") + self.checkErrors() - m = re.search(r"function download\(\){.*window\.location\.href = '([^']+)';", self.html, re.S) - if m: # Direct mode - self.startDownload(m.group(1)) - else: + m = re.search(self.LINK_FREE_PATTERN, self.html) + + if m is None: self.handleCaptcha() self.wait(30) self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) - m = re.search(self.WAIT_PATTERN, self.html) - if m: - self.logDebug("Hoster told us to wait for %s" % m.group(1)) - # string to time convert courtesy of https://stackoverflow.com/questions/10663720 - ftr = [3600, 60, 1] - wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) - self.wait(wait_time, True) - self.retry() - - m = re.search(self.MULTIDL_ERROR, self.html) - if m: - # if someone is already downloading on our line, wait 30min and retry - self.logDebug("Already downloading, waiting for 30 minutes") - self.wait(30 * 60, True) - self.retry() + self.checkErrors() - m = re.search(self.LINK_PATTERN, self.html) + m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("LINK_PATTERN not found")) - self.startDownload(m.group(1)) + self.error(_("LINK_FREE_PATTERN not found")) + + self.link = self._getDownloadLink(m.group(1)) + + + def handlePremium(self): + super(Keep2shareCc, self).handlePremium() + if self.link: + self.link = self._getDownloadLink(self.link) def handleCaptcha(self): recaptcha = ReCaptcha(self) for _i in xrange(5): - post_data = {'free': 1, + post_data = {'free' : 1, 'freeDownloadRequest': 1, - 'uniqueId': self.fid, - 'yt0': ''} + 'uniqueId' : self.fid, + 'yt0' : ''} m = re.search(self.CAPTCHA_PATTERN, self.html) if m: - captcha_url = urljoin(self.base_url, m.group(1)) + captcha_url = urljoin(self.base, m.group(1)) post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) else: challenge, response = recaptcha.challenge() post_data.update({'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response}) + 'recaptcha_response_field' : response}) self.html = self.load(self.pyfile.url, post=post_data) @@ -102,17 +128,11 @@ class Keep2shareCc(SimpleHoster): self.fail(_("All captcha attempts failed")) - def startDownload(self, url): - d = urljoin(self.base_url, url) - self.download(d, disposition=True) - - - def sanitize_url(self): - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: - self.pyfile.url = header['location'] + def _getDownloadLink(self, url): p = urlparse(self.pyfile.url) - self.base_url = "%s://%s" % (p.scheme, p.hostname) + base = "%s://%s" % (p.scheme, p.netloc) + link = _isDirectLink(url) + return urljoin(base, link) if link else "" getInfo = create_getInfo(Keep2shareCc) -- cgit v1.2.3 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 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') 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 "" -- cgit v1.2.3 From 5a23de6f32dc99960cccd634d2fd2cc47c34be2a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 5 Dec 2014 23:08:44 +0100 Subject: Code cosmetics about checkErrors --- module/plugins/hoster/Keep2shareCc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index 7ca29701a..cb5e65a29 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -49,8 +49,8 @@ class Keep2shareCc(SimpleHoster): m = re.search(self.ERROR_PATTERN, self.html) if m: - e = self.info['error'] = m.group(1) - self.error(e) + errmsg = self.info['error'] = m.group(1) + self.error(errmsg) m = re.search(self.WAIT_PATTERN, self.html) if m: -- cgit v1.2.3 From 430092f0ba67e4bb2dd75433b08340d0afca0fa9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 12 Dec 2014 20:34:42 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/hoster/Keep2shareCc.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index cb5e65a29..d98fa3c09 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import _isDirectLink, SimpleHoster, cr class Keep2shareCc(SimpleHoster): __name__ = "Keep2shareCc" __type__ = "hoster" - __version__ = "0.16" + __version__ = "0.17" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P\w+)' @@ -23,8 +23,6 @@ class Keep2shareCc(SimpleHoster): URL_REPLACEMENTS = [(__pattern__ + ".*", "http://k2s.cc/file/\g")] - CONTENT_DISPOSITION = True - NAME_PATTERN = r'File: (?P.+)' SIZE_PATTERN = r'Size: (?P[^<]+)' @@ -87,13 +85,7 @@ class Keep2shareCc(SimpleHoster): if m is None: self.error(_("LINK_FREE_PATTERN not found")) - self.link = self._getDownloadLink(m.group(1)) - - - def handlePremium(self): - super(Keep2shareCc, self).handlePremium() - if self.link: - self.link = self._getDownloadLink(self.link) + self.link = m.group(1) def handleCaptcha(self): @@ -125,11 +117,16 @@ class Keep2shareCc(SimpleHoster): self.fail(_("All captcha attempts failed")) - def _getDownloadLink(self, url): - p = urlparse(self.pyfile.url) + def downloadLink(self, link): + if not link: + return + + p = urlparse(self.pyfile.url) base = "%s://%s" % (p.scheme, p.netloc) - link = _isDirectLink(self, url, self.premium) - return urljoin(base, link) if link else "" + link = _isDirectLink(self, link, self.premium) + + if link: + self.download(urljoin(base, link), disposition=True) getInfo = create_getInfo(Keep2shareCc) -- cgit v1.2.3 From 608af3e22f15a36ba7a3efab1886f5827fd6741e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 23:00:32 +0100 Subject: [Keep2shareCc] Fix captcha_url --- module/plugins/hoster/Keep2shareCc.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index d98fa3c09..0d06a74c7 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import _isDirectLink, SimpleHoster, cr class Keep2shareCc(SimpleHoster): __name__ = "Keep2shareCc" __type__ = "hoster" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P\w+)' @@ -99,7 +99,7 @@ class Keep2shareCc(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: - captcha_url = urljoin(self.base, m.group(1)) + captcha_url = urljoin("http://k2s.cc/", m.group(1)) post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) else: challenge, response = recaptcha.challenge() @@ -121,12 +121,10 @@ class Keep2shareCc(SimpleHoster): if not link: return - p = urlparse(self.pyfile.url) - base = "%s://%s" % (p.scheme, p.netloc) link = _isDirectLink(self, link, self.premium) if link: - self.download(urljoin(base, link), disposition=True) + self.download(urljoin("http://k2s.cc/", link), disposition=True) getInfo = create_getInfo(Keep2shareCc) -- cgit v1.2.3 From 57300575fa97107d172e0c9909b244c8c8ae6c12 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Dec 2014 20:02:20 +0100 Subject: Extend SimpleHoster in multi-hoster plugins --- module/plugins/hoster/Keep2shareCc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/Keep2shareCc.py') diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index 0d06a74c7..86c28e93b 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -118,7 +118,7 @@ class Keep2shareCc(SimpleHoster): def downloadLink(self, link): - if not link: + if not link or not isinstance(link, basestring): return link = _isDirectLink(self, link, self.premium) -- cgit v1.2.3