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