vtm.py 1.8 KB

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