int_or_none,
unified_strdate,
update_url_query,
+ url_or_none,
)
# Empty collection may be returned, in this case we proceed
# straight to next_href
- def resolve_permalink_url(candidates):
+ def resolve_entry(candidates):
for cand in candidates:
- if isinstance(cand, dict):
- permalink_url = cand.get('permalink_url')
- entry_id = self._extract_id(cand)
- if permalink_url and permalink_url.startswith('http'):
- return permalink_url, entry_id
+ if not isinstance(cand, dict):
+ continue
+ permalink_url = url_or_none(cand.get('permalink_url'))
+ if not permalink_url:
+ continue
+ return self.url_result(
+ permalink_url,
+ ie=SoundcloudIE.ie_key() if SoundcloudIE.suitable(permalink_url) else None,
+ video_id=self._extract_id(cand),
+ video_title=cand.get('title'))
for e in collection:
- permalink_url, entry_id = resolve_permalink_url((e, e.get('track'), e.get('playlist')))
- if permalink_url:
- entries.append(self.url_result(permalink_url, video_id=entry_id))
+ entry = resolve_entry((e, e.get('track'), e.get('playlist')))
+ if entry:
+ entries.append(entry)
next_href = response.get('next_href')
if not next_href:
'''
IE_NAME = 'soundcloud:user'
_TESTS = [{
- 'url': 'https://soundcloud.com/the-akashic-chronicler',
+ 'url': 'https://soundcloud.com/soft-cell-official',
'info_dict': {
- 'id': '114582580',
- 'title': 'The Akashic Chronicler (All)',
+ 'id': '207965082',
+ 'title': 'Soft Cell (All)',
},
- 'playlist_mincount': 74,
+ 'playlist_mincount': 28,
}, {
- 'url': 'https://soundcloud.com/the-akashic-chronicler/tracks',
+ 'url': 'https://soundcloud.com/soft-cell-official/tracks',
'info_dict': {
- 'id': '114582580',
- 'title': 'The Akashic Chronicler (Tracks)',
+ 'id': '207965082',
+ 'title': 'Soft Cell (Tracks)',
},
- 'playlist_mincount': 37,
+ 'playlist_mincount': 27,
}, {
- 'url': 'https://soundcloud.com/the-akashic-chronicler/sets',
+ 'url': 'https://soundcloud.com/soft-cell-official/albums',
+ 'info_dict': {
+ 'id': '207965082',
+ 'title': 'Soft Cell (Albums)',
+ },
+ 'playlist_mincount': 1,
+ }, {
+ 'url': 'https://soundcloud.com/jcv246/sets',
'info_dict': {
- 'id': '114582580',
- 'title': 'The Akashic Chronicler (Playlists)',
+ 'id': '12982173',
+ 'title': 'Jordi / cv (Playlists)',
},
'playlist_mincount': 2,
}, {
- 'url': 'https://soundcloud.com/the-akashic-chronicler/reposts',
+ 'url': 'https://soundcloud.com/jcv246/reposts',
'info_dict': {
- 'id': '114582580',
- 'title': 'The Akashic Chronicler (Reposts)',
+ 'id': '12982173',
+ 'title': 'Jordi / cv (Reposts)',
},
- 'playlist_mincount': 7,
+ 'playlist_mincount': 6,
}, {
- 'url': 'https://soundcloud.com/the-akashic-chronicler/likes',
+ 'url': 'https://soundcloud.com/clalberg/likes',
'info_dict': {
- 'id': '114582580',
- 'title': 'The Akashic Chronicler (Likes)',
+ 'id': '11817582',
+ 'title': 'clalberg (Likes)',
},
- 'playlist_mincount': 321,
+ 'playlist_mincount': 5,
}, {
'url': 'https://soundcloud.com/grynpyret/spotlight',
'info_dict': {
'title': 'Grynpyret (Spotlight)',
},
'playlist_mincount': 1,
- }, {
- 'url': 'https://soundcloud.com/soft-cell-official/albums',
- 'only_matching': True,
}]
_BASE_URL_MAP = {