1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 03:32:05 +00:00
youtube-dl/youtube_dl/extractor/ketnet.py

73 lines
2.5 KiB
Python
Raw Normal View History

2016-09-09 16:20:45 +00:00
from __future__ import unicode_literals
from .canvas import CanvasIE
2016-09-09 16:20:45 +00:00
from .common import InfoExtractor
2021-01-05 17:17:04 +00:00
from ..compat import compat_urllib_parse_unquote
from ..utils import (
int_or_none,
parse_iso8601,
)
2016-09-09 16:20:45 +00:00
class KetnetIE(InfoExtractor):
2021-01-05 17:17:04 +00:00
_VALID_URL = r'https?://(?:www\.)?ketnet\.be/(?P<id>(?:[^/]+/)*[^/?#&]+)'
2016-09-09 16:20:45 +00:00
_TESTS = [{
2021-01-05 17:17:04 +00:00
'url': 'https://www.ketnet.be/kijken/n/nachtwacht/3/nachtwacht-s3a1-de-greystook',
'md5': '37b2b7bb9b3dcaa05b67058dc3a714a9',
2016-09-09 16:20:45 +00:00
'info_dict': {
2021-01-05 17:17:04 +00:00
'id': 'pbs-pub-aef8b526-115e-4006-aa24-e59ff6c6ef6f$vid-ddb815bf-c8e7-467b-8879-6bad7a32cebd',
2016-09-09 16:20:45 +00:00
'ext': 'mp4',
2021-01-05 17:17:04 +00:00
'title': 'Nachtwacht - Reeks 3: Aflevering 1',
'description': 'De Nachtwacht krijgt te maken met een parasiet',
'thumbnail': r're:^https?://.*\.jpg$',
2021-01-05 17:17:04 +00:00
'duration': 1468.02,
'timestamp': 1609225200,
'upload_date': '20201229',
'series': 'Nachtwacht',
'season': 'Reeks 3',
'episode': 'De Greystook',
'episode_number': 1,
},
'expected_warnings': ['is not a supported codec', 'Unknown MIME type'],
2016-09-09 16:20:45 +00:00
}, {
2021-01-05 17:17:04 +00:00
'url': 'https://www.ketnet.be/themas/karrewiet/jaaroverzicht-20200/karrewiet-het-jaar-van-black-mamba',
'only_matching': True,
2016-09-09 16:20:45 +00:00
}]
def _real_extract(self, url):
2021-01-05 17:17:04 +00:00
display_id = self._match_id(url)
2021-01-05 17:17:04 +00:00
video = self._download_json(
'https://senior-bff.ketnet.be/graphql', display_id, query={
'query': '''{
video(id: "content/ketnet/nl/%s.model.json") {
description
episodeNr
imageUrl
mediaReference
programTitle
publicationDate
seasonTitle
subtitleVideodetail
titleVideodetail
}
}''' % display_id,
})['data']['video']
2016-09-09 16:20:45 +00:00
2021-01-05 17:17:04 +00:00
mz_id = compat_urllib_parse_unquote(video['mediaReference'])
2016-09-09 16:20:45 +00:00
return {
2021-01-05 17:17:04 +00:00
'_type': 'url_transparent',
'id': mz_id,
'title': video['titleVideodetail'],
'url': 'https://mediazone.vrt.be/api/v1/ketnet/assets/' + mz_id,
'thumbnail': video.get('imageUrl'),
'description': video.get('description'),
'timestamp': parse_iso8601(video.get('publicationDate')),
'series': video.get('programTitle'),
'season': video.get('seasonTitle'),
'episode': video.get('subtitleVideodetail'),
'episode_number': int_or_none(video.get('episodeNr')),
'ie_key': CanvasIE.ie_key(),
2016-09-09 16:20:45 +00:00
}