Simplify RedTube

master
Philipp Hagemeister 2013-05-03 20:07:35 +02:00
parent 5e34d2ebbf
commit c34407d16c
3 changed files with 16 additions and 17 deletions

View File

@ -405,7 +405,7 @@
} }
}, },
{ {
"name": "Redtube", "name": "RedTube",
"url": "http://www.redtube.com/66418", "url": "http://www.redtube.com/66418",
"file": "66418.mp4", "file": "66418.mp4",
"md5": "7b8c22b5e7098a3e1c09709df1126d2d", "md5": "7b8c22b5e7098a3e1c09709df1126d2d",

View File

@ -4183,31 +4183,29 @@ class BandcampIE(InfoExtractor):
return [track_info] return [track_info]
class RedtubeIE(InfoExtractor): class RedTubeIE(InfoExtractor):
"""Information Extractor for redtube""" """Information Extractor for redtube"""
_VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)' _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
IE_NAME = u'redtube'
def _real_extract(self,url): def _real_extract(self,url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
if mobj is None: if mobj is None:
self._downloader.report_error(u'invalid URL: %s' % url) raise ExtractorError(u'Invalid URL: %s' % url)
return
video_id = mobj.group('id') video_id = mobj.group('id')
video_extension = 'mp4' video_extension = 'mp4'
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
self.report_extraction(video_id) self.report_extraction(video_id)
mobj = re.search(r'<source src="'+'(.+)'+'" type="video/mp4">',webpage) mobj = re.search(r'<source src="'+'(.+)'+'" type="video/mp4">',webpage)
if mobj is not None:
video_url = mobj.group(1) if mobj is None:
else: raise ExtractorError(u'Unable to extract media URL')
self._downloader.report_error(u'unable to extract media URL')
return video_url = mobj.group(1)
mobj = re.search('<h1 class="videoTitle slidePanelMovable">'+r'(.+)'+r'</h1>',webpage) mobj = re.search('<h1 class="videoTitle slidePanelMovable">(.+)</h1>',webpage)
if mobj is not None: if mobj is None:
video_title = mobj.group(1) raise ExtractorError(u'Unable to extract title')
else: video_title = mobj.group(1)
video_title = 'Redtube - %s' % time.ctime()
return [{ return [{
'id': video_id, 'id': video_id,
@ -4272,7 +4270,7 @@ def gen_extractors():
ARDIE(), ARDIE(),
TumblrIE(), TumblrIE(),
BandcampIE(), BandcampIE(),
RedtubeIE(), RedTubeIE(),
GenericIE() GenericIE()
] ]

View File

@ -388,7 +388,8 @@ def _real_main(argv=None):
if 'http' in proxies and 'https' not in proxies: if 'http' in proxies and 'https' not in proxies:
proxies['https'] = proxies['http'] proxies['https'] = proxies['http']
proxy_handler = compat_urllib_request.ProxyHandler(proxies) proxy_handler = compat_urllib_request.ProxyHandler(proxies)
opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler()) https_handler = compat_urllib_request.HTTPSHandler()
opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, YoutubeDLHandler())
compat_urllib_request.install_opener(opener) compat_urllib_request.install_opener(opener)
socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words) socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)