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