'
FREE_URL_PATTERN = r''
def setup(self):
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)
passwords = self.getPassword().splitlines()
while self.PASSWD_PATTERN in self.html:
if passwords:
password = passwords.pop(0)
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")
if re.search(self.VIPLINK_PATTERN, self.html):
self.html = self.load(pyfile.url, get={"disclaimer": "1"})
self.file_info = self.getFileInfo()
if self.premium and self.checkTrafficLeft():
self.handlePremium()
else:
self.handleFree()
self.doCheckDownload()
def handleFree(self):
parsed_url = self.findDownloadURL(premium=False)
# get and decrypt captcha
captcha_id = self.getStorage("captcha_id")
captcha_text = self.getStorage("captcha_text")
captcha_url = "DUMMY"
if not captcha_id or not captcha_text:
found = re.search(self.CAPTCHA_PATTERN, self.html)
if not found: self.parseError("CAPTCHA")
captcha_url, captcha_id = found.groups()
captcha_text = self.decryptCaptcha(captcha_url)
self.log.debug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA ID:' + captcha_id + ' CAPTCHA TEXT:' + captcha_text)
self.setStorage("captcha_id", captcha_id)
self.setStorage("captcha_text", captcha_text)
self.multiDL = True
self.download(parsed_url, post={"captcha[id]": captcha_id, "captcha[text]": captcha_text, "freeDownload": "Download"}, cookies=True)
def handlePremium(self):
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")
found = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html)
if not found: self.parseError(msg)
parsed_url = "http://www.ulozto.net" + found.group(1)
self.logDebug("%s: %s" % (msg, parsed_url))
return parsed_url
def doCheckDownload(self):
check = self.checkDownload({
"wrong_captcha": re.compile(self.CAPTCHA_PATTERN),
"offline": re.compile(self.FILE_OFFLINE_PATTERN),
"passwd": self.PASSWD_PATTERN,
"paralell_dl": "
Uloz.to - Již stahuješ",
"not_found": "Ulož.to"
})
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 == "paralell_dl":
self.multiDL = False
self.setWait(300, True)
self.wait()
self.retry()
elif check == "not_found":
self.fail("Server error - file not downloadable")
getInfo = create_getInfo(UlozTo)