summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-19 00:28:18 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-19 00:28:18 +0200
commita0e2459f2d1506912ac4a5d0c330c8dae01a4768 (patch)
treef7fcbc10a7b1b5b862889b5388b319a43fce7dc9 /module/plugins
parentCode cosmetics (2) (diff)
downloadpyload-a0e2459f2d1506912ac4a5d0c330c8dae01a4768.tar.xz
Improve fixurl method
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/crypter/TurbobitNetFolder.py4
-rw-r--r--module/plugins/internal/Hoster.py12
-rw-r--r--module/plugins/internal/Plugin.py11
-rw-r--r--module/plugins/internal/SimpleHoster.py5
4 files changed, 14 insertions, 18 deletions
diff --git a/module/plugins/crypter/TurbobitNetFolder.py b/module/plugins/crypter/TurbobitNetFolder.py
index f8e56712f..4d07704fb 100644
--- a/module/plugins/crypter/TurbobitNetFolder.py
+++ b/module/plugins/crypter/TurbobitNetFolder.py
@@ -40,9 +40,7 @@ class TurbobitNetFolder(SimpleCrypter):
def get_links(self):
- id = re.match(self.__pattern__, self.pyfile.url).group('ID')
- fixurl = lambda id: "http://turbobit.net/%s.html" % id
- return map(fixurl, self._get_links(id))
+ return ["http://turbobit.net/%s.html" % id for id in self._get_links(self.info['pattern']['ID'])]
getInfo = create_getInfo(TurbobitNetFolder)
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']: