]>
Commit | Line | Data |
---|---|---|
c6129feb S |
1 | from __future__ import unicode_literals |
2 | ||
544ffb77 | 3 | from .canvas import CanvasIE |
c6129feb | 4 | from .common import InfoExtractor |
00dd0cd5 | 5 | from ..compat import compat_urllib_parse_unquote |
6 | from ..utils import ( | |
7 | int_or_none, | |
8 | parse_iso8601, | |
9 | ) | |
c6129feb S |
10 | |
11 | ||
12 | class KetnetIE(InfoExtractor): | |
00dd0cd5 | 13 | _VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?P<id>(?:[^/]+/)*[^/?#&]+)' |
c6129feb | 14 | _TESTS = [{ |
00dd0cd5 | 15 | 'url': 'https://www.ketnet.be/kijken/n/nachtwacht/3/nachtwacht-s3a1-de-greystook', |
16 | 'md5': '37b2b7bb9b3dcaa05b67058dc3a714a9', | |
c6129feb | 17 | 'info_dict': { |
00dd0cd5 | 18 | 'id': 'pbs-pub-aef8b526-115e-4006-aa24-e59ff6c6ef6f$vid-ddb815bf-c8e7-467b-8879-6bad7a32cebd', |
c6129feb | 19 | 'ext': 'mp4', |
00dd0cd5 | 20 | 'title': 'Nachtwacht - Reeks 3: Aflevering 1', |
21 | 'description': 'De Nachtwacht krijgt te maken met een parasiet', | |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
00dd0cd5 | 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, | |
544ffb77 S |
30 | }, |
31 | 'expected_warnings': ['is not a supported codec', 'Unknown MIME type'], | |
c6129feb | 32 | }, { |
00dd0cd5 | 33 | 'url': 'https://www.ketnet.be/themas/karrewiet/jaaroverzicht-20200/karrewiet-het-jaar-van-black-mamba', |
f533490b | 34 | 'only_matching': True, |
c6129feb S |
35 | }] |
36 | ||
37 | def _real_extract(self, url): | |
00dd0cd5 | 38 | display_id = self._match_id(url) |
544ffb77 | 39 | |
00dd0cd5 | 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'] | |
c6129feb | 56 | |
00dd0cd5 | 57 | mz_id = compat_urllib_parse_unquote(video['mediaReference']) |
c6129feb S |
58 | |
59 | return { | |
00dd0cd5 | 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(), | |
c6129feb | 72 | } |