diff options
Diffstat (limited to 'pyload/plugins/hoster/UlozTo.py')
-rw-r--r-- | pyload/plugins/hoster/UlozTo.py | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/pyload/plugins/hoster/UlozTo.py b/pyload/plugins/hoster/UlozTo.py index 3fecbd672..84d5287ac 100644 --- a/pyload/plugins/hoster/UlozTo.py +++ b/pyload/plugins/hoster/UlozTo.py @@ -13,23 +13,24 @@ def convertDecimalPrefix(m): class UlozTo(SimpleHoster): - __name__ = "UlozTo" - __type__ = "hoster" - __version__ = "0.98" + __name__ = "UlozTo" + __type__ = "hoster" + __version__ = "0.99" - __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(?:live/)?(?P<id>\w+/[^/?]*)' + __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj\.cz|zachowajto\.pl)/(?:live/)?(?P<id>\w+/[^/?]*)' __description__ = """Uloz.to hoster plugin""" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' - FILE_NAME_PATTERN = r'<title>(?P<N>[^<]+) \| Uloz.to</title>' - FILE_SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[0-9.]+\s[kMG]?B)</span>' + INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' + NAME_PATTERN = r'<title>(?P<N>[^<]+) \| Uloz\.to</title>' + 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>' - FILE_SIZE_REPLACEMENTS = [('([0-9.]+)\s([kMG])B', convertDecimalPrefix)] - FILE_URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "www.ulozto.net")] + SIZE_REPLACEMENTS = [('([\d.]+)\s([kMG])B', convertDecimalPrefix)] + URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "www.ulozto.net")] ADULT_PATTERN = r'<form action="(?P<link>[^\"]*)" method="post" id="frm-askAgeForm">' PASSWD_PATTERN = r'<div class="passwordProtectedFile">' @@ -43,16 +44,17 @@ class UlozTo(SimpleHoster): self.multiDL = self.premium 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. Proceeding..") + self.logInfo(_("Adult content confirmation needed")) m = re.search(self.TOKEN_PATTERN, self.html) if m is None: - self.parseError('TOKEN') + self.error(_("TOKEN_PATTERN not found")) token = m.group(1) self.html = self.load(pyfile.url, get={"do": "askAgeForm-submit"}, @@ -62,16 +64,16 @@ class UlozTo(SimpleHoster): while self.PASSWD_PATTERN in self.html: if passwords: password = passwords.pop(0) - self.logInfo("Password protected link, trying " + 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) else: - self.fail("No or incorrect password") + self.fail(_("No or incorrect password")) if re.search(self.VIPLINK_PATTERN, self.html): self.html = self.load(pyfile.url, get={"disclaimer": "1"}) - self.file_info = self.getFileInfo() + self.getFileInfo() if self.premium and self.checkTrafficLeft(): self.handlePremium() @@ -80,10 +82,11 @@ class UlozTo(SimpleHoster): self.doCheckDownload() + def handleFree(self): action, inputs = self.parseHtmlForm('id="frm-downloadDialog-freeDownloadForm"') if not action or not inputs: - self.parseError("free download form") + self.error(_("Free download form not found")) self.logDebug("inputs.keys = " + str(inputs.keys())) # get and decrypt captcha @@ -109,25 +112,28 @@ class UlozTo(SimpleHoster): inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) else: - self.parseError("CAPTCHA form changed") + self.error(_("CAPTCHA form changed")) self.multiDL = True self.download("http://www.ulozto.net" + action, post=inputs, cookies=True, disposition=True) + 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"}) + def findDownloadURL(self, premium=False): - msg = "%s link" % ("Premium" if premium else "Free") + 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.parseError(msg) + self.error(msg) parsed_url = "http://www.ulozto.net" + m.group(1) self.logDebug("%s: %s" % (msg, parsed_url)) return parsed_url + def doCheckDownload(self): check = self.checkDownload({ "wrong_captcha": re.compile(r'<ul class="error">\s*<li>Error rewriting the text.</li>'), @@ -141,18 +147,18 @@ class UlozTo(SimpleHoster): #self.delStorage("captcha_id") #self.delStorage("captcha_text") self.invalidCaptcha() - self.retry(reason="Wrong captcha code") + self.retry(reason=_("Wrong captcha code")) elif check == "offline": self.offline() elif check == "passwd": - self.fail("Wrong password") + self.fail(_("Wrong password")) elif check == "server_error": - self.logError("Server error, try downloading later") + 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")) getInfo = create_getInfo(UlozTo) |