From f2cc0d30605f3676855b94f38d6b0e8f90c74fd2 Mon Sep 17 00:00:00 2001 From: voidptr_t Date: Mon, 5 Aug 2024 21:24:12 +0300 Subject: [PATCH] dimensions --- yt_dlp/extractor/plvideo.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/yt_dlp/extractor/plvideo.py b/yt_dlp/extractor/plvideo.py index 9ed8e3635..65b047b3a 100644 --- a/yt_dlp/extractor/plvideo.py +++ b/yt_dlp/extractor/plvideo.py @@ -16,6 +16,17 @@ class PlVideoVideoIE(InfoExtractor): }, ] + def _quality_to_dimensions(self, quality): + mapped = { + '240p': (426, 240), + '360p': (640, 360), + '468p': (720, 468), + '480p': (720, 480), + '720p': (1280, 720), + '1080p': (1920, 1080), + } + return mapped.get(quality) + def _real_extract(self, url): video_id = self._match_id(url) api_url = f'https://api.g1.plvideo.ru/v1/videos/{video_id}?Aud=18' @@ -33,12 +44,16 @@ class PlVideoVideoIE(InfoExtractor): for key, value in item.get('profiles').items(): hlsurl = value.get('hls') + dimensions = self._quality_to_dimensions(key) fmt = { 'url': hlsurl, 'ext': 'mp4', 'quality': preference(key), + 'width': dimensions[0], + 'height': dimensions[1], 'format_id': key, 'protocol': 'm3u8_native', + 'aspect_ratio': float(value.get('aspectRatio')), } formats.append(fmt)