]> jfr.im git - yt-dlp.git/commitdiff
[extractor/soundcloud] Support user permalink (#5842)
authornosoop <redacted>
Thu, 29 Dec 2022 18:46:43 +0000 (10:46 -0800)
committerGitHub <redacted>
Thu, 29 Dec 2022 18:46:43 +0000 (00:16 +0530)
Closes #5841
Authored by: nosoop

yt_dlp/extractor/_extractors.py
yt_dlp/extractor/soundcloud.py

index a2b92b85aeb9901d4e59f8dbfe32d7d7a8bb9aae..352de83cac0a3a40a06aface65df28ae0aac2605 100644 (file)
     SoundcloudSetIE,
     SoundcloudRelatedIE,
     SoundcloudUserIE,
+    SoundcloudUserPermalinkIE,
     SoundcloudTrackStationIE,
     SoundcloudPlaylistIE,
     SoundcloudSearchIE,
index 4879d48c8079ff7a451b8c1fc9c8f30e553aaed8..979f23f44f431612c58d72eb7019a6c64b1f3e22 100644 (file)
@@ -782,6 +782,27 @@ def _real_extract(self, url):
             '%s (%s)' % (user['username'], resource.capitalize()))
 
 
+class SoundcloudUserPermalinkIE(SoundcloudPagedPlaylistBaseIE):
+    _VALID_URL = r'https?://api\.soundcloud\.com/users/(?P<id>\d+)'
+    IE_NAME = 'soundcloud:user:permalink'
+    _TESTS = [{
+        'url': 'https://api.soundcloud.com/users/30909869',
+        'info_dict': {
+            'id': '30909869',
+            'title': 'neilcic',
+        },
+        'playlist_mincount': 23,
+    }]
+
+    def _real_extract(self, url):
+        user_id = self._match_id(url)
+        user = self._download_json(
+            self._resolv_url(url), user_id, 'Downloading user info', headers=self._HEADERS)
+
+        return self._extract_playlist(
+            f'{self._API_V2_BASE}stream/users/{user["id"]}', str(user['id']), user.get('username'))
+
+
 class SoundcloudTrackStationIE(SoundcloudPagedPlaylistBaseIE):
     _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/stations/track/[^/]+/(?P<id>[^/?#&]+)'
     IE_NAME = 'soundcloud:trackstation'