diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-13 15:56:57 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-13 15:56:57 +0100 |
commit | acc46fc3497a66a427b795b4a22c6e71d69185a1 (patch) | |
tree | 2d315b838a76435fc456b972c99c28d1732b2f70 /pyload/plugin/hoster/FilecloudIo.py | |
parent | Code fixes (diff) | |
download | pyload-acc46fc3497a66a427b795b4a22c6e71d69185a1.tar.xz |
Update
Diffstat (limited to 'pyload/plugin/hoster/FilecloudIo.py')
-rw-r--r-- | pyload/plugin/hoster/FilecloudIo.py | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/pyload/plugin/hoster/FilecloudIo.py b/pyload/plugin/hoster/FilecloudIo.py new file mode 100644 index 000000000..792f563d6 --- /dev/null +++ b/pyload/plugin/hoster/FilecloudIo.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.utils import json_loads +from pyload.plugin.internal.captcha import ReCaptcha +from pyload.plugin.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class FilecloudIo(SimpleHoster): + __name = "FilecloudIo" + __type = "hoster" + __version = "0.05" + + __pattern = r'http://(?:www\.)?(?:filecloud\.io|ifile\.it|mihd\.net)/(?P<ID>\w+).*' + + __description = """Filecloud.io hoster plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + SIZE_PATTERN = r'{var __ab1 = (?P<S>\d+);}' + NAME_PATTERN = r'id="aliasSpan">(?P<N>.*?) <' + OFFLINE_PATTERN = r'l10n\.(FILES__DOESNT_EXIST|REMOVED)' + TEMP_OFFLINE_PATTERN = r'l10n\.FILES__WARNING' + + UKEY_PATTERN = r'\'ukey\'\s*:\'(\w+)' + AB1_PATTERN = r'if\( __ab1 == \'(\w+)\' \)' + ERROR_MSG_PATTERN = r'var __error_msg\s*=\s*l10n\.(.*?);' + RECAPTCHA_PATTERN = r'var __recaptcha_public\s*=\s*\'(.+?)\';' + + LINK_PATTERN = r'"(http://s\d+\.filecloud\.io/%s/\d+/.*?)"' + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = 1 + + + def handleFree(self): + data = {"ukey": self.info['pattern']['ID']} + + m = re.search(self.AB1_PATTERN, self.html) + if m is None: + self.error(_("__AB1")) + data['__ab1'] = m.group(1) + + recaptcha = ReCaptcha(self) + + m = re.search(self.RECAPTCHA_PATTERN, self.html) + captcha_key = m.group(1) if m else recaptcha.detect_key() + + if captcha_key is None: + self.error(_("ReCaptcha key not found")) + + if not self.account: + self.fail(_("User not logged in")) + elif not self.account.logged_in: + challenge, response = recaptcha.challenge(captcha_key) + self.account.form_data = {"recaptcha_challenge_field": challenge, + "recaptcha_response_field" : response} + self.account.relogin(self.user) + self.retry(2) + + json_url = "http://filecloud.io/download-request.json" + res = self.load(json_url, post=data) + self.logDebug(res) + res = json_loads(res) + + if "error" in res and res['error']: + self.fail(res) + + self.logDebug(res) + if res['captcha']: + data['ctype'] = "recaptcha" + + for _i in xrange(5): + data['recaptcha_challenge'], data['recaptcha_response'] = recaptcha.challenge(captcha_key) + + json_url = "http://filecloud.io/download-request.json" + res = self.load(json_url, post=data) + self.logDebug(res) + res = json_loads(res) + + if "retry" in res and res['retry']: + self.invalidCaptcha() + else: + self.correctCaptcha() + break + else: + self.fail(_("Incorrect captcha")) + + if res['dl']: + self.html = self.load('http://filecloud.io/download.html') + + m = re.search(self.LINK_PATTERN % self.info['pattern']['ID'], self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + + if "size" in self.info and self.info['size']: + self.check_data = {"size": int(self.info['size'])} + + download_url = m.group(1) + self.download(download_url) + else: + self.fail(_("Unexpected server response")) + + + def handlePremium(self): + akey = self.account.getAccountData(self.user)['akey'] + ukey = self.info['pattern']['ID'] + self.logDebug("Akey: %s | Ukey: %s" % (akey, ukey)) + rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", + post={"akey": akey, "ukey": ukey}) + self.logDebug("FetchDownloadUrl: " + rep) + rep = json_loads(rep) + if rep['status'] == 'ok': + self.download(rep['download_url'], disposition=True) + else: + self.fail(rep['message']) + + +getInfo = create_getInfo(FilecloudIo) |