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