]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ExtractorError | |
3 | ||
4 | ||
5 | class RTVNHIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P<id>[0-9]+)' | |
7 | _TEST = { | |
8 | 'url': 'http://www.rtvnh.nl/video/131946', | |
9 | 'md5': 'cdbec9f44550763c8afc96050fa747dc', | |
10 | 'info_dict': { | |
11 | 'id': '131946', | |
12 | 'ext': 'mp4', | |
13 | 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw', | |
14 | 'thumbnail': r're:^https?:.*\.jpg$' | |
15 | } | |
16 | } | |
17 | ||
18 | def _real_extract(self, url): | |
19 | video_id = self._match_id(url) | |
20 | ||
21 | meta = self._parse_json(self._download_webpage( | |
22 | 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) | |
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 | ||
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)) | |
52 | ||
53 | return { | |
54 | 'id': video_id, | |
55 | 'title': meta['title'].strip(), | |
56 | 'thumbnail': meta.get('image'), | |
57 | 'formats': formats | |
58 | } |