You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. class KetnetIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  5. _TESTS = [{
  6. 'url': 'https://www.ketnet.be/kijken/zomerse-filmpjes',
  7. 'md5': 'd907f7b1814ef0fa285c0475d9994ed7',
  8. 'info_dict': {
  9. 'id': 'zomerse-filmpjes',
  10. 'ext': 'mp4',
  11. 'title': 'Gluur mee op de filmset en op Pennenzakkenrock',
  12. 'description': 'Gluur mee met Ghost Rockers op de filmset',
  13. 'thumbnail': 're:^https?://.*\.jpg$',
  14. }
  15. }, {
  16. 'url': 'https://www.ketnet.be/kijken/karrewiet/uitzending-8-september-2016',
  17. 'only_matching': True,
  18. }, {
  19. 'url': 'https://www.ketnet.be/achter-de-schermen/sien-repeteert-voor-stars-for-life',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. config = self._parse_json(
  26. self._search_regex(
  27. r'(?s)playerConfig\s*=\s*({.+?})\s*;', webpage,
  28. 'player config'),
  29. video_id)
  30. title = config['title']
  31. formats = self._extract_m3u8_formats(
  32. config['source']['hls'], video_id, 'mp4',
  33. entry_protocol='m3u8_native', m3u8_id='hls')
  34. self._sort_formats(formats)
  35. return {
  36. 'id': video_id,
  37. 'title': title,
  38. 'description': config.get('description'),
  39. 'thumbnail': config.get('image'),
  40. 'series': config.get('program'),
  41. 'episode': config.get('episode'),
  42. 'formats': formats,
  43. }