diff options
Diffstat (limited to 'module/plugins/hoster/Keep2ShareCc.py')
-rw-r--r-- | module/plugins/hoster/Keep2ShareCc.py | 82 |
1 files changed, 31 insertions, 51 deletions
diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 8f8e8cb67..3ed11aa13 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -2,20 +2,20 @@ import re -from urlparse import urljoin, urlparse +from urlparse import urljoin -from pyload.plugin.internal.captcha import ReCaptcha -from pyload.plugin.internal.SimpleHoster import _isDirectLink, SimpleHoster, create_getInfo +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -class Keep2shareCc(SimpleHoster): - __name__ = "Keep2shareCc" +class Keep2ShareCc(SimpleHoster): + __name__ = "Keep2ShareCc" __type__ = "hoster" - __version__ = "0.17" + __version__ = "0.21" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P<ID>\w+)' - __description__ = """Keep2share.cc hoster plugin""" + __description__ = """Keep2Share.cc hoster plugin""" __license__ = "GPLv3" __authors__ = [("stickell", "l.stickell@yahoo.it"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -29,7 +29,8 @@ class Keep2shareCc(SimpleHoster): 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 = \'(.+?)\';' + LINK_FREE_PATTERN = r'"([^"]+url.html?file=.+?)"|window\.location\.href = \'(.+?)\';' + LINK_PREMIUM_PATTERN = r'window\.location\.href = \'(.+?)\';' CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' @@ -56,7 +57,7 @@ class Keep2shareCc(SimpleHoster): # 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(':')))]) + 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") @@ -64,9 +65,9 @@ class Keep2shareCc(SimpleHoster): self.info.pop('error', None) - def handleFree(self): + def handleFree(self, pyfile): self.fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1) - self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) + self.html = self.load(pyfile.url, post={'yt0': '', 'slow_id': self.fid}) self.checkErrors() @@ -77,56 +78,35 @@ class Keep2shareCc(SimpleHoster): self.wait(30) - self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) - - self.checkErrors() + self.html = self.load(pyfile.url) m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("LINK_FREE_PATTERN not found")) + self.error(_("Free download link not found")) self.link = m.group(1) - - def handleCaptcha(self): recaptcha = ReCaptcha(self) + post_data = {'free' : 1, + 'freeDownloadRequest': 1, + 'uniqueId' : self.fid, + 'yt0' : ''} - 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, 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() + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + captcha_url = urljoin("http://k2s.cc/", m.group(1)) + post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) else: - self.fail(_("All captcha attempts failed")) + response, challenge = recaptcha.challenge() + post_data.update({'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + self.html = self.load(self.pyfile.url, post=post_data) - def downloadLink(self, link): - 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) + if 'verification code is incorrect' not in self.html: + self.correctCaptcha() + else: + self.invalidCaptcha() -getInfo = create_getInfo(Keep2shareCc) +getInfo = create_getInfo(Keep2ShareCc) |