From 6052f269928fd9d54636084f406c5a62d8d16ccd Mon Sep 17 00:00:00 2001 From: unkernet Date: Fri, 16 Jun 2023 16:40:58 +0700 Subject: [PATCH 1/2] [soundcloud] Download Soundcloud GO+ high quality streams and private playlists --- youtube_dl/extractor/soundcloud.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py index abb85e1e5..197c00587 100644 --- a/youtube_dl/extractor/soundcloud.py +++ b/youtube_dl/extractor/soundcloud.py @@ -293,6 +293,11 @@ class SoundcloudIE(InfoExtractor): if non_fatal: del kwargs['fatal'] query = kwargs.get('query', {}).copy() + oauth_token = self._get_cookies(self._BASE_URL).get('oauth_token') + if oauth_token: + if not kwargs.get('headers'): + kwargs['headers'] = {} + kwargs['headers']['authorization'] = 'OAuth ' + oauth_token.value for _ in range(2): query['client_id'] = self._CLIENT_ID kwargs['query'] = query @@ -319,6 +324,7 @@ class SoundcloudIE(InfoExtractor): track_id = compat_str(info['id']) title = info['title'] + duration = info.get('duration') format_urls = set() formats = [] query = {'client_id': self._CLIENT_ID} @@ -335,12 +341,14 @@ class SoundcloudIE(InfoExtractor): if urlh: format_url = urlh.geturl() format_urls.add(format_url) + filesize = int_or_none(urlh.headers.get('Content-Length')) formats.append({ 'format_id': 'download', 'ext': urlhandle_detect_ext(urlh) or 'mp3', - 'filesize': int_or_none(urlh.headers.get('Content-Length')), + 'filesize': filesize, 'url': format_url, 'preference': 10, + 'abr': (filesize and duration) and (filesize / duration * 8), }) def invalid_url(url): From 2d72ef66d5305683f82b2f31034aba78bc608d50 Mon Sep 17 00:00:00 2001 From: unkernet Date: Fri, 16 Jun 2023 20:24:20 +0700 Subject: [PATCH 2/2] [soundcloud] Fix Soundcloud test case --- youtube_dl/extractor/soundcloud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py index 197c00587..e4c5c3091 100644 --- a/youtube_dl/extractor/soundcloud.py +++ b/youtube_dl/extractor/soundcloud.py @@ -233,8 +233,8 @@ class SoundcloudIE(InfoExtractor): 'id': '583011102', 'ext': 'mp3', 'title': 'Mezzo Valzer', - 'description': 'md5:4138d582f81866a530317bae316e8b61', - 'uploader': 'Micronie', + 'description': 'md5:8de664f12895716c8ac6f1da6348eb8e', + 'uploader': 'Giovanni Sarani', 'uploader_id': '3352531', 'timestamp': 1551394171, 'upload_date': '20190228',