mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-12 14:26:49 +01:00
parent
e75bb0d6c3
commit
c2dedf12e8
@ -1357,6 +1357,7 @@
|
||||
SoundcloudEmbedIE,
|
||||
SoundcloudIE,
|
||||
SoundcloudSetIE,
|
||||
SoundcloudRelatedIE,
|
||||
SoundcloudUserIE,
|
||||
SoundcloudTrackStationIE,
|
||||
SoundcloudPlaylistIE,
|
||||
|
@ -214,8 +214,9 @@ class SoundcloudIE(SoundcloudBaseIE):
|
||||
(?!stations/track)
|
||||
(?P<uploader>[\w\d-]+)/
|
||||
(?!(?:tracks|albums|sets(?:/.+?)?|reposts|likes|spotlight)/?(?:$|[?#]))
|
||||
(?P<title>[\w\d-]+)/?
|
||||
(?P<token>[^?]+?)?(?:[?].*)?$)
|
||||
(?P<title>[\w\d-]+)
|
||||
(?:/(?P<token>(?!(?:albums|sets|recommended))[^?]+?))?
|
||||
(?:[?].*)?$)
|
||||
|(?:api(?:-v2)?\.soundcloud\.com/tracks/(?P<track_id>\d+)
|
||||
(?:/?\?secret_token=(?P<secret_token>[^&]+))?)
|
||||
)
|
||||
@ -827,6 +828,54 @@ def _real_extract(self, url):
|
||||
track_id, 'Track station: %s' % track['title'])
|
||||
|
||||
|
||||
class SoundcloudRelatedIE(SoundcloudPagedPlaylistBaseIE):
|
||||
_VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/(?P<slug>[\w\d-]+/[\w\d-]+)/(?P<relation>albums|sets|recommended)'
|
||||
IE_NAME = 'soundcloud:related'
|
||||
_TESTS = [{
|
||||
'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/recommended',
|
||||
'info_dict': {
|
||||
'id': '1084577272',
|
||||
'title': 'Sexapil - Pingers 5 (Recommended)',
|
||||
},
|
||||
'playlist_mincount': 50,
|
||||
}, {
|
||||
'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/albums',
|
||||
'info_dict': {
|
||||
'id': '1084577272',
|
||||
'title': 'Sexapil - Pingers 5 (Albums)',
|
||||
},
|
||||
'playlist_mincount': 1,
|
||||
}, {
|
||||
'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/sets',
|
||||
'info_dict': {
|
||||
'id': '1084577272',
|
||||
'title': 'Sexapil - Pingers 5 (Sets)',
|
||||
},
|
||||
'playlist_mincount': 4,
|
||||
}]
|
||||
|
||||
_BASE_URL_MAP = {
|
||||
'albums': 'tracks/%s/albums',
|
||||
'sets': 'tracks/%s/playlists_without_albums',
|
||||
'recommended': 'tracks/%s/related',
|
||||
}
|
||||
|
||||
def _real_extract(self, url):
|
||||
slug, relation = self._match_valid_url(url).group('slug', 'relation')
|
||||
|
||||
track = self._download_json(
|
||||
self._resolv_url(self._BASE_URL + slug),
|
||||
slug, 'Downloading track info', headers=self._HEADERS)
|
||||
|
||||
if track.get('errors'):
|
||||
raise ExtractorError(f'{self.IE_NAME} said: %s' % ','.join(
|
||||
str(err['error_message']) for err in track['errors']), expected=True)
|
||||
|
||||
return self._extract_playlist(
|
||||
self._API_V2_BASE + self._BASE_URL_MAP[relation] % track['id'], str(track['id']),
|
||||
'%s (%s)' % (track.get('title') or slug, relation.capitalize()))
|
||||
|
||||
|
||||
class SoundcloudPlaylistIE(SoundcloudPlaylistBaseIE):
|
||||
_VALID_URL = r'https?://api(?:-v2)?\.soundcloud\.com/playlists/(?P<id>[0-9]+)(?:/?\?secret_token=(?P<token>[^&]+?))?$'
|
||||
IE_NAME = 'soundcloud:playlist'
|
||||
|
Loading…
Reference in New Issue
Block a user