diff options
author | mkaay <mkaay@mkaay.de> | 2010-12-21 18:20:30 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-12-21 18:20:30 +0100 |
commit | 7fa32641f04e93681d21f04022af673aa2c8c31a (patch) | |
tree | 4df57c1c8280a3bcebb619ce4bc04a10cbef1741 /module/plugins/hoster | |
parent | improved bucket (diff) | |
download | pyload-7fa32641f04e93681d21f04022af673aa2c8c31a.tar.xz |
new download backend: wrapped deferred, Request compatibility draft, other fixes
added caution's fixes (VeehdCom, PornhubCom)
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/PornhubCom.py | 16 | ||||
-rw-r--r-- | module/plugins/hoster/VeehdCom.py | 80 |
2 files changed, 92 insertions, 4 deletions
diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 2df7ba452..6afa9d295 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -8,7 +8,7 @@ class PornhubCom(Hoster): __name__ = "PornhubCom"
__type__ = "hoster"
__pattern__ = r'http://[\w\.]*?pornhub\.com/view_video\.php\?viewkey=[\w\d]+'
- __version__ = "0.2"
+ __version__ = "0.3"
__description__ = """Pornhub.com Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
@@ -48,10 +48,18 @@ class PornhubCom(Hoster): def get_file_name(self):
if self.html is None:
self.download_html()
-
- name = re.findall('<h1>(.*?)</h1>', self.html)[1] + ".flv"
- return name
+ match = re.search(r'<title[^>]+>([^<]+) - ', self.html)
+ if match:
+ name = re.group(1)
+ else:
+ matches = re.findall('<h1>(.*?)</h1>', self.html)
+ if len(matches) > 1:
+ name = matches[1]
+ else:
+ name = matches[0]
+
+ return name + '.flv'
def file_exists(self):
""" returns True or False
diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py new file mode 100644 index 000000000..06e59c7fa --- /dev/null +++ b/module/plugins/hoster/VeehdCom.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import re +from module.plugins.Hoster import Hoster + +class VeehdCom(Hoster): + __name__ = 'VeehdCom' + __type__ = 'hoster' + __pattern__ = r'http://veehd\.com/video/\d+_\S+' + __config__ = [ + ('filename_spaces', 'bool', "Allow spaces in filename", 'False'), + ('replacement_char', 'str', "Filename replacement character", '_'), + ] + __version__ = '0.1' + __description__ = """Veehd.com Download Hoster""" + __author_name__ = ('cat') + __author_mail__ = ('cat@pyload') + + def _debug(self, msg): + self.log.debug('[%s] %s' % (self.__name__, msg)) + + def setup(self): + self.html = None + self.multiDL = True + self.req.canContinue = True + + def process(self, pyfile): + self.download_html() + if not self.file_exists(): + self.offline() + + pyfile.name = self.get_file_name() + self.download(self.get_file_url()) + + def download_html(self): + url = self.pyfile.url + self._debug("Requesting page: %s" % (repr(url),)) + self.html = self.load(url) + + def file_exists(self): + if self.html is None: + self.download_html() + + if '<title>Veehd</title>' in self.html: + return False + return True + + def get_file_name(self): + if self.html is None: + self.download_html() + + match = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) + if not match: + self.fail("video title not found") + name = match.group(1) + + # replace unwanted characters in filename + if self.getConf('filename_spaces'): + pattern = '[^0-9A-Za-z\.\ ]+' + else: + pattern = '[^0-9A-Za-z\.]+' + + name = re.sub('[^0-9A-Za-z\.]+', self.getConf('replacement_char'), + name) + return name + '.avi' + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html is None: + self.download_html() + + match = re.search(r'<embed type="video/divx" ' + r'src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', + self.html) + if not match: + self.fail("embedded video url not found") + file_url = match.group(1) + + return file_url |