From 2416fddcfbd3dd22caa78fc2cf7018d82a7d2efc Mon Sep 17 00:00:00 2001 From: DmitryScaletta Date: Sat, 17 Feb 2024 05:24:49 +0300 Subject: [PATCH] [PromoDJ] Add codecs --- yt_dlp/extractor/promodj.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/promodj.py b/yt_dlp/extractor/promodj.py index 8600b93d1..235ff0187 100644 --- a/yt_dlp/extractor/promodj.py +++ b/yt_dlp/extractor/promodj.py @@ -155,6 +155,8 @@ def _parse_media_data(self, media_data, id): 'format_id': 'lossy', 'url': traverse_obj(source, ('URL', {url_or_none})), 'size': traverse_obj(source, ('size', {int_or_none})), + 'acodec': 'mp3', + 'vcodec': 'none', } for source in traverse_obj(media_data, ('sources'))] thumbnails = [{ 'url': url, @@ -780,7 +782,7 @@ class PromoDJIE(PromoDJBaseIE): # examples: MP3, 320 Кбит | MP4, 20157 Кбит | WAV, 1412 Кбит | AVI, 1731 Кбит | ASF, 6905 Кбит | FLAC, 1509 Кбит # https://regex101.com/r/2AuaxB/1 - _FORMATS_RE = r'(?:[^\"]+)\">)?\s*\w+, (?P\d+) Кбит' + _FORMATS_RE = r'(?:[^\"]+)\">)?\s*(?P\w+), (?P\d+) Кбит' _VIEW_COUNT_RE = r'(?:Прослушиваний|Просмотров):\s*(\d+)' # examples: 0:21 | 1:07 | 74:38 _DURATION_RE = r'Продолжительность:\s*(\d+:\d{2})' @@ -847,18 +849,19 @@ def _real_extract(self, url): # size field describes best quality size = self._parse_ru_size(*re.search(self._SIZE_RE, meta_html).groups()) if type == 'videos': - for url, bitrate in formats_from_html: + for url, format, bitrate in formats_from_html: if url_or_none(url): metadata['formats'].append({ 'format_id': 'source', 'url': url, 'tbr': int(bitrate), 'size': size, + 'container': format.lower(), 'quality': 1, }) elif not is_paid: for i, match in enumerate(formats_from_html): - url, bitrate = match + url, format, bitrate = match is_last = i == len(formats_from_html) - 1 if is_last: metadata['formats'][0]['abr'] = int(bitrate) @@ -867,6 +870,8 @@ def _real_extract(self, url): 'format_id': 'lossless', 'url': url, 'abr': int(bitrate), + 'acodec': format.lower(), + 'vcodec': 'none', }) metadata['formats'][-1]['size'] = size @@ -1037,6 +1042,8 @@ def _real_extract(self, url): 'url': f'https://radio.promodj.com/{slug}-192', 'abr': 192, 'ext': 'mp3', + 'acodec': 'mp3', + 'vcodec': 'none', }], 'is_live': True, }