summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-18 12:16:49 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-18 12:16:49 +0100
commitb08ac6609f87140d52a00a0ae6c5ce0fbee8f0a1 (patch)
tree035cd8a68c7bbb4374fa0cd47a9d5daff1a91ef1 /module
parent[SimpleHoster] Fix and improve directLink routine (now fileUrl) (diff)
downloadpyload-b08ac6609f87140d52a00a0ae6c5ce0fbee8f0a1.tar.xz
[BasePlugin][SimpleDereferer] Use SimpleHoster fileUrl
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hoster/BasePlugin.py42
-rw-r--r--module/plugins/internal/SimpleDereferer.py6
2 files changed, 12 insertions, 36 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index 6d3132e65..f098111c2 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -6,14 +6,14 @@ from urllib import unquote
from urlparse import urljoin, urlparse
from module.network.HTTPRequest import BadHeader
-from module.plugins.internal.SimpleHoster import create_getInfo
+from module.plugins.internal.SimpleHoster import create_getInfo, fileUrl
from module.plugins.Hoster import Hoster
class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
- __version__ = "0.30"
+ __version__ = "0.31"
__pattern__ = r'^unmatchable$'
@@ -35,7 +35,7 @@ class BasePlugin(Hoster):
def setup(self):
- self.chunkLimit = -1
+ self.chunkLimit = -1
self.resumeDownload = True
@@ -49,7 +49,12 @@ class BasePlugin(Hoster):
for _i in xrange(5):
try:
- self.downloadFile(pyfile)
+ link = fileUrl(unquote(pyfile.url))
+
+ if link:
+ self.download(link, disposition=True)
+ else:
+ self.fail(_("File not found"))
except BadHeader, e:
if e.code is 404:
@@ -85,33 +90,4 @@ class BasePlugin(Hoster):
self.fail(check.capitalize())
- def downloadFile(self, pyfile):
- url = pyfile.url
-
- for i in xrange(1, 7): #@TODO: retrieve the pycurl.MAXREDIRS value set by req
- header = self.load(url, ref=True, cookies=True, just_header=True, decode=True)
-
- if 'location' not in header or not header['location']:
- if 'code' in header and header['code'] not in (200, 201, 203, 206):
- self.logDebug("Received HTTP status code: %d" % header['code'])
- self.fail(_("File not found"))
- else:
- break
-
- location = header['location']
-
- self.logDebug("Redirect #%d to: %s" % (i, location))
-
- if urlparse(location).scheme:
- url = location
- else:
- p = urlparse(url)
- base = "%s://%s" % (p.scheme, p.netloc)
- url = urljoin(base, location)
- else:
- self.fail(_("Too many redirects"))
-
- self.download(unquote(url), disposition=True)
-
-
getInfo = create_getInfo(BasePlugin)
diff --git a/module/plugins/internal/SimpleDereferer.py b/module/plugins/internal/SimpleDereferer.py
index 53b80f827..deef42620 100644
--- a/module/plugins/internal/SimpleDereferer.py
+++ b/module/plugins/internal/SimpleDereferer.py
@@ -5,13 +5,13 @@ import re
from urllib import unquote
from module.plugins.Crypter import Crypter
-from module.plugins.internal.SimpleHoster import directLink, set_cookies
+from module.plugins.internal.SimpleHoster import fileUrl, set_cookies
class SimpleDereferer(Crypter):
__name__ = "SimpleDereferer"
__type__ = "crypter"
- __version__ = "0.03"
+ __version__ = "0.04"
__pattern__ = r'^unmatchable$'
__config__ = [("use_subfolder", "bool", "Save package to subfolder", True),
@@ -45,7 +45,7 @@ class SimpleDereferer(Crypter):
def decrypt(self, pyfile):
- link = directLink(self, pyfile.url)
+ link = fileUrl(self, pyfile.url)
if not link:
try: