diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-19 00:28:18 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-19 00:28:18 +0200 |
commit | a0e2459f2d1506912ac4a5d0c330c8dae01a4768 (patch) | |
tree | f7fcbc10a7b1b5b862889b5388b319a43fce7dc9 /module/plugins/internal | |
parent | Code cosmetics (2) (diff) | |
download | pyload-a0e2459f2d1506912ac4a5d0c330c8dae01a4768.tar.xz |
Improve fixurl method
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/Hoster.py | 12 | ||||
-rw-r--r-- | module/plugins/internal/Plugin.py | 11 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 5 |
3 files changed, 13 insertions, 15 deletions
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index c0e374a86..e7df336b6 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -6,7 +6,6 @@ import inspect import os import random import time -import urllib import urlparse if os.name != "nt": @@ -14,7 +13,7 @@ if os.name != "nt": import pwd from module.plugins.internal.Plugin import (Plugin, Abort, Fail, Reconnect, Retry, Skip - chunks, replace_patterns, seconds_to_midnight, + chunks, fixurl as _fixurl, replace_patterns, seconds_to_midnight, set_cookies, parse_html_form, parse_html_tag_attr_value, timestamp) from module.utils import fs_decode, fs_encode, save_join as fs_join @@ -135,7 +134,7 @@ class Hoster(Plugin): @classmethod def get_info(cls, url="", html=""): - url = urllib.unquote(url) + url = _fixurl(url) url_p = urlparse.urlparse(url) return {'name' : (url_p.path.split('/')[-1] or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0] @@ -412,12 +411,11 @@ class Hoster(Plugin): def fixurl(self, url): - url_p = urlparse.urlparse(self.pyfile.url) - baseurl = "%s://%s" % (url_p.scheme, url_p.netloc) - - url = super(Hoster, self).fixurl(url) + url = _fixurl(url) if not urlparse.urlparse(url).scheme: + url_p = urlparse.urlparse(self.pyfile.url) + baseurl = "%s://%s" % (url_p.scheme, url_p.netloc) url = urlparse.urljoin(baseurl, url) return url diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 51f952b40..93dd2ecbe 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -12,6 +12,11 @@ from module.utils import fs_encode, fs_decode, html_unescape, save_join as fs_jo #@TODO: Move to utils in 0.4.10 +def fixurl(url): + return html_unescape(urllib.unquote(url.decode('unicode-escape'))).strip() + + +#@TODO: Move to utils in 0.4.10 def timestamp(): return int(time.time() * 1000) @@ -256,10 +261,6 @@ class Plugin(object): raise Fail(msg) - def fixurl(self, url): - return html_unescape(urllib.unquote(url.decode('unicode-escape'))).strip() - - def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=True, multipart=True, req=None): """ Load content at url and returns it @@ -276,7 +277,7 @@ class Plugin(object): if hasattr(self, 'pyfile') and self.pyfile.abort: self.abort() - url = self.fixurl(url) + url = fixurl(url) if not url or not isinstance(url, basestring): self.fail(_("No url given")) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 08f13f900..5bf2f0417 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -7,14 +7,13 @@ import mimetypes import os import re import time -import urllib import urlparse from module.PyFile import statusMap as _statusMap from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster, create_getInfo, parse_fileInfo -from module.plugins.internal.Plugin import Fail, Retry, replace_patterns, set_cookies +from module.plugins.internal.Plugin import Fail, Retry, fixurl, replace_patterns, set_cookies from module.utils import fixup, fs_encode, parseFileSize as parse_size @@ -176,7 +175,7 @@ class SimpleHoster(Hoster): info['status'] = 2 if 'N' in info['pattern']: - info['name'] = replace_patterns(urllib.unquote(info['pattern']['N'].strip()), + info['name'] = replace_patterns(fixurl(info['pattern']['N']), cls.NAME_REPLACEMENTS) if 'S' in info['pattern']: |