summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-20 02:46:39 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-20 02:46:39 +0100
commit96ee02d0120690291962269d23f1a324ff674e99 (patch)
tree2f15ec0ac7c0116c0edfe6d618b1a34e2527053c /module
parent[UlozTo] Fix handlePremium (thx kmarty-cz) (diff)
downloadpyload-96ee02d0120690291962269d23f1a324ff674e99.tar.xz
[SimpleHoster] Improve getInfo
Diffstat (limited to 'module')
-rw-r--r--module/plugins/internal/MultiHoster.py11
-rw-r--r--module/plugins/internal/SimpleHoster.py41
2 files changed, 36 insertions, 16 deletions
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index 24dcf64c7..eee634d46 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, r
class MultiHoster(SimpleHoster):
__name__ = "MultiHoster"
__type__ = "hoster"
- __version__ = "0.34"
+ __version__ = "0.35"
__pattern__ = r'^unmatchable$'
@@ -70,17 +70,10 @@ class MultiHoster(SimpleHoster):
self.logDebug("Handled as free download")
self.handleFree(pyfile)
- self.downloadLink(self.link)
+ self.downloadLink(self.link, True)
self.checkFile()
- #@TODO: Remove in 0.4.10
- def downloadLink(self, link):
- if link and isinstance(link, basestring):
- self.correctCaptcha()
- self.download(link, disposition=True)
-
-
def handlePremium(self, pyfile):
return self.handleFree(pyfile)
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 78f5e531d..819572a7e 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -151,9 +151,33 @@ def fileUrl(self, url, follow_location=False):
redirect = max(follow_location, 1)
for i in xrange(redirect):
- self.logDebug("Redirect #%d to: %s" % (i, url))
+ try:
+ self.logDebug("Redirect #%d to: %s" % (i, url))
+ header = self.load(url, ref=True, cookies=True, just_header=True, decode=True)
+
+ except Exception: #: Bad bad bad...
+ req = pyreq.getHTTPRequest()
+ res = req.load(url, cookies=True, just_header=True, decode=True)
+
+ req.close()
+
+ header = {"code": req.code}
+ for line in res.splitlines():
+ line = line.strip()
+ if not line or ":" not in line:
+ continue
+
+ key, none, value = line.partition(":")
+ key = key.lower().strip()
+ value = value.strip()
- header = self.load(url, ref=True, cookies=True, just_header=True, decode=True)
+ if key in header:
+ if type(header[key]) == list:
+ header[key].append(value)
+ else:
+ header[key] = [header[key], value]
+ else:
+ header[key] = value
if 'content-disposition' in header:
link = url
@@ -193,7 +217,10 @@ def fileUrl(self, url, follow_location=False):
break
else:
- self.logError(_("Too many redirects"))
+ try:
+ self.logError(_("Too many redirects"))
+ except Exception:
+ pass
return link
@@ -219,7 +246,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.05"
+ __version__ = "1.06"
__pattern__ = r'^unmatchable$'
@@ -320,7 +347,7 @@ class SimpleHoster(Hoster):
info['error'] = "missing url"
info['status'] = 1
- elif info['status'] is 3:
+ elif info['status'] is 3 and not fileUrl(None, url):
try:
html = getURL(url, cookies=cls.COOKIES, decode=not cls.TEXT_ENCODING)
@@ -464,7 +491,7 @@ class SimpleHoster(Hoster):
self.checkFile()
- def downloadLink(self, link):
+ def downloadLink(self, link, disposition=False):
if link and isinstance(link, basestring):
self.correctCaptcha()
@@ -473,7 +500,7 @@ class SimpleHoster(Hoster):
baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
link = urljoin(baseurl, link)
- self.download(link, disposition=False) #@TODO: Set `disposition=True` in 0.4.10
+ self.download(link, disposition=disposition) #@TODO: Set `disposition=True` in 0.4.10
def checkFile(self):