]>
Commit | Line | Data |
---|---|---|
1 | from __future__ import unicode_literals | |
2 | ||
3 | from .canvas import CanvasIE | |
4 | from .common import InfoExtractor | |
5 | from ..compat import compat_urllib_parse_unquote | |
6 | from ..utils import ( | |
7 | int_or_none, | |
8 | parse_iso8601, | |
9 | ) | |
10 | ||
11 | ||
12 | class KetnetIE(InfoExtractor): | |
13 | _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?P<id>(?:[^/]+/)*[^/?#&]+)' | |
14 | _TESTS = [{ | |
15 | 'url': 'https://www.ketnet.be/kijken/n/nachtwacht/3/nachtwacht-s3a1-de-greystook', | |
16 | 'md5': '37b2b7bb9b3dcaa05b67058dc3a714a9', | |
17 | 'info_dict': { | |
18 | 'id': 'pbs-pub-aef8b526-115e-4006-aa24-e59ff6c6ef6f$vid-ddb815bf-c8e7-467b-8879-6bad7a32cebd', | |
19 | 'ext': 'mp4', | |
20 | 'title': 'Nachtwacht - Reeks 3: Aflevering 1', | |
21 | 'description': 'De Nachtwacht krijgt te maken met een parasiet', | |
22 | 'thumbnail': r're:^https?://.*\.jpg$', | |
23 | 'duration': 1468.02, | |
24 | 'timestamp': 1609225200, | |
25 | 'upload_date': '20201229', | |
26 | 'series': 'Nachtwacht', | |
27 | 'season': 'Reeks 3', | |
28 | 'episode': 'De Greystook', | |
29 | 'episode_number': 1, | |
30 | }, | |
31 | 'expected_warnings': ['is not a supported codec', 'Unknown MIME type'], | |
32 | }, { | |
33 | 'url': 'https://www.ketnet.be/themas/karrewiet/jaaroverzicht-20200/karrewiet-het-jaar-van-black-mamba', | |
34 | 'only_matching': True, | |
35 | }] | |
36 | ||
37 | def _real_extract(self, url): | |
38 | display_id = self._match_id(url) | |
39 | ||
40 | video = self._download_json( | |
41 | 'https://senior-bff.ketnet.be/graphql', display_id, query={ | |
42 | 'query': '''{ | |
43 | video(id: "content/ketnet/nl/%s.model.json") { | |
44 | description | |
45 | episodeNr | |
46 | imageUrl | |
47 | mediaReference | |
48 | programTitle | |
49 | publicationDate | |
50 | seasonTitle | |
51 | subtitleVideodetail | |
52 | titleVideodetail | |
53 | } | |
54 | }''' % display_id, | |
55 | })['data']['video'] | |
56 | ||
57 | mz_id = compat_urllib_parse_unquote(video['mediaReference']) | |
58 | ||
59 | return { | |
60 | '_type': 'url_transparent', | |
61 | 'id': mz_id, | |
62 | 'title': video['titleVideodetail'], | |
63 | 'url': 'https://mediazone.vrt.be/api/v1/ketnet/assets/' + mz_id, | |
64 | 'thumbnail': video.get('imageUrl'), | |
65 | 'description': video.get('description'), | |
66 | 'timestamp': parse_iso8601(video.get('publicationDate')), | |
67 | 'series': video.get('programTitle'), | |
68 | 'season': video.get('seasonTitle'), | |
69 | 'episode': video.get('subtitleVideodetail'), | |
70 | 'episode_number': int_or_none(video.get('episodeNr')), | |
71 | 'ie_key': CanvasIE.ie_key(), | |
72 | } |