]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/redtube.py
[muzu] Modernize
[yt-dlp.git] / youtube_dl / extractor / redtube.py
CommitLineData
032b3df5
PH
1from __future__ import unicode_literals
2
9f5daf00
PH
3import re
4
5from .common import InfoExtractor
9f5daf00
PH
6
7
8class RedTubeIE(InfoExtractor):
c1152961 9 _VALID_URL = r'http://(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
6f5ac90c 10 _TEST = {
032b3df5
PH
11 'url': 'http://www.redtube.com/66418',
12 'file': '66418.mp4',
d1c25204
PH
13 # md5 varies from time to time, as in
14 # https://travis-ci.org/rg3/youtube-dl/jobs/14052463#L295
032b3df5
PH
15 #'md5': u'7b8c22b5e7098a3e1c09709df1126d2d',
16 'info_dict': {
17 "title": "Sucked on a toilet",
18 "age_limit": 18,
6f5ac90c
PH
19 }
20 }
9f5daf00 21
cd214418 22 def _real_extract(self, url):
9f5daf00 23 mobj = re.match(self._VALID_URL, url)
9f5daf00
PH
24
25 video_id = mobj.group('id')
cd214418 26 video_extension = 'mp4'
9f5daf00
PH
27 webpage = self._download_webpage(url, video_id)
28
29 self.report_extraction(video_id)
30
cd214418
PH
31 video_url = self._html_search_regex(
32 r'<source src="(.+?)" type="video/mp4">', webpage, u'video URL')
9f5daf00 33
cd214418 34 video_title = self._html_search_regex(
938384c5 35 r'<h1 class="videoTitle[^"]*">(.+?)</h1>',
9f5daf00
PH
36 webpage, u'title')
37
530ed178 38 video_thumbnail = self._og_search_thumbnail(webpage)
9d11a41f 39
1310bf24
PH
40 # No self-labeling, but they describe themselves as
41 # "Home of Videos Porno"
42 age_limit = 18
43
cd214418 44 return {
032b3df5
PH
45 'id': video_id,
46 'url': video_url,
47 'ext': video_extension,
48 'title': video_title,
9d11a41f 49 'thumbnail': video_thumbnail,
1310bf24 50 'age_limit': age_limit,
cd214418 51 }