mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[soundcloud] detect format extension(closes #16549)
This commit is contained in:
parent
986c0b0215
commit
c0fd20abca
1 changed files with 10 additions and 7 deletions
|
@ -181,7 +181,6 @@ def _extract_info_dict(self, info, full_title=None, quiet=False, secret_token=No
|
||||||
thumbnail = info.get('artwork_url') or info.get('user', {}).get('avatar_url')
|
thumbnail = info.get('artwork_url') or info.get('user', {}).get('avatar_url')
|
||||||
if isinstance(thumbnail, compat_str):
|
if isinstance(thumbnail, compat_str):
|
||||||
thumbnail = thumbnail.replace('-large', '-t500x500')
|
thumbnail = thumbnail.replace('-large', '-t500x500')
|
||||||
ext = 'mp3'
|
|
||||||
result = {
|
result = {
|
||||||
'id': track_id,
|
'id': track_id,
|
||||||
'uploader': info.get('user', {}).get('username'),
|
'uploader': info.get('user', {}).get('username'),
|
||||||
|
@ -215,8 +214,11 @@ def _extract_info_dict(self, info, full_title=None, quiet=False, secret_token=No
|
||||||
track_id, 'Downloading track url', query=query)
|
track_id, 'Downloading track url', query=query)
|
||||||
|
|
||||||
for key, stream_url in format_dict.items():
|
for key, stream_url in format_dict.items():
|
||||||
abr = int_or_none(self._search_regex(
|
ext, abr = 'mp3', None
|
||||||
r'_(\d+)_url', key, 'audio bitrate', default=None))
|
mobj = re.search(r'_([^_]+)_(\d+)_url', key)
|
||||||
|
if mobj:
|
||||||
|
ext, abr = mobj.groups()
|
||||||
|
abr = int(abr)
|
||||||
if key.startswith('http'):
|
if key.startswith('http'):
|
||||||
stream_formats = [{
|
stream_formats = [{
|
||||||
'format_id': key,
|
'format_id': key,
|
||||||
|
@ -234,13 +236,14 @@ def _extract_info_dict(self, info, full_title=None, quiet=False, secret_token=No
|
||||||
}]
|
}]
|
||||||
elif key.startswith('hls'):
|
elif key.startswith('hls'):
|
||||||
stream_formats = self._extract_m3u8_formats(
|
stream_formats = self._extract_m3u8_formats(
|
||||||
stream_url, track_id, 'mp3', entry_protocol='m3u8_native',
|
stream_url, track_id, ext, entry_protocol='m3u8_native',
|
||||||
m3u8_id=key, fatal=False)
|
m3u8_id=key, fatal=False)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for f in stream_formats:
|
if abr:
|
||||||
f['abr'] = abr
|
for f in stream_formats:
|
||||||
|
f['abr'] = abr
|
||||||
|
|
||||||
formats.extend(stream_formats)
|
formats.extend(stream_formats)
|
||||||
|
|
||||||
|
@ -250,7 +253,7 @@ def _extract_info_dict(self, info, full_title=None, quiet=False, secret_token=No
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': 'fallback',
|
'format_id': 'fallback',
|
||||||
'url': update_url_query(info['stream_url'], query),
|
'url': update_url_query(info['stream_url'], query),
|
||||||
'ext': ext,
|
'ext': 'mp3',
|
||||||
})
|
})
|
||||||
|
|
||||||
for f in formats:
|
for f in formats:
|
||||||
|
|
Loading…
Reference in a new issue