1 from __future__ import unicode_literals
3 from .common import InfoExtractor
6 class KetnetIE(InfoExtractor):
7 _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?:[^/]+/)*(?P<id>[^/?#&]+)'
9 'url': 'https://www.ketnet.be/kijken/zomerse-filmpjes',
10 'md5': 'd907f7b1814ef0fa285c0475d9994ed7',
12 'id': 'zomerse-filmpjes',
14 'title': 'Gluur mee op de filmset en op Pennenzakkenrock',
15 'description': 'Gluur mee met Ghost Rockers op de filmset',
16 'thumbnail': r're:^https?://.*\.jpg$',
19 'url': 'https://www.ketnet.be/kijken/karrewiet/uitzending-8-september-2016',
20 'only_matching': True,
22 'url': 'https://www.ketnet.be/achter-de-schermen/sien-repeteert-voor-stars-for-life',
23 'only_matching': True,
25 # mzsource, geo restricted to Belgium
26 'url': 'https://www.ketnet.be/kijken/nachtwacht/de-bermadoe',
27 'only_matching': True,
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
35 config = self._parse_json(
37 r'(?s)playerConfig\s*=\s*({.+?})\s*;', webpage,
41 title = config['title']
44 for source_key in ('', 'mz'):
45 source = config.get('%ssource' % source_key)
46 if not isinstance(source, dict):
48 for format_id, format_url in source.items():
49 if format_id == 'hls':
50 formats.extend(self._extract_m3u8_formats(
51 format_url, video_id, 'mp4',
52 entry_protocol='m3u8_native', m3u8_id=format_id,
54 elif format_id == 'hds':
55 formats.extend(self._extract_f4m_formats(
56 format_url, video_id, f4m_id=format_id, fatal=False))
60 'format_id': format_id,
62 self._sort_formats(formats)
67 'description': config.get('description'),
68 'thumbnail': config.get('image'),
69 'series': config.get('program'),
70 'episode': config.get('episode'),