summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/Ftp.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/Ftp.py')
-rw-r--r--module/plugins/hoster/Ftp.py88
1 files changed, 0 insertions, 88 deletions
diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py
deleted file mode 100644
index 546845ca0..000000000
--- a/module/plugins/hoster/Ftp.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import pycurl
-import re
-
-from urllib import quote, unquote
-from urlparse import urlparse
-
-from module.plugins.Hoster import Hoster
-
-
-class Ftp(Hoster):
- __name__ = "Ftp"
- __type__ = "hoster"
- __version__ = "0.50"
-
- __pattern__ = r'(?:ftps?|sftp)://([\w.-]+(:[\w.-]+)?@)?[\w.-]+(:\d+)?/.+'
-
- __description__ = """Download from ftp directory"""
- __license__ = "GPLv3"
- __authors__ = [("jeix", "jeix@hasnomail.com"),
- ("mkaay", "mkaay@mkaay.de"),
- ("zoidberg", "zoidberg@mujmail.cz")]
-
-
- def setup(self):
- self.chunkLimit = -1
- self.resumeDownload = True
-
-
- #: Work-around to `filename*=UTF-8` bug; remove in 0.4.10
- def download(self, url, get={}, post={}, ref=True, cookies=True, disposition=False):
- try:
- if disposition:
- content = urllib2.urlopen(url).info()['Content-Disposition'].split(';')
- self.pyfile.name = content[1].split('filename=')[1].strip('"\'') or self.pyfile.name
- finally:
- return super(Ftp, self).download(url, get, post, ref, cookies, False)
-
-
- 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 Exception:
- 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.getAccountInfo(netloc)['password'])
- else:
- pwd = self.getPassword()
- if ':' in pwd:
- self.req.addAuth(pwd)
-
- self.req.http.c.setopt(pycurl.NOBODY, 1)
-
- try:
- res = 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)
-
- m = re.search(r"Content-Length:\s*(\d+)", res)
- if m:
- pyfile.size = int(m.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
- res = self.load(pyfile.url, decode=False)
- links = [pyfile.url + quote(x) for x in res.splitlines()]
- self.logDebug("LINKS", links)
- self.core.api.addPackage(pkgname, links)
- else:
- self.fail(_("Unexpected server response"))