logo

youtube-dl

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

vtm.py (1899B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_iso8601,
  7. try_get,
  8. )
  9. class VTMIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?vtm\.be/([^/?&#]+)~v(?P<id>[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})'
  11. _TEST = {
  12. 'url': 'https://vtm.be/gast-vernielt-genkse-hotelkamer~ve7534523-279f-4b4d-a5c9-a33ffdbe23e1',
  13. 'md5': '37dca85fbc3a33f2de28ceb834b071f8',
  14. 'info_dict': {
  15. 'id': '192445',
  16. 'ext': 'mp4',
  17. 'title': 'Gast vernielt Genkse hotelkamer',
  18. 'timestamp': 1611060180,
  19. 'upload_date': '20210119',
  20. 'duration': 74,
  21. # TODO: fix url _type result processing
  22. # 'series': 'Op Interventie',
  23. }
  24. }
  25. def _real_extract(self, url):
  26. uuid = self._match_id(url)
  27. video = self._download_json(
  28. 'https://omc4vm23offuhaxx6hekxtzspi.appsync-api.eu-west-1.amazonaws.com/graphql',
  29. uuid, query={
  30. 'query': '''{
  31. getComponent(type: Video, uuid: "%s") {
  32. ... on Video {
  33. description
  34. duration
  35. myChannelsVideo
  36. program {
  37. title
  38. }
  39. publishedAt
  40. title
  41. }
  42. }
  43. }''' % uuid,
  44. }, headers={
  45. 'x-api-key': 'da2-lz2cab4tfnah3mve6wiye4n77e',
  46. })['data']['getComponent']
  47. return {
  48. '_type': 'url',
  49. 'id': uuid,
  50. 'title': video.get('title'),
  51. 'url': 'http://mychannels.video/embed/%d' % video['myChannelsVideo'],
  52. 'description': video.get('description'),
  53. 'timestamp': parse_iso8601(video.get('publishedAt')),
  54. 'duration': int_or_none(video.get('duration')),
  55. 'series': try_get(video, lambda x: x['program']['title']),
  56. 'ie_key': 'Medialaan',
  57. }