From 37d898f681e41fe9c9a8719a540eda59bfedd448 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 21 Jul 2013 12:58:42 +0200 Subject: Normalize line endings to avoid line endings merge conflicts --- module/plugins/hoster/LuckyShareNet.py | 144 ++++++++++++++++----------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'module/plugins/hoster/LuckyShareNet.py') diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 5a4a583ff..08e44d9f6 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -1,72 +1,72 @@ -# -*- coding: utf-8 -*- - -import re -from module.lib.bottle import json_loads - -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha - - -class LuckyShareNet(SimpleHoster): - __name__ = "LuckyShareNet" - __type__ = "hoster" - __pattern__ = r"https?://(www\.)?luckyshare.net/(?P\d{10,})" - __version__ = "0.02" - __description__ = """LuckyShare.net Download Hoster""" - __author_name__ = ("stickell") - __author_mail__ = ("l.stickell@yahoo.it") - - FILE_INFO_PATTERN = r"

(?P\S+)

\s*Filesize: (?P[\d.]+)(?P\w+)" - FILE_OFFLINE_PATTERN = 'There is no such file available' - RECAPTCHA_KEY = '6LdivsgSAAAAANWh-d7rPE1mus4yVWuSQIJKIYNw' - - def parseJson(self, rep): - if 'AJAX Error' in rep: - html = self.load(self.pyfile.url, decode=True) - m = re.search(r"waitingtime = (\d+);", html) - if m: - waittime = int(m.group(1)) - self.logDebug('You have to wait %d seconds between free downloads' % waittime) - self.retry(wait_time=waittime) - else: - self.parseError('Unable to detect wait time between free downloads') - elif 'Hash expired' in rep: - self.retry(reason='Hash expired') - return json_loads(rep) - - # TODO: There should be a filesize limit for free downloads - # TODO: Some files could not be downloaded in free mode - def handleFree(self): - file_id = re.search(self.__pattern__, self.pyfile.url).group('ID') - self.logDebug('File ID: ' + file_id) - rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True) - self.logDebug('JSON: ' + rep) - json = self.parseJson(rep) - - self.setWait(int(json['time'])) - self.wait() - - recaptcha = ReCaptcha(self) - for i in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % - (challenge, response, json['hash']), decode=True) - self.logDebug('JSON: ' + rep) - if 'link' in rep: - json.update(self.parseJson(rep)) - self.correctCaptcha() - break - elif 'Verification failed' in rep: - self.logInfo('Wrong captcha') - self.invalidCaptcha() - else: - self.parseError('Unable to get downlaod link') - - if not json['link']: - self.fail("No Download url retrieved/all captcha attempts failed") - - self.logDebug('Direct URL: ' + json['link']) - self.download(json['link']) - - -getInfo = create_getInfo(LuckyShareNet) +# -*- coding: utf-8 -*- + +import re +from module.lib.bottle import json_loads + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.CaptchaService import ReCaptcha + + +class LuckyShareNet(SimpleHoster): + __name__ = "LuckyShareNet" + __type__ = "hoster" + __pattern__ = r"https?://(www\.)?luckyshare.net/(?P\d{10,})" + __version__ = "0.02" + __description__ = """LuckyShare.net Download Hoster""" + __author_name__ = ("stickell") + __author_mail__ = ("l.stickell@yahoo.it") + + FILE_INFO_PATTERN = r"

(?P\S+)

\s*Filesize: (?P[\d.]+)(?P\w+)" + FILE_OFFLINE_PATTERN = 'There is no such file available' + RECAPTCHA_KEY = '6LdivsgSAAAAANWh-d7rPE1mus4yVWuSQIJKIYNw' + + def parseJson(self, rep): + if 'AJAX Error' in rep: + html = self.load(self.pyfile.url, decode=True) + m = re.search(r"waitingtime = (\d+);", html) + if m: + waittime = int(m.group(1)) + self.logDebug('You have to wait %d seconds between free downloads' % waittime) + self.retry(wait_time=waittime) + else: + self.parseError('Unable to detect wait time between free downloads') + elif 'Hash expired' in rep: + self.retry(reason='Hash expired') + return json_loads(rep) + + # TODO: There should be a filesize limit for free downloads + # TODO: Some files could not be downloaded in free mode + def handleFree(self): + file_id = re.search(self.__pattern__, self.pyfile.url).group('ID') + self.logDebug('File ID: ' + file_id) + rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True) + self.logDebug('JSON: ' + rep) + json = self.parseJson(rep) + + self.setWait(int(json['time'])) + self.wait() + + recaptcha = ReCaptcha(self) + for i in xrange(5): + challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % + (challenge, response, json['hash']), decode=True) + self.logDebug('JSON: ' + rep) + if 'link' in rep: + json.update(self.parseJson(rep)) + self.correctCaptcha() + break + elif 'Verification failed' in rep: + self.logInfo('Wrong captcha') + self.invalidCaptcha() + else: + self.parseError('Unable to get downlaod link') + + if not json['link']: + self.fail("No Download url retrieved/all captcha attempts failed") + + self.logDebug('Direct URL: ' + json['link']) + self.download(json['link']) + + +getInfo = create_getInfo(LuckyShareNet) -- cgit v1.2.3