[rtvnh] Renamed rtvnhnl -> rtvnh
[youtube-dl] / youtube_dl / extractor / rtvnh.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class RTVNHIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P<id>[0-9]+)'
9     _TEST = {
10         'params': {
11             'hls_prefer_native': True
12         },
13
14         'url': 'http://www.rtvnh.nl/video/131946',
15         'md5': '6e1d0ab079e2a00b6161442d3ceacfc1',
16         'info_dict': {
17             'id': '131946',
18             'ext': 'mp4',
19             'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw',
20             'thumbnail': 're:^https?:.*\.jpg$'
21         }
22     }
23
24     def _real_extract(self, url):
25         video_id = self._match_id(url)
26         meta = self._parse_json(self._download_webpage('http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id)
27         formats = self._extract_smil_formats('http://www.rtvnh.nl/video/smil?m=' + video_id, video_id)
28
29         for item in meta['source']['fb']:
30             if item.get('type') == 'hls':
31                 formats.extend(self._extract_m3u8_formats(item['file'], video_id, ext='mp4'))
32             elif item.get('type') == '':
33                 formats.append({'url': item['file']})
34         
35         return {
36             'id': video_id,
37             'title': meta['title'].strip(),
38             'thumbnail': meta['image'],
39             'formats': formats
40         }