diff options
author | Jeix <devnull@localhost> | 2010-08-01 14:11:19 +0200 |
---|---|---|
committer | Jeix <devnull@localhost> | 2010-08-01 14:11:19 +0200 |
commit | f94a0a5d7b74ca430a81084d843f0c096c2b4551 (patch) | |
tree | 17479ca12d17620c8fd5969a1dcd4e5c1387b516 /module/plugins/hoster | |
parent | some fixes (diff) | |
download | pyload-f94a0a5d7b74ca430a81084d843f0c096c2b4551.tar.xz |
plugin updates to new interface
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/Ftp.py | 42 | ||||
-rw-r--r-- | module/plugins/hoster/PornhostCom.py | 19 | ||||
-rw-r--r-- | module/plugins/hoster/PornhubCom.py | 21 | ||||
-rw-r--r-- | module/plugins/hoster/RedtubeCom.py | 17 | ||||
-rw-r--r-- | module/plugins/hoster/Xdcc.py | 59 |
5 files changed, 83 insertions, 75 deletions
diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 83daa9257..42ee0f53f 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -29,38 +29,34 @@ from module.plugins.Hoster import Hoster class Ftp(Hoster):
__name__ = "Ftp"
- __version__ = "0.1"
+ __version__ = "0.2"
__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")
__author_mail__ = ("jeix@hasnomail.com")
- def __init__(self, parent):
- self.parent = parent
- self.req = parent.core.requestFactory.getRequest(self.__name__, type="FTP")
- self.want_reconnect = False
- self.multi_dl = True
- self.logger = logging.getLogger("log")
- self.pyfile = self.parent
+ def process(self, pyfile):
+ self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="FTP")
+ pyfile.name = get_file_name()
+
+ self.doDownload(pyfile.url, pyfile.name)
- def prepare(self, thread):
- self.pyfile.status.url = self.parent.url
- self.pyfile.status.filename = self.get_file_name()
- thread.wait(self.parent)
- return True
def get_file_name(self):
return self.parent.url.rpartition('/')[2]
+
+
+ def doDownload(self, url, filename):
+ self.pyfile.setStatus("downloading")
+
+ download_folder = self.config['general']['download_folder']
+ location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
+ if not exists(location):
+ makedirs(location)
- def proceed(self, url, location):
- download_folder = self.parent.core.config['general']['download_folder']
- if self.pyfile.package.data["package_name"] != (self.parent.core.config['general']['link_file']) and self.parent.core.xmlconfig.get("general", "folder_per_package", False):
- self.pyfile.folder = self.pyfile.package.data["package_name"]
- location = join(download_folder, self.pyfile.folder.decode(sys.getfilesystemencoding()))
- if not exists(location): makedirs(location)
- file_path = join(location.decode(sys.getfilesystemencoding()), self.pyfile.status.filename.decode(sys.getfilesystemencoding()))
- else:
- file_path = join(download_folder, self.pyfile.status.filename.decode(sys.getfilesystemencoding()))
+ newname = self.req.download(url, join(location,filename.decode(sys.getfilesystemencoding())))
+ self.pyfile.size = self.req.dl_size
- self.pyfile.status.filename = self.req.download(url, file_path)
+ if newname:
+ self.pyfile.name = newname
diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index db256c2ec..5dd681b5b 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -8,19 +8,24 @@ class PornhostCom(Hoster): __name__ = "PornhostCom"
__type__ = "hoster"
__pattern__ = r'http://[\w\.]*?pornhost\.com/([0-9]+/[0-9]+\.html|[0-9]+)'
- __version__ = "0.1"
+ __version__ = "0.2"
__description__ = """Pornhost.com Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
- def __init__(self, parent):
- Hoster.__init__(self, parent)
- self.parent = parent
- self.html = None
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ self.download(self.get_file_url())
+
+ ### old interface
def download_html(self):
- url = self.parent.url
- self.html = self.req.load(url)
+ url = self.pyfile.url
+ self.html = self.load(url)
def get_file_url(self):
""" returns the absolute downloadable filepath
diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 61c388fec..ea7e1423c 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -8,19 +8,22 @@ class PornhubCom(Hoster): __name__ = "PornhubCom"
__type__ = "hoster"
__pattern__ = r'http://[\w\.]*?pornhub\.com/view_video\.php\?viewkey=[\w\d]+'
- __version__ = "0.1"
+ __version__ = "0.2"
__description__ = """Pornhub.com Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
- def __init__(self, parent):
- Hoster.__init__(self, parent)
- self.parent = parent
- self.html = None
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ self.download(self.get_file_url())
def download_html(self):
- url = self.parent.url
- self.html = self.req.load(url)
+ url = self.pyfile.url
+ self.html = self.load(url)
def get_file_url(self):
""" returns the absolute downloadable filepath
@@ -29,7 +32,7 @@ class PornhubCom(Hoster): self.download_html()
url = "http://www.pornhub.com//gateway.php"
- video_id = self.parent.url.split('=')[-1]
+ video_id = self.pyfile.url.split('=')[-1]
# thanks to jD team for this one v
post_data = "\x00\x03\x00\x00\x00\x01\x00\x0c\x70\x6c\x61\x79\x65\x72\x43\x6f\x6e\x66\x69\x67\x00\x02\x2f\x31\x00\x00\x00\x44\x0a\x00\x00\x00\x03\x02\x00"
post_data += chr(len(video_id))
@@ -37,7 +40,7 @@ class PornhubCom(Hoster): post_data += "\x02\x00\x02\x2d\x31\x02\x00\x20"
post_data += "add299463d4410c6d1b1c418868225f7"
- content = self.req.load(url, post=post_data, no_post_encode=True)
+ content = self.req.load(url, post=str(post_data), no_post_encode=True)
file_url = re.search(r'flv_url.*(http.*?)\?r=.*', content).group(1)
return file_url
diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index 6cbd6416e..6a9baffbe 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -9,19 +9,22 @@ class RedtubeCom(Hoster): __name__ = "RedtubeCom"
__type__ = "hoster"
__pattern__ = r'http://[\w\.]*?redtube\.com/\d+'
- __version__ = "0.1"
+ __version__ = "0.2"
__description__ = """Redtube.com Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
- def __init__(self, parent):
- Hoster.__init__(self, parent)
- self.parent = parent
- self.html = None
+ def process(self, pyfile):
+ self.download_html()
+ if not self.file_exists():
+ offline()
+
+ pyfile.name = self.get_file_name()
+ self.download(self.get_file_url())
def download_html(self):
- url = self.parent.url
- self.html = self.req.load(url)
+ url = self.pyfile.url
+ self.html = self.load(url)
def get_file_url(self):
""" returns the absolute downloadable filepath
diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 4c529b3bc..52ece4ca4 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -30,41 +30,42 @@ from module.plugins.Hoster import Hoster class Xdcc(Hoster):
__name__ = "Xdcc"
- __version__ = "0.1"
- __pattern__ = r'xdcc://.*?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/[XDCC]|Shit/#0004/
+ __version__ = "0.2"
+ __pattern__ = r'xdcc://.*?(/#?.*?)?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/#channel/[XDCC]|Shit/#0004/
__type__ = "hoster"
+ __config__ = [
+ ("nick", "str", "Nickname", "pyload"),
+ ("ident", "str", "Ident", "pyloadident"),
+ ("realname", "str", "Realname", "pyloadreal")
+ ]
__description__ = """A Plugin that allows you to download from an IRC XDCC bot"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.com")
- def __init__(self, parent):
- self.parent = parent
- self.req = parent.core.requestFactory.getRequest(self.__name__, type="XDCC")
- self.want_reconnect = False
- self.multi_dl = True
- self.logger = logging.getLogger("log")
- self.pyfile = self.parent
+ def process(self, pyfile):
+ self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC")
+ self.doDownload(pyfile.url)
- def prepare(self, thread):
- self.pyfile.status.url = self.parent.url
- thread.wait(self.parent)
- return True
+ def doDownload(self, url):
+ self.pyfile.setStatus("downloading")
- def proceed(self, url, location):
- download_folder = self.parent.core.config['general']['download_folder']
- location = download_folder
- if self.pyfile.package.data["package_name"] != (self.parent.core.config['general']['link_file']) and self.parent.core.xmlconfig.get("general", "folder_per_package", False):
- self.pyfile.folder = self.pyfile.package.data["package_name"]
- location = join(download_folder, self.pyfile.folder.decode(sys.getfilesystemencoding()))
- if not exists(location):
- makedirs(location)
-
- m = re.search(r'xdcc://(.*?)/(.*?)/#?(\d+)/?', url)
+ download_folder = self.config['general']['download_folder']
+ location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
+ if not exists(location):
+ makedirs(location)
+
+ m = re.search(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url)
server = m.group(1)
- bot = m.group(2)
- pack = m.group(3)
- nick = self.parent.core.config['xdcc']['nick']
- ident = self.parent.core.config['xdcc']['ident']
- real = self.parent.core.config['xdcc']['realname']
+ chan = m.group(2)
+ bot = m.group(3)
+ pack = m.group(4)
+ nick = self.getConf('nick')
+ ident = self.getConf('ident')
+ real = self.getConf('realname')
- self.pyfile.status.filename = self.req.download(bot, pack, location, nick, ident, real, server)
+ newname = self.req.download(bot, pack, location, nick, ident, real, chan, server)
+ self.pyfile.size = self.req.dl_size
+
+ if newname:
+ self.pyfile.name = newname
+
\ No newline at end of file |