]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vtm.py
[extractor/youtube] Extract DRC formats
[yt-dlp.git] / yt_dlp / extractor / vtm.py
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
5 try_get,
6 )
7
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
26 def _real_extract(self, url):
27 uuid = self._match_id(url)
28 video = self._download_json(
29 'https://omc4vm23offuhaxx6hekxtzspi.appsync-api.eu-west-1.amazonaws.com/graphql',
30 uuid, query={
31 'query': '''{
32 getComponent(type: Video, uuid: "%s") {
33 ... on Video {
34 description
35 duration
36 myChannelsVideo
37 program {
38 title
39 }
40 publishedAt
41 title
42 }
43 }
44 }''' % uuid,
45 }, headers={
46 'x-api-key': 'da2-lz2cab4tfnah3mve6wiye4n77e',
47 })['data']['getComponent']
48
49 return {
50 '_type': 'url',
51 'id': uuid,
52 'title': video.get('title'),
53 'url': 'http://mychannels.video/embed/%d' % video['myChannelsVideo'],
54 'description': video.get('description'),
55 'timestamp': parse_iso8601(video.get('publishedAt')),
56 'duration': int_or_none(video.get('duration')),
57 'series': try_get(video, lambda x: x['program']['title']),
58 'ie_key': 'Medialaan',
59 }