[PromoDJ] Add codecs

This commit is contained in:
DmitryScaletta 2024-02-17 05:24:49 +03:00
parent 49ac5d31a3
commit 2416fddcfb
No known key found for this signature in database
GPG Key ID: 167A65222EDD4C2A

View File

@ -155,6 +155,8 @@ def _parse_media_data(self, media_data, id):
'format_id': 'lossy', 'format_id': 'lossy',
'url': traverse_obj(source, ('URL', {url_or_none})), 'url': traverse_obj(source, ('URL', {url_or_none})),
'size': traverse_obj(source, ('size', {int_or_none})), 'size': traverse_obj(source, ('size', {int_or_none})),
'acodec': 'mp3',
'vcodec': 'none',
} for source in traverse_obj(media_data, ('sources'))] } for source in traverse_obj(media_data, ('sources'))]
thumbnails = [{ thumbnails = [{
'url': url, 'url': url,
@ -780,7 +782,7 @@ class PromoDJIE(PromoDJBaseIE):
# examples: MP3, 320 Кбит | MP4, 20157 Кбит | WAV, 1412 Кбит | AVI, 1731 Кбит | ASF, 6905 Кбит | FLAC, 1509 Кбит # examples: MP3, 320 Кбит | MP4, 20157 Кбит | WAV, 1412 Кбит | AVI, 1731 Кбит | ASF, 6905 Кбит | FLAC, 1509 Кбит
# https://regex101.com/r/2AuaxB/1 # https://regex101.com/r/2AuaxB/1
_FORMATS_RE = r'(?:<a\s+href=\"(?P<url>[^\"]+)\">)?\s*\w+, (?P<bitrate>\d+) Кбит' _FORMATS_RE = r'(?:<a\s+href=\"(?P<url>[^\"]+)\">)?\s*(?P<format>\w+), (?P<bitrate>\d+) Кбит'
_VIEW_COUNT_RE = r'<b>(?:Прослушиваний|Просмотров):</b>\s*(\d+)' _VIEW_COUNT_RE = r'<b>(?:Прослушиваний|Просмотров):</b>\s*(\d+)'
# examples: 0:21 | 1:07 | 74:38 # examples: 0:21 | 1:07 | 74:38
_DURATION_RE = r'<b>Продолжительность:</b>\s*(\d+:\d{2})' _DURATION_RE = r'<b>Продолжительность:</b>\s*(\d+:\d{2})'
@ -847,18 +849,19 @@ def _real_extract(self, url):
# size field describes best quality # size field describes best quality
size = self._parse_ru_size(*re.search(self._SIZE_RE, meta_html).groups()) size = self._parse_ru_size(*re.search(self._SIZE_RE, meta_html).groups())
if type == 'videos': if type == 'videos':
for url, bitrate in formats_from_html: for url, format, bitrate in formats_from_html:
if url_or_none(url): if url_or_none(url):
metadata['formats'].append({ metadata['formats'].append({
'format_id': 'source', 'format_id': 'source',
'url': url, 'url': url,
'tbr': int(bitrate), 'tbr': int(bitrate),
'size': size, 'size': size,
'container': format.lower(),
'quality': 1, 'quality': 1,
}) })
elif not is_paid: elif not is_paid:
for i, match in enumerate(formats_from_html): for i, match in enumerate(formats_from_html):
url, bitrate = match url, format, bitrate = match
is_last = i == len(formats_from_html) - 1 is_last = i == len(formats_from_html) - 1
if is_last: if is_last:
metadata['formats'][0]['abr'] = int(bitrate) metadata['formats'][0]['abr'] = int(bitrate)
@ -867,6 +870,8 @@ def _real_extract(self, url):
'format_id': 'lossless', 'format_id': 'lossless',
'url': url, 'url': url,
'abr': int(bitrate), 'abr': int(bitrate),
'acodec': format.lower(),
'vcodec': 'none',
}) })
metadata['formats'][-1]['size'] = size metadata['formats'][-1]['size'] = size
@ -1037,6 +1042,8 @@ def _real_extract(self, url):
'url': f'https://radio.promodj.com/{slug}-192', 'url': f'https://radio.promodj.com/{slug}-192',
'abr': 192, 'abr': 192,
'ext': 'mp3', 'ext': 'mp3',
'acodec': 'mp3',
'vcodec': 'none',
}], }],
'is_live': True, 'is_live': True,
} }