diff options
Diffstat (limited to 'module/plugins/hoster/UlozTo.py')
-rw-r--r-- | module/plugins/hoster/UlozTo.py | 133 |
1 files changed, 59 insertions, 74 deletions
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 6b84a5e1b..b43ff8d92 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -15,9 +15,10 @@ def convertDecimalPrefix(m): class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" - __version__ = "1.01" + __version__ = "1.09" __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj\.cz|zachowajto\.pl)/(?:live/)?(?P<ID>\w+/[^/?]*)' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Uloz.to hoster plugin""" __license__ = "GPLv3" @@ -29,65 +30,25 @@ class UlozTo(SimpleHoster): SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[\d.,]+\s[kMG]?B)</span>' OFFLINE_PATTERN = r'<title>404 - Page not found</title>|<h1 class="h1">File (has been deleted|was banned)</h1>' - URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "www.ulozto.net")] - SIZE_REPLACEMENTS = [('([\d.]+)\s([kMG])B', convertDecimalPrefix)] + URL_REPLACEMENTS = [(r'(?<=http://)([^/]+)', "www.ulozto.net")] + SIZE_REPLACEMENTS = [(r'([\d.]+)\s([kMG])B', convertDecimalPrefix)] - ADULT_PATTERN = r'<form action="([^\"]*)" method="post" id="frm-askAgeForm">' + CHECK_TRAFFIC = True + DISPOSITION = False #: Remove in 0.4.10 + + ADULT_PATTERN = r'<form action="(.+?)" method="post" id="frm-askAgeForm">' PASSWD_PATTERN = r'<div class="passwordProtectedFile">' - VIPLINK_PATTERN = r'<a href="[^"]*\?disclaimer=1" class="linkVip">' + VIPLINK_PATTERN = r'<a href=".+?\?disclaimer=1" class="linkVip">' TOKEN_PATTERN = r'<input type="hidden" name="_token_" .*?value="(.+?)"' - FREE_URL_PATTERN = r'<div class="freeDownloadForm"><form action="([^"]+)"' - PREMIUM_URL_PATTERN = r'<div class="downloadForm"><form action="([^"]+)"' - def setup(self): - self.multiDL = self.premium + self.chunkLimit = 16 if self.premium else 1 + self.multiDL = True self.resumeDownload = True - def process(self, pyfile): - pyfile.url = re.sub(r"(?<=http://)([^/]+)", "www.ulozto.net", pyfile.url) - self.html = self.load(pyfile.url, decode=True, cookies=True) - - if re.search(self.ADULT_PATTERN, self.html): - self.logInfo(_("Adult content confirmation needed")) - - m = re.search(self.TOKEN_PATTERN, self.html) - if m is None: - self.error(_("TOKEN_PATTERN not found")) - token = m.group(1) - - self.html = self.load(pyfile.url, get={"do": "askAgeForm-submit"}, - post={"agree": "Confirm", "_token_": token}, cookies=True) - - if self.PASSWD_PATTERN in self.html: - password = self.getPassword() - - if password: - self.logInfo(_("Password protected link, trying ") + password) - self.html = self.load(pyfile.url, get={"do": "passwordProtectedForm-submit"}, - post={"password": password, "password_send": 'Send'}, cookies=True) - - if self.PASSWD_PATTERN in self.html: - self.fail(_("Incorrect password")) - else: - self.fail(_("No password found")) - - if re.search(self.VIPLINK_PATTERN, self.html): - self.html = self.load(pyfile.url, get={"disclaimer": "1"}) - - self.getFileInfo() - - if self.premium and self.checkTrafficLeft(): - self.handlePremium() - else: - self.handleFree() - - self.doCheckDownload() - - - def handleFree(self): + def handleFree(self, pyfile): action, inputs = self.parseHtmlForm('id="frm-downloadDialog-freeDownloadForm"') if not action or not inputs: self.error(_("Free download form not found")) @@ -107,7 +68,7 @@ class UlozTo(SimpleHoster): # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 self.logDebug('Using "new" version') - xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={"rnd": str(int(time.time()))}) + xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={'rnd': str(int(time.time()))}) self.logDebug("xapca = " + str(xapca)) data = json_loads(xapca) @@ -115,54 +76,78 @@ class UlozTo(SimpleHoster): self.logDebug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: " + str(data['salt']), "CAPTCHA VALUE: " + captcha_value) inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) + else: self.error(_("CAPTCHA form changed")) - self.multiDL = True - self.download("http://www.ulozto.net" + action, post=inputs, cookies=True, disposition=True) + self.download("http://www.ulozto.net" + action, post=inputs) + + + def handlePremium(self, pyfile): + self.download(pyfile.url, get={'do': "directDownload"}) + + + def checkErrors(self): + if re.search(self.ADULT_PATTERN, self.html): + self.logInfo(_("Adult content confirmation needed")) + + m = re.search(self.TOKEN_PATTERN, self.html) + if m is None: + self.error(_("TOKEN_PATTERN not found")) + + self.html = self.load(pyfile.url, + get={'do': "askAgeForm-submit"}, + post={"agree": "Confirm", "_token_": m.group(1)}) + + if self.PASSWD_PATTERN in self.html: + password = self.getPassword() + if password: + self.logInfo(_("Password protected link, trying ") + password) + self.html = self.load(pyfile.url, + get={'do': "passwordProtectedForm-submit"}, + post={"password": password, "password_send": 'Send'}) - def handlePremium(self): - self.download(self.pyfile.url + "?do=directDownload", disposition=True) - #parsed_url = self.findDownloadURL(premium=True) - #self.download(parsed_url, post={"download": "Download"}) + if self.PASSWD_PATTERN in self.html: + self.fail(_("Incorrect password")) + else: + self.fail(_("No password found")) + if re.search(self.VIPLINK_PATTERN, self.html): + self.html = self.load(pyfile.url, get={'disclaimer': "1"}) - def findDownloadURL(self, premium=False): - msg = _("%s link" % ("Premium" if premium else "Free")) - m = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html) - if m is None: - self.error(msg) - parsed_url = "http://www.ulozto.net" + m.group(1) - self.logDebug("%s: %s" % (msg, parsed_url)) - return parsed_url + return super(UlozTo, self).checkErrors() - def doCheckDownload(self): + def checkFile(self, rules={}): check = self.checkDownload({ "wrong_captcha": re.compile(r'<ul class="error">\s*<li>Error rewriting the text.</li>'), - "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": "<title>Ulož.to</title>" + "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" : "<title>Ulož.to</title>" }) if check == "wrong_captcha": - #self.delStorage("captcha_id") - #self.delStorage("captcha_text") self.invalidCaptcha() self.retry(reason=_("Wrong captcha code")) + elif check == "offline": self.offline() + elif check == "passwd": self.fail(_("Wrong password")) + elif check == "server_error": self.logError(_("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")) + self.fail(_("Server error, file not downloadable")) + + return super(UlozTo, self).checkFile(rules) getInfo = create_getInfo(UlozTo) |