diff options
Diffstat (limited to 'module/plugins/hoster/UlozTo.py')
-rw-r--r-- | module/plugins/hoster/UlozTo.py | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 282d4605b..dbdaf3f8e 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -1,26 +1,11 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re import time -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.common.json_layer import json_loads +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + def convertDecimalPrefix(m): # decimal prefixes used in filesize and traffic @@ -30,16 +15,19 @@ def convertDecimalPrefix(m): class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(?:live/)?(?P<id>\w+/[^/?]*)' __version__ = "0.98" + + __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(?:live/)?(?P<id>\w+/[^/?]*)' + __description__ = """Uloz.to hoster plugin""" __author_name__ = "zoidberg" __author_mail__ = "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>' - FILE_INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' - FILE_OFFLINE_PATTERN = r'<title>404 - Page not found</title>|<h1 class="h1">File (has been deleted|was banned)</h1>' + 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")] @@ -50,6 +38,7 @@ class UlozTo(SimpleHoster): PREMIUM_URL_PATTERN = r'<div class="downloadForm"><form action="([^"]+)"' TOKEN_PATTERN = r'<input type="hidden" name="_token_" id="[^\"]*" value="(?P<token>[^\"]*)" />' + def setup(self): self.multiDL = self.premium self.resumeDownload = True @@ -61,10 +50,10 @@ class UlozTo(SimpleHoster): if re.search(self.ADULT_PATTERN, self.html): self.logInfo("Adult content confirmation needed. Proceeding..") - found = re.search(self.TOKEN_PATTERN, self.html) - if not found: + m = re.search(self.TOKEN_PATTERN, self.html) + if m is None: self.parseError('TOKEN') - token = found.group(1) + token = m.group(1) self.html = self.load(pyfile.url, get={"do": "askAgeForm-submit"}, post={"agree": "Confirm", "_token_": token}, cookies=True) @@ -98,16 +87,16 @@ class UlozTo(SimpleHoster): self.logDebug('inputs.keys() = ' + str(inputs.keys())) # get and decrypt captcha - if all(key in inputs for key in ('captcha_value', 'captcha_id', 'captcha_key')): + if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")): # Old version - last seen 9.12.2013 self.logDebug('Using "old" version') captcha_value = self.decryptCaptcha("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) - self.logDebug('CAPTCHA ID: ' + inputs['captcha_id'] + ', CAPTCHA VALUE: ' + captcha_value) + self.logDebug('CAPTCHA ID: ' + inputs['captcha_id'] + ", CAPTCHA VALUE: " + captcha_value) inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) - elif all(key in inputs for key in ('captcha_value', 'timestamp', 'salt', 'hash')): + elif all(key in inputs for key in ("captcha_value", "timestamp", "salt", "hash")): # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 self.logDebug('Using "new" version') @@ -116,7 +105,7 @@ class UlozTo(SimpleHoster): data = json_loads(xapca) captcha_value = self.decryptCaptcha(str(data['image'])) - self.logDebug('CAPTCHA HASH: ' + data['hash'] + ', CAPTCHA SALT: ' + str(data['salt']) + ', CAPTCHA VALUE: ' + captcha_value) + 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: @@ -132,17 +121,17 @@ class UlozTo(SimpleHoster): 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: + m = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html) + if m is None: self.parseError(msg) - parsed_url = "http://www.ulozto.net" + found.group(1) + 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>'), - "offline": re.compile(self.FILE_OFFLINE_PATTERN), + "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>" |