From 3d61d4ef00907a8e27788df2e318f94d9fbc2f86 Mon Sep 17 00:00:00 2001 From: Alex Karabanov Date: Thu, 25 Sep 2025 13:35:31 +0400 Subject: [PATCH] [ie/kinescope] Add kinescope as BaseExtractor for get video info by API --- yt_dlp/extractor/kinescope.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 yt_dlp/extractor/kinescope.py diff --git a/yt_dlp/extractor/kinescope.py b/yt_dlp/extractor/kinescope.py new file mode 100644 index 0000000000..5f458a7dc0 --- /dev/null +++ b/yt_dlp/extractor/kinescope.py @@ -0,0 +1,33 @@ + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + traverse_obj, +) + + +class KinescopeBaseIE(InfoExtractor): + + def _get_video_info(self, media_id, token, fatal=False, **kwargs): + headers = {'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'} + video_info = self._download_json(f'https://api.kinescope.io/v1/videos/{media_id}', + media_id, fatal=fatal, headers=headers, **kwargs) + if traverse_obj(video_info, 'error'): + raise self._error_or_warning(ExtractorError( + f'Kinescope said: {video_info["error"]}', expected=True), fatal=fatal) + return video_info or {} + + def _get_formats(self, video_info, fatal=False, **kwargs): + if traverse_obj(video_info, 'error'): + raise self._error_or_warning(ExtractorError( + f'Kinescope said: {video_info["error"]}', expected=True), fatal=fatal) + else: + formats = [] + for item in traverse_obj(video_info, ('data', 'assets')): + formats.append({ + 'url': item.get('download_link'), + 'format_id': item.get('quality'), + 'ext': item.get('filetype'), + 'resolution': item.get('resolution'), + }) + return formats or {}