mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
[ie/soundcloud] Fix thumbnail extraction
Authored by: bashonly
This commit is contained in:
parent
7f3006eb0c
commit
957fe60dc7
1 changed files with 6 additions and 4 deletions
|
@ -52,7 +52,7 @@ class SoundcloudBaseIE(InfoExtractor):
|
||||||
_API_VERIFY_AUTH_TOKEN = 'https://api-auth.soundcloud.com/connect/session%s'
|
_API_VERIFY_AUTH_TOKEN = 'https://api-auth.soundcloud.com/connect/session%s'
|
||||||
_HEADERS = {}
|
_HEADERS = {}
|
||||||
|
|
||||||
_IMAGE_REPL_RE = r'-([0-9a-z]+)\.jpg'
|
_IMAGE_REPL_RE = r'-[0-9a-z]+\.(?P<ext>jpg|png)'
|
||||||
_TAGS_RE = re.compile(r'"([^"]+)"|([^ ]+)')
|
_TAGS_RE = re.compile(r'"([^"]+)"|([^ ]+)')
|
||||||
|
|
||||||
_ARTWORK_MAP = {
|
_ARTWORK_MAP = {
|
||||||
|
@ -332,12 +332,14 @@ def invalid_url(url):
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
artwork_url = info.get('artwork_url')
|
artwork_url = info.get('artwork_url')
|
||||||
thumbnail = artwork_url or user.get('avatar_url')
|
thumbnail = artwork_url or user.get('avatar_url')
|
||||||
if isinstance(thumbnail, str):
|
if url_or_none(thumbnail):
|
||||||
if re.search(self._IMAGE_REPL_RE, thumbnail):
|
if mobj := re.search(self._IMAGE_REPL_RE, thumbnail):
|
||||||
for image_id, size in self._ARTWORK_MAP.items():
|
for image_id, size in self._ARTWORK_MAP.items():
|
||||||
|
# Soundcloud serves JPEG regardless of URL's ext *except* for "original" thumb
|
||||||
|
ext = mobj.group('ext') if image_id == 'original' else 'jpg'
|
||||||
i = {
|
i = {
|
||||||
'id': image_id,
|
'id': image_id,
|
||||||
'url': re.sub(self._IMAGE_REPL_RE, f'-{image_id}.jpg', thumbnail),
|
'url': re.sub(self._IMAGE_REPL_RE, f'-{image_id}.{ext}', thumbnail),
|
||||||
}
|
}
|
||||||
if image_id == 'tiny' and not artwork_url:
|
if image_id == 'tiny' and not artwork_url:
|
||||||
size = 18
|
size = 18
|
||||||
|
|
Loading…
Reference in a new issue