diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-09 00:22:51 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-09 00:22:51 +0200 |
commit | 73f99ea811d01a2e113a882fe5ab86b0aa9c4f4c (patch) | |
tree | 88c50e2d5ccf079768111f040c0531f5eee26a97 /module/plugins | |
parent | Merge branch 'pr/n1314_sebdelsol' into stable (diff) | |
download | pyload-73f99ea811d01a2e113a882fe5ab86b0aa9c4f4c.tar.xz |
[SimpleHoster] Improve file name handling
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/crypter/LinkdecrypterCom.py | 1 | ||||
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 6 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 37 |
4 files changed, 24 insertions, 24 deletions
diff --git a/module/plugins/crypter/LinkdecrypterCom.py b/module/plugins/crypter/LinkdecrypterCom.py index c2e3ed91d..0704214d0 100644 --- a/module/plugins/crypter/LinkdecrypterCom.py +++ b/module/plugins/crypter/LinkdecrypterCom.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Crypter import Crypter diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 9e6f2d379..d40b52aa7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -173,7 +173,7 @@ class ExtractArchive(Hook): except OSError, e: if e.errno == 2: - self.logInfo(_("No %s installed") % p) + self.logWarning(_("No %s installed") % p) else: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: @@ -185,7 +185,7 @@ class ExtractArchive(Hook): traceback.print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors)) + self.logDebug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors]) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index cdb37a18c..fbac432cd 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import re -from urllib import unquote +import urllib from BeautifulSoup import BeautifulSoup @@ -53,8 +53,8 @@ class ZippyshareCom(SimpleHoster): else: self.link = self.get_link() - if pyfile.name == 'file.html' and self.link: - pyfile.name = unquote(self.link.split('/')[-1]) + if self.link and pyfile.name == 'file.html': + pyfile.name = urllib.unquote(self.link.split('/')[-1]) def get_link(self): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 8b1527b3e..ac5fbf391 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -5,11 +5,9 @@ import mimetypes import os import re import time +import urllib import urllib2 - -from inspect import isclass -from urllib import unquote -from urlparse import urljoin, urlparse +import urlparse from module.PyFile import statusMap as _statusMap from module.network.CookieJar import CookieJar @@ -109,8 +107,8 @@ def parseFileInfo(plugin, url="", html=""): info = plugin.getInfo(url, html) res = info['name'], info['size'], info['status'], info['url'] else: - url = unquote(url) - url_p = urlparse(url) + url = urllib.unquote(url) + url_p = urlparse.urlparse(url) res = ((url_p.path.split('/')[-1] or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0] or url_p.netloc.split('.', 1)[0]), @@ -186,10 +184,10 @@ def getFileURL(self, url, follow_location=None): elif 'location' in header and header['location'].strip(): location = header['location'] - if not urlparse(location).scheme: - url_p = urlparse(url) + if not urlparse.urlparse(location).scheme: + url_p = urlparse.urlparse(url) baseurl = "%s://%s" % (url_p.scheme, url_p.netloc) - location = urljoin(baseurl, location) + location = urlparse.urljoin(baseurl, location) if 'code' in header and header['code'] == 302: link = location @@ -199,7 +197,7 @@ def getFileURL(self, url, follow_location=None): continue else: - extension = os.path.splitext(urlparse(url).path.split('/')[-1])[-1] + extension = os.path.splitext(urlparse.urlparse(url).path.split('/')[-1])[-1] if 'content-type' in header and header['content-type'].strip(): mimetype = header['content-type'].split(';')[0].strip() @@ -247,7 +245,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.35" + __version__ = "1.36" __pattern__ = r'^unmatchable$' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -323,8 +321,8 @@ class SimpleHoster(Hoster): @classmethod def apiInfo(cls, url="", get={}, post={}): - url = unquote(url) - url_p = urlparse(url) + url = urllib.unquote(url) + url_p = urlparse.urlparse(url) return {'name' : (url_p.path.split('/')[-1] or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0] or url_p.netloc.split('.', 1)[0]), @@ -391,7 +389,7 @@ class SimpleHoster(Hoster): info['status'] = 2 if 'N' in info['pattern']: - info['name'] = replace_patterns(unquote(info['pattern']['N'].strip()), + info['name'] = replace_patterns(urllib.unquote(info['pattern']['N'].strip()), cls.NAME_REPLACEMENTS) if 'S' in info['pattern']: @@ -503,7 +501,9 @@ class SimpleHoster(Hoster): try: if disposition: content = urllib2.urlopen(url).info()['Content-Disposition'].split(';') - self.pyfile.name = content[1].split('filename=')[1][1:-1] or self.pyfile.name + self.pyfile.name = (content[1].split('filename=')[1][1:-1] + or urlparse.urlparse(urllib.unquote(url)).path.split('/')[-1] + or self.pyfile.name) finally: return super(SimpleHoster, self).download(url, get, post, ref, cookies, False) @@ -512,10 +512,10 @@ class SimpleHoster(Hoster): if link and isinstance(link, basestring): self.correctCaptcha() - if not urlparse(link).scheme: - url_p = urlparse(self.pyfile.url) + if not urlparse.urlparse(link).scheme: + url_p = urlparse.urlparse(self.pyfile.url) baseurl = "%s://%s" % (url_p.scheme, url_p.netloc) - link = urljoin(baseurl, link) + link = urlparse.urljoin(baseurl, link) self.download(link, ref=False, disposition=disposition) @@ -679,7 +679,6 @@ class SimpleHoster(Hoster): if link: self.logInfo(_("Direct download link detected")) - self.link = link else: self.logDebug("Direct download link not found") |