summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/BasePlugin.py58
-rw-r--r--module/plugins/hoster/Ftp.py73
-rw-r--r--module/plugins/hoster/UptoboxCom.py20
3 files changed, 116 insertions, 35 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index 1ac33931f..14dfbba62 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -12,10 +12,10 @@ class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
__pattern__ = r"^unmatchable$"
- __version__ = "0.151"
+ __version__ = "0.16"
__description__ = """Base Plugin when any other didnt fit"""
- __author_name__ = ("RaNaN", 'hagg')
- __author_mail__ = ("RaNaN@pyload.org", '')
+ __author_name__ = ("RaNaN")
+ __author_mail__ = ("RaNaN@pyload.org")
def setup(self):
self.chunkLimit = -1
@@ -47,15 +47,22 @@ class BasePlugin(Hoster):
except BadHeader, e:
if e.code in (401, 403):
self.logDebug("Auth required")
-
- pwd = pyfile.package().password.strip()
- if ":" not in pwd:
- self.fail(_("Authorization required (username:password)"))
-
- self.req.addAuth(pwd)
+
+ servers = [ x['login'] for x in core.accountManager.getAccountPlugin('Http').getAllAccounts() ]
+ server = urlparse(pyfile.url).netloc
+
+ if server in servers:
+ self.logDebug("Logging on to %s" % server)
+ self.req.addAuth(self.account.accounts[server]["password"])
+ else:
+ for pwd in pyfile.package().password.splitlines()
+ if ":" in pwd:
+ self.req.addAuth(pwd.strip())
+ break
+ else:
+ self.fail(_("Authorization required (username:password)"))
+
self.downloadFile(pyfile)
- elif e.code == 404:
- self.offline()
else:
raise
@@ -64,18 +71,21 @@ class BasePlugin(Hoster):
def downloadFile(self, pyfile):
- header = self.load(pyfile.url, just_header = True)
- #self.logDebug(header)
-
- # self.load does not raise a BadHeader on 404 responses, do it here
- if header.has_key('code') and header['code'] == 404:
- raise BadHeader(404)
-
- if 'location' in header:
- self.logDebug("Location: " + header['location'])
- url = unquote(header['location'])
- else:
- url = pyfile.url
+ url = pyfile.url
+
+ for i in range(5):
+ header = self.load(pyfile.url, just_header = True)
+
+ # self.load does not raise a BadHeader on 404 responses, do it here
+ if header.has_key('code') and header['code'] == 404:
+ raise BadHeader(404)
+
+ if 'location' in header:
+ self.logDebug("Location: " + header['location'])
+ url = unquote(header['location'])
+ self.logDebug("URL: %s" % url, html_unescape(unquote(urlparse(url).path.split("/")[-1])))
+ else:
+ break
name = html_unescape(unquote(urlparse(url).path.split("/")[-1]))
@@ -92,4 +102,4 @@ class BasePlugin(Hoster):
if not name: name = url
pyfile.name = name
self.logDebug("Filename: %s" % pyfile.name)
- self.download(url, disposition=True)
+ self.download(url, disposition=True) \ No newline at end of file
diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py
index 7c2af85ed..3bda3b32e 100644
--- a/module/plugins/hoster/Ftp.py
+++ b/module/plugins/hoster/Ftp.py
@@ -17,24 +17,75 @@
@author: jeix
@author: mkaay
"""
+from urlparse import urlparse, urljoin
+from urllib import quote, unquote
+import pycurl, re
from module.plugins.Hoster import Hoster
-
+from module.network.HTTPRequest import BadHeader
class Ftp(Hoster):
__name__ = "Ftp"
- __version__ = "0.31"
+ __version__ = "0.41"
__pattern__ = r'(ftps?|sftp)://(.*?:.*?@)?.*?/.*' # ftp://user:password@ftp.server.org/path/to/file
__type__ = "hoster"
__description__ = """A Plugin that allows you to download from an from an ftp directory"""
- __author_name__ = ("jeix", "mkaay")
- __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de")
+ __author_name__ = ("jeix", "mkaay", "zoidberg")
+ __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de", "zoidberg@mujmail.cz")
- def process(self, pyfile):
- pyfile.name = self.pyfile.url.rpartition('/')[2]
-
+ def setup(self):
self.chunkLimit = -1
- self.resumeDownload = True
-
- self.download(pyfile.url)
-
+ self.resumeDownload = True
+
+ def process(self, pyfile):
+ parsed_url = urlparse(pyfile.url)
+ netloc = parsed_url.netloc
+
+ pyfile.name = parsed_url.path.rpartition('/')[2]
+ try:
+ pyfile.name = unquote(str(pyfile.name)).decode('utf8')
+ except:
+ pass
+
+ if not "@" in netloc:
+ servers = [ x['login'] for x in self.account.getAllAccounts() ] if self.account else []
+
+ if netloc in servers:
+ self.logDebug("Logging on to %s" % netloc)
+ self.req.addAuth(self.account.accounts[netloc]["password"])
+ else:
+ for pwd in pyfile.package().password.splitlines():
+ if ":" in pwd:
+ self.req.addAuth(pwd.strip())
+ break
+
+ self.req.http.c.setopt(pycurl.NOBODY, 1)
+
+ try:
+ response = self.load(pyfile.url)
+ except pycurl.error, e:
+ self.fail("Error %d: %s" % e.args)
+
+ self.req.http.c.setopt(pycurl.NOBODY, 0)
+ self.logDebug(self.req.http.header)
+
+ found = re.search(r"Content-Length:\s*(\d+)", response)
+ if found:
+ pyfile.size = int(found.group(1))
+ self.download(pyfile.url)
+ else:
+ #Naive ftp directory listing
+ if re.search(r'^25\d.*?"', self.req.http.header, re.M):
+ pyfile.url = pyfile.url.rstrip('/')
+ pkgname = "/".join((pyfile.package().name,urlparse(pyfile.url).path.rpartition('/')[2]))
+ pyfile.url += '/'
+ self.req.http.c.setopt(48, 1) # CURLOPT_DIRLISTONLY
+ response = self.load(pyfile.url, decode = False)
+ links = [ pyfile.url + quote(x) for x in response.splitlines() ]
+ self.logDebug("LINKS", links)
+ self.core.api.addPackage(pkgname, links, 1)
+ #self.core.files.addLinks(links, pyfile.package().id)
+ else:
+ self.fail("Unexpected server response")
+
+ \ No newline at end of file
diff --git a/module/plugins/hoster/UptoboxCom.py b/module/plugins/hoster/UptoboxCom.py
new file mode 100644
index 000000000..ae2f14a14
--- /dev/null
+++ b/module/plugins/hoster/UptoboxCom.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo
+
+class UptoboxCom(XFileSharingPro):
+ __name__ = "UptoboxCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(?:\w*\.)*?uptobox.com/\w{12}"
+ __version__ = "0.06"
+ __description__ = """Uptobox.com hoster plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FILE_INFO_PATTERN = r'<h2>\s*Download File\s*<span[^>]*>(?P<N>[^>]+)</span></h2>\s*[^\(]*\((?P<S>[^\)]+)\)</h2>'
+ HOSTER_NAME = "uptobox.com"
+
+ def setup(self):
+ self.resumeDownload = self.multiDL = self.premium
+ self.chunkLimit = 1
+
+getInfo = create_getInfo(UptoboxCom) \ No newline at end of file