logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

ketnet.py (2526B)


  1. from __future__ import unicode_literals
  2. from .canvas import CanvasIE
  3. from .common import InfoExtractor
  4. from ..compat import compat_urllib_parse_unquote
  5. from ..utils import (
  6. int_or_none,
  7. parse_iso8601,
  8. )
  9. class KetnetIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?P<id>(?:[^/]+/)*[^/?#&]+)'
  11. _TESTS = [{
  12. 'url': 'https://www.ketnet.be/kijken/n/nachtwacht/3/nachtwacht-s3a1-de-greystook',
  13. 'md5': '37b2b7bb9b3dcaa05b67058dc3a714a9',
  14. 'info_dict': {
  15. 'id': 'pbs-pub-aef8b526-115e-4006-aa24-e59ff6c6ef6f$vid-ddb815bf-c8e7-467b-8879-6bad7a32cebd',
  16. 'ext': 'mp4',
  17. 'title': 'Nachtwacht - Reeks 3: Aflevering 1',
  18. 'description': 'De Nachtwacht krijgt te maken met een parasiet',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'duration': 1468.02,
  21. 'timestamp': 1609225200,
  22. 'upload_date': '20201229',
  23. 'series': 'Nachtwacht',
  24. 'season': 'Reeks 3',
  25. 'episode': 'De Greystook',
  26. 'episode_number': 1,
  27. },
  28. 'expected_warnings': ['is not a supported codec', 'Unknown MIME type'],
  29. }, {
  30. 'url': 'https://www.ketnet.be/themas/karrewiet/jaaroverzicht-20200/karrewiet-het-jaar-van-black-mamba',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. display_id = self._match_id(url)
  35. video = self._download_json(
  36. 'https://senior-bff.ketnet.be/graphql', display_id, query={
  37. 'query': '''{
  38. video(id: "content/ketnet/nl/%s.model.json") {
  39. description
  40. episodeNr
  41. imageUrl
  42. mediaReference
  43. programTitle
  44. publicationDate
  45. seasonTitle
  46. subtitleVideodetail
  47. titleVideodetail
  48. }
  49. }''' % display_id,
  50. })['data']['video']
  51. mz_id = compat_urllib_parse_unquote(video['mediaReference'])
  52. return {
  53. '_type': 'url_transparent',
  54. 'id': mz_id,
  55. 'title': video['titleVideodetail'],
  56. 'url': 'https://mediazone.vrt.be/api/v1/ketnet/assets/' + mz_id,
  57. 'thumbnail': video.get('imageUrl'),
  58. 'description': video.get('description'),
  59. 'timestamp': parse_iso8601(video.get('publicationDate')),
  60. 'series': video.get('programTitle'),
  61. 'season': video.get('seasonTitle'),
  62. 'episode': video.get('subtitleVideodetail'),
  63. 'episode_number': int_or_none(video.get('episodeNr')),
  64. 'ie_key': CanvasIE.ie_key(),
  65. }