diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2012-01-11 16:26:04 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2012-01-11 16:26:04 +0100 |
commit | 8334d649654f03b66ac2f6c2bb6fe2f1883173ef (patch) | |
tree | 637492fccdfe708107d08f50b14fd2d0a15260b4 /module/plugins/hoster | |
parent | fix filepost, mediafire closed #495 (diff) | |
download | pyload-8334d649654f03b66ac2f6c2bb6fe2f1883173ef.tar.xz |
uloz.to premium, update linkdecrypter.com
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/UlozTo.py | 192 |
1 files changed, 95 insertions, 97 deletions
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 53c5cd81f..9c9f502c3 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -18,121 +18,119 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.network.RequestFactory import getURL + +def convertDecimalPrefix(m): + # decimal prefixes used in filesize and traffic + return "%s%s%s B" % (m.group(1), m.group(2).ljust(3, '0') if m.group(2) else '000', {'k': '', 'M': '000', 'G': '000000'}[m.group(3)]) class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/.*" - __version__ = "0.74" + __version__ = "0.80" __description__ = """uloz.to""" - __config__ = [("reuseCaptcha", "bool", "Reuse captcha", "True"), - ("captchaUser", "str", "captcha_user", ""), - ("captchaNb", "str", "captcha_nb", "")] __author_name__ = ("zoidberg") - FILE_URL_PATTERN = r'<form name="dwn" action="([^"]+)"' - FILE_NAME_PATTERN = r'<h2 class="nadpis" style="margin-left:196px;"><a href="[^"]+">(?P<N>[^<]+)</a></h2>' - CAPTCHA_PATTERN = r'<img style=".*src="([^"]+)" alt="Captcha" class="captcha"' - CAPTCHA_NB_PATTERN = r'<input class="captcha_nb" type="hidden" name="captcha_nb" value="([0-9]+)" >' + FILE_NAME_PATTERN = r'<a share_url="[^&]*&t=(?P<N>[^"]+)"' + #FILE_NAME_PATTERN = r'<h2 class="nadpis" style="margin-left:196px;"><a href="[^"]+">(?P<N>[^<]+)</a></h2>' + FILE_SIZE_PATTERN = r'<div class="info_velikost" style="top:-55px;">\s*<div>[^<]*\s+(?P<S>[0-9.]+\s[kMG]B)\s*</div>\s*</div>' + FILE_SIZE_REPLACEMENTS = [('(\d+)\.?(\d+)? (\w)B', convertDecimalPrefix), (' ','')] FILE_OFFLINE_PATTERN = r'http://www.uloz.to/(neexistujici|smazano|nenalezeno)' + PASSWD_PATTERN = r'<input type="password" class="text" name="file_password" id="frmfilepasswordForm-file_password" />' - LIVE_URL_PATTERN = r'<div id="flashplayer"[^>]*>\s*<a href="([^"]+)"' - LIVE_NAME_PATTERN = r'<a share_url="[^&]*&t=([^"]+)"' - FILE_SIZE_PATTERN = r'<div class="info_velikost" style="top:-55px;">\s*<div>[^<]*\s+(?P<S>[0-9.]+)\s(?P<U>[kKMG])i?B\s*</div>\s*</div>' - VIPLINK_PATTERN = r'<a href="[^"]*\?disclaimer=1" class="linkVip">' - - def setup(self): - self.multiDL = False + VIPLINK_PATTERN = r'<a href="[^"]*\?disclaimer=1" class="linkVip">' + FREE_URL_PATTERN = r'<form name="dwn" action="([^"]+)"' + PREMIUM_URL_PATTERN = r'<a onclick[^>]*href="([^"]+)[^>]*class="linkVip"' + CAPTCHA_PATTERN = r'<img style=".*src="([^"]+)" alt="Captcha" class="captcha"' + CAPTCHA_NB_PATTERN = r'<input class="captcha_nb" type="hidden" name="captcha_nb" value="([0-9]+)" >' def process(self, pyfile): + # check file online header = self.load(pyfile.url, just_header=True) if "location" in header: self.logDebug('LOCATION: ' + header['location']) if "utm_source=old" in header['location'] or re.search(self.FILE_OFFLINE_PATTERN, header['location']): - self.offline() - + self.offline() + self.html = self.load(pyfile.url, decode=True) - if self.PASSWD_PATTERN in self.html: - self.fail("Password protected link") - + # password protected links + 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": "filepasswordForm-submit"}, post={"file_password": password, "fpwdsend": 'Odeslat'}, cookies=True) + else: + self.fail("No or incorrect password") + + self.file_info = self.getFileInfo() + + # adult content if re.search(self.VIPLINK_PATTERN, self.html): self.html = self.load(pyfile.url, get={"disclaimer": "1"}) + + if self.premium and self.checkCredit(): + self.handlePremium() + else: + self.handleFree() + + def handleFree(self): + parsed_url = self.findDownloadURL(premium=False) + + # get and decrypt captcha + captcha = self.getStorage("captchaUser") + captcha_nb = self.getStorage("captchaNb") + captcha_url = "DUMMY" + + if not captcha or not captcha_nb: + found = re.search(self.CAPTCHA_PATTERN, self.html) + if not found: self.parseError("CAPTCHA") + captcha_url = found.group(1) + + found = re.search(self.CAPTCHA_NB_PATTERN, self.html) + if not found: self.parseError("CAPTCHA_NB") + captcha_nb = found.group(1) + + captcha = self.decryptCaptcha(captcha_url) + + self.log.debug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha + ' CAPTCHA_NB:' + captcha_nb) - found = re.search(self.LIVE_URL_PATTERN, self.html) - if found is not None: - # Uloz.to LIVE - parsed_url = found.group(1) - self.logDebug("LIVE URL:" + parsed_url) - - found = re.search(self.LIVE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (LIVE_NAME)") - pyfile.name = found.group(1) - self.log.debug("LIVE NAME:" + pyfile.name) - - self.download(parsed_url) - else: - # Uloz.to DATA - # parse the name from the site and set attribute in pyfile - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (FILENAME)") - pyfile.name = found.group(1) - self.log.debug("PARSED_NAME:" + pyfile.name) - - found = re.search(self.FILE_URL_PATTERN, self.html) - if found is None: - self.fail("Parse error (URL)") - parsed_url = found.group(1) - self.log.debug("PARSED_URL:" + parsed_url) - - # get and decrypt captcha - reuse_captcha = self.getConfig("reuseCaptcha") - captcha = self.getConfig("captchaUser") - captcha_nb = self.getConfig("captchaNb") - captcha_url = "DUMMY" - - if not reuse_captcha or not captcha or not captcha_nb: - found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: - self.fail("Parse error (CAPTCHA)") - captcha_url = found.group(1) - captcha = self.decryptCaptcha(captcha_url) - found = re.search(self.CAPTCHA_NB_PATTERN, self.html) - if found is None: - self.fail("Parse error (CAPTCHA_NB)") - captcha_nb = found.group(1) - self.log.debug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha + ' CAPTCHA_NB:' + captcha_nb) - - # download the file, destination is determined by pyLoad - self.download(parsed_url, post={ - "captcha_user": captcha, - "captcha_nb": captcha_nb - }) - - check = self.checkDownload({ - "wrong_captcha": re.compile(self.CAPTCHA_PATTERN), - "offline": re.compile(self.FILE_OFFLINE_PATTERN), - "passwd": self.PASSWD_PATTERN - }) - - if check == "wrong_captcha": - if reuse_captcha: - self.setConfig("captchaUser", "") - self.setConfig("captchaNb", "") - self.invalidCaptcha() - self.retry(reason="Wrong captcha code") - elif check == "offline": - self.offline() - elif check == "passwd": - self.fail("Password protected") - - if reuse_captcha: - self.setConfig("captchaUser", captcha) - self.setConfig("captchaNb", captcha_nb) - -getInfo = create_getInfo(UlozTo) - -
\ No newline at end of file + # download and check + self.download(parsed_url, post={"captcha_user": captcha, "captcha_nb": captcha_nb}, cookies=True, disposition = True) + self.doCheckDownload() + + self.setStorage("captchaUser", captcha) + self.setStorage("captchaNb", captcha_nb) + + def handlePremium(self): + parsed_url = self.findDownloadURL(premium=True) + self.download(parsed_url, disposition = True) + self.doCheckDownload() + + 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 = 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 + }) + + if check == "wrong_captcha": + self.delStorage("captchaUser") + self.delStorage("captchaNb") + self.invalidCaptcha() + self.retry(reason="Wrong captcha code") + elif check == "offline": + self.offline() + elif check == "passwd": + self.fail("Wrong password") + +getInfo = create_getInfo(UlozTo)
\ No newline at end of file |