From 01c5c24e6aa993b2060618e244f47a476725657d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 1 Oct 2014 04:45:27 +0200 Subject: [OneFichierCom] Fixed wait pattern + code optimizations --- module/plugins/hoster/Keep2shareCC.py | 11 ++++++----- 1 file changed, 6 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 78d6aaba7..f17faae46 100644 --- a/module/plugins/hoster/Keep2shareCC.py +++ b/module/plugins/hoster/Keep2shareCC.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -# -# Test links: -# http://k2s.cc/file/55fb73e1c00c5/random.bin import re @@ -22,13 +19,14 @@ class Keep2shareCC(SimpleHoster): __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + FILE_NAME_PATTERN = r'File: (?P.+)' FILE_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' WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' - ALREADY_DOWNLOADING_PATTERN = r'Free account does not allow to download more than one file at the same time' + MULTIDL_ERROR = r'Free account does not allow to download more than one file at the same time' RECAPTCHA_KEY = "6LcYcN0SAAAAABtMlxKj7X0hRxOY8_2U86kI1vbb" @@ -59,7 +57,7 @@ class Keep2shareCC(SimpleHoster): self.wait(wait_time, reconnect=True) self.retry() - m = re.search(self.ALREADY_DOWNLOADING_PATTERN, self.html) + 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") @@ -71,6 +69,7 @@ class Keep2shareCC(SimpleHoster): self.parseError("Unable to detect direct link") self.startDownload(m.group(1)) + def handleCaptcha(self): recaptcha = ReCaptcha(self) for _ in xrange(5): @@ -94,11 +93,13 @@ class Keep2shareCC(SimpleHoster): 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: -- cgit v1.2.3