From 3c9f55270a83b0e88ec0dc516f9d9921e4d7b6ea Mon Sep 17 00:00:00 2001 From: mkaay Date: Wed, 25 Aug 2010 16:48:55 +0200 Subject: merged gui --- core/module/plugins/hoster/Ftp.py | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 core/module/plugins/hoster/Ftp.py (limited to 'core/module/plugins/hoster/Ftp.py') diff --git a/core/module/plugins/hoster/Ftp.py b/core/module/plugins/hoster/Ftp.py new file mode 100644 index 000000000..9303b00c8 --- /dev/null +++ b/core/module/plugins/hoster/Ftp.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: jeix + @author: mkaay +""" + +import logging +from os.path import exists +from os.path import join +from os.path import exists +from os import makedirs +import sys + +from module.plugins.Hoster import Hoster + + +class Ftp(Hoster): + __name__ = "Ftp" + __version__ = "0.3" + __pattern__ = r'ftp://(.*?:.*?@)?.*?/.*' # 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") + + def process(self, pyfile): + self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="FTP") + pyfile.name = self.pyfile.url.rpartition('/')[2] + + self.doDownload(pyfile.url, pyfile.name) + + def doDownload(self, url, filename): + self.pyfile.setStatus("downloading") + + download_folder = self.core.config['general']['download_folder'] + location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) + if not exists(location): + makedirs(location) + + newname = self.req.download(str(url), join(location, filename.decode(sys.getfilesystemencoding()))) + self.pyfile.size = self.req.dl_size + + if newname: + self.pyfile.name = newname -- cgit v1.2.3