]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/trutube.py
Merge branch 'peugeot-tnaflix'
[yt-dlp.git] / youtube_dl / extractor / trutube.py
CommitLineData
491ed3dd
PH
1from __future__ import unicode_literals
2
9ddfd84e
JMS
3import re
4
5from .common import InfoExtractor
9ddfd84e
JMS
6
7
8class TruTubeIE(InfoExtractor):
491ed3dd 9 _VALID_URL = r'https?://(?:www\.)?trutube\.tv/video/(?P<id>[0-9]+)/.*'
9ddfd84e 10 _TEST = {
491ed3dd
PH
11 'url': 'http://trutube.tv/video/14880/Ramses-II-Proven-To-Be-A-Red-Headed-Caucasoid-',
12 'md5': 'c5b6e301b0a2040b074746cbeaa26ca1',
9ddfd84e 13 'info_dict': {
491ed3dd
PH
14 'id': '14880',
15 'ext': 'flv',
16 'title': 'Ramses II - Proven To Be A Red Headed Caucasoid',
17 'thumbnail': 're:^http:.*\.jpg$',
9ddfd84e
JMS
18 }
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
491ed3dd 23 video_id = mobj.group('id')
9ddfd84e 24
9ddfd84e 25 webpage = self._download_webpage(url, video_id)
491ed3dd
PH
26 video_title = self._og_search_title(webpage).strip()
27 thumbnail = self._search_regex(
28 r"var splash_img = '([^']+)';", webpage, 'thumbnail', fatal=False)
29
30 all_formats = re.finditer(
31 r"var (?P<key>[a-z]+)_video_file\s*=\s*'(?P<url>[^']+)';", webpage)
32 formats = [{
33 'format_id': m.group('key'),
34 'quality': -i,
35 'url': m.group('url'),
36 } for i, m in enumerate(all_formats)]
37 self._sort_formats(formats)
9ddfd84e
JMS
38
39 return {
40 'id': video_id,
9ddfd84e 41 'title': video_title,
491ed3dd
PH
42 'formats': formats,
43 'thumbnail': thumbnail,
44 }