# -*- coding: utf-8 -*- import re from module.plugins.internal.SimpleHoster import SimpleHoster from module.plugins.internal.misc import json, timestamp, parse_name def convert_decimal_prefix(m): #: Decimal prefixes used in filesize and traffic return ("%%.%df" % {'k': 3, 'M': 6, 'G': 9}[m.group(2)] % float(m.group(1))).replace('.', '') class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" __version__ = "1.33" __status__ = "testing" __pattern__ = r'http(s)?://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj\.cz|zachowajto\.pl|pornfile\.cz)/(?:live/)?(?P\w+/[^/?]*)' __config__ = [("activated" , "bool", "Activated" , True), ("use_premium" , "bool", "Use premium account if available" , True), ("fallback" , "bool", "Fallback to free download if premium fails" , True), ("chk_filesize", "bool", "Check file size" , True), ("captcha" , "Image;Sound", "Captcha recognition" , "Image"), ("max_wait" , "int" , "Reconnect if waiting time is greater than minutes", 10 )] __description__ = """Uloz.to hoster plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("ondrej", "git@ondrej.it"),] NAME_PATTERN = r'(

File |)(?P<N>.+?)(<| \|)' SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[\d.,]+\s[kMG]?B)</span>' OFFLINE_PATTERN = r'<title>404 - Page not found|

File (has been deleted|was banned)

' URL_REPLACEMENTS = [(r'(?<=http://)([^/]+)', "www.ulozto.net")] SIZE_REPLACEMENTS = [(r'([\d.]+)\s([kMG])B', convert_decimal_prefix)] CHECK_TRAFFIC = True ADULT_PATTERN = r'PORNfile.cz' PASSWD_PATTERN = r'
' VIPLINK_PATTERN = r'' TOKEN_PATTERN = r' 1.4.2016') inputs.update({'do': inputs['do'], '_token_': inputs['_token_'], 'ts': inputs['ts'], 'cid': inputs['cid'], 'adi': inputs['adi'], 'sign_a': inputs['sign_a'],'sign': inputs['sign']}) else: self.error(_("CAPTCHA form changed")) self.download("http://www.ulozto.net" + action, post=inputs) def handle_premium(self, pyfile): self.download(pyfile.url, get={'do': "directDownload"}) def check_errors(self): if self.PASSWD_PATTERN in self.data: password = self.get_password() if password: self.log_info(_("Password protected link, trying ") + password) self.data = self.load(self.pyfile.url, get={'do': "passwordProtectedForm-submit"}, post={'password': password, 'password_send': 'Send'}) if self.PASSWD_PATTERN in self.data: self.fail(_("Wrong password")) else: self.fail(_("No password found")) if re.search(self.VIPLINK_PATTERN, self.data): self.data = self.load(pyfile.url, get={'disclaimer': "1"}) return super(UlozTo, self).check_errors() def check_download(self): check = self.scan_download({ 'wrong_captcha': ">An error ocurred while verifying the user", 'offline' : re.compile(self.OFFLINE_PATTERN), 'passwd' : self.PASSWD_PATTERN, 'server_error' : 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', #: Paralell dl, server overload etc. 'not_found' : "Ulož.to" }) if check == "wrong_captcha": self.captcha.invalid() self.retry(msg=_("Wrong captcha code")) elif check == "offline": self.offline() elif check == "passwd": self.fail(_("Wrong password")) elif check == "server_error": self.log_error(_("Server error, try downloading later")) self.multiDL = False self.wait(1 * 60 * 60, True) self.retry() elif check == "not_found": self.fail(_("Server error, file not downloadable")) return super(UlozTo, self).check_download()