]>
Commit | Line | Data |
---|---|---|
f0f3a6c9 | 1 | from .common import InfoExtractor |
2c919adb | 2 | from ..utils import ExtractorError |
f0f3a6c9 | 3 | |
4 | ||
d9ab5262 | 5 | class RTVNHIE(InfoExtractor): |
f0f3a6c9 | 6 | _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P<id>[0-9]+)' |
7 | _TEST = { | |
f0f3a6c9 | 8 | 'url': 'http://www.rtvnh.nl/video/131946', |
e3f88be7 | 9 | 'md5': 'cdbec9f44550763c8afc96050fa747dc', |
f0f3a6c9 | 10 | 'info_dict': { |
11 | 'id': '131946', | |
12 | 'ext': 'mp4', | |
13 | 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw', | |
ec85ded8 | 14 | 'thumbnail': r're:^https?:.*\.jpg$' |
f0f3a6c9 | 15 | } |
16 | } | |
17 | ||
18 | def _real_extract(self, url): | |
19 | video_id = self._match_id(url) | |
240ca32e S |
20 | |
21 | meta = self._parse_json(self._download_webpage( | |
22 | 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) | |
2c919adb S |
23 | |
24 | status = meta.get('status') | |
25 | if status != 200: | |
26 | raise ExtractorError( | |
27 | '%s returned error code %d' % (self.IE_NAME, status), expected=True) | |
28 | ||
e3f88be7 RA |
29 | formats = [] |
30 | rtmp_formats = self._extract_smil_formats( | |
31 | 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id) | |
32 | formats.extend(rtmp_formats) | |
33 | ||
34 | for rtmp_format in rtmp_formats: | |
35 | rtmp_url = '%s/%s' % (rtmp_format['url'], rtmp_format['play_path']) | |
36 | rtsp_format = rtmp_format.copy() | |
37 | del rtsp_format['play_path'] | |
38 | del rtsp_format['ext'] | |
39 | rtsp_format.update({ | |
40 | 'format_id': rtmp_format['format_id'].replace('rtmp', 'rtsp'), | |
41 | 'url': rtmp_url.replace('rtmp://', 'rtsp://'), | |
42 | 'protocol': 'rtsp', | |
43 | }) | |
44 | formats.append(rtsp_format) | |
45 | http_base_url = rtmp_url.replace('rtmp://', 'http://') | |
46 | formats.extend(self._extract_m3u8_formats( | |
47 | http_base_url + '/playlist.m3u8', video_id, 'mp4', | |
48 | 'm3u8_native', m3u8_id='hls', fatal=False)) | |
49 | formats.extend(self._extract_f4m_formats( | |
50 | http_base_url + '/manifest.f4m', | |
51 | video_id, f4m_id='hds', fatal=False)) | |
2c919adb | 52 | |
f0f3a6c9 | 53 | return { |
54 | 'id': video_id, | |
55 | 'title': meta['title'].strip(), | |
f1960478 | 56 | 'thumbnail': meta.get('image'), |
f0f3a6c9 | 57 | 'formats': formats |
58 | } |