[redtube] move into own file
[youtube-dl] / youtube_dl / extractor / redtube.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5     ExtractorError,
6 )
7
8
9 class RedTubeIE(InfoExtractor):
10     _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
11
12     def _real_extract(self,url):
13         mobj = re.match(self._VALID_URL, url)
14         if mobj is None:
15             raise ExtractorError(u'Invalid URL: %s' % url)
16
17         video_id = mobj.group('id')
18         video_extension = 'mp4'        
19         webpage = self._download_webpage(url, video_id)
20
21         self.report_extraction(video_id)
22
23         video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
24             webpage, u'video URL')
25
26         video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
27             webpage, u'title')
28
29         return [{
30             'id':       video_id,
31             'url':      video_url,
32             'ext':      video_extension,
33             'title':    video_title,
34         }]