]>
Commit | Line | Data |
---|---|---|
92790f4e | 1 | import itertools |
73602bcd | 2 | import re |
2ab47fa3 | 3 | import json |
be05d5cf | 4 | # import random |
aad0d6d5 | 5 | |
2abf7cab | 6 | from .common import ( |
7 | InfoExtractor, | |
8 | SearchInfoExtractor | |
9 | ) | |
1cc79574 | 10 | from ..compat import ( |
3bed6217 | 11 | compat_HTTPError, |
aad0d6d5 | 12 | compat_str, |
1cc79574 PH |
13 | ) |
14 | from ..utils import ( | |
de7aade2 | 15 | error_to_compat_str, |
aad0d6d5 | 16 | ExtractorError, |
e09965d5 | 17 | float_or_none, |
548c3957 | 18 | HEADRequest, |
eb920777 | 19 | int_or_none, |
e09965d5 | 20 | KNOWN_EXTENSIONS, |
e09965d5 | 21 | mimetype2ext, |
aa6c2530 | 22 | parse_qs, |
e09965d5 | 23 | str_or_none, |
f516f440 S |
24 | try_get, |
25 | unified_timestamp, | |
d7c7100e | 26 | update_url_query, |
7c5307f4 | 27 | url_or_none, |
a6c5859d | 28 | urlhandle_detect_ext, |
2ab47fa3 | 29 | sanitized_Request, |
d7c7100e | 30 | ) |
aad0d6d5 PH |
31 | |
32 | ||
548c3957 | 33 | class SoundcloudEmbedIE(InfoExtractor): |
cf80ff18 | 34 | _VALID_URL = r'https?://(?:w|player|p)\.soundcloud\.com/player/?.*?\burl=(?P<id>.+)' |
bfd973ec | 35 | _EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?(?:w\.)?soundcloud\.com/player.+?)\1'] |
cf80ff18 RA |
36 | _TEST = { |
37 | # from https://www.soundi.fi/uutiset/ennakkokuuntelussa-timo-kaukolammen-station-to-station-to-station-julkaisua-juhlitaan-tanaan-g-livelabissa/ | |
38 | 'url': 'https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F922213810&show_artwork=true&maxwidth=640&maxheight=960&dnt=1&secret_token=s-ziYey', | |
39 | 'only_matching': True, | |
40 | } | |
548c3957 | 41 | |
548c3957 | 42 | def _real_extract(self, url): |
aa6c2530 | 43 | query = parse_qs(url) |
cf80ff18 RA |
44 | api_url = query['url'][0] |
45 | secret_token = query.get('secret_token') | |
46 | if secret_token: | |
47 | api_url = update_url_query(api_url, {'secret_token': secret_token[0]}) | |
48 | return self.url_result(api_url) | |
548c3957 RA |
49 | |
50 | ||
63ccf4ff | 51 | class SoundcloudBaseIE(InfoExtractor): |
08d30158 | 52 | _NETRC_MACHINE = 'soundcloud' |
53 | ||
63ccf4ff | 54 | _API_V2_BASE = 'https://api-v2.soundcloud.com/' |
55 | _BASE_URL = 'https://soundcloud.com/' | |
08d30158 | 56 | _USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36' |
57 | _API_AUTH_QUERY_TEMPLATE = '?client_id=%s' | |
58 | _API_AUTH_URL_PW = 'https://api-auth.soundcloud.com/web-auth/sign-in/password%s' | |
59 | _API_VERIFY_AUTH_TOKEN = 'https://api-auth.soundcloud.com/connect/session%s' | |
60 | _access_token = None | |
61 | _HEADERS = {} | |
63ccf4ff | 62 | |
63 | def _store_client_id(self, client_id): | |
9809740b | 64 | self.cache.store('soundcloud', 'client_id', client_id) |
63ccf4ff | 65 | |
66 | def _update_client_id(self): | |
67 | webpage = self._download_webpage('https://soundcloud.com/', None) | |
68 | for src in reversed(re.findall(r'<script[^>]+src="([^"]+)"', webpage)): | |
69 | script = self._download_webpage(src, None, fatal=False) | |
70 | if script: | |
71 | client_id = self._search_regex( | |
72 | r'client_id\s*:\s*"([0-9a-zA-Z]{32})"', | |
73 | script, 'client id', default=None) | |
74 | if client_id: | |
75 | self._CLIENT_ID = client_id | |
76 | self._store_client_id(client_id) | |
77 | return | |
78 | raise ExtractorError('Unable to extract client id') | |
79 | ||
80 | def _download_json(self, *args, **kwargs): | |
81 | non_fatal = kwargs.get('fatal') is False | |
82 | if non_fatal: | |
83 | del kwargs['fatal'] | |
84 | query = kwargs.get('query', {}).copy() | |
85 | for _ in range(2): | |
86 | query['client_id'] = self._CLIENT_ID | |
87 | kwargs['query'] = query | |
88 | try: | |
f9934b96 | 89 | return super()._download_json(*args, **kwargs) |
63ccf4ff | 90 | except ExtractorError as e: |
91 | if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 403): | |
92 | self._store_client_id(None) | |
93 | self._update_client_id() | |
94 | continue | |
95 | elif non_fatal: | |
96 | self.report_warning(error_to_compat_str(e)) | |
97 | return False | |
98 | raise | |
99 | ||
52efa4b3 | 100 | def _initialize_pre_login(self): |
9809740b | 101 | self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf' |
63ccf4ff | 102 | |
52efa4b3 | 103 | def _perform_login(self, username, password): |
104 | if username != 'oauth': | |
63ccf4ff | 105 | self.report_warning( |
106 | 'Login using username and password is not currently supported. ' | |
b69fd25c | 107 | 'Use "--username oauth --password <oauth_token>" to login using an oauth token') |
52efa4b3 | 108 | self._access_token = password |
109 | query = self._API_AUTH_QUERY_TEMPLATE % self._CLIENT_ID | |
110 | payload = {'session': {'access_token': self._access_token}} | |
111 | token_verification = sanitized_Request(self._API_VERIFY_AUTH_TOKEN % query, json.dumps(payload).encode('utf-8')) | |
112 | response = self._download_json(token_verification, None, note='Verifying login token...', fatal=False) | |
113 | if response is not False: | |
114 | self._HEADERS = {'Authorization': 'OAuth ' + self._access_token} | |
115 | self.report_login() | |
116 | else: | |
117 | self.report_warning('Provided authorization token seems to be invalid. Continue as guest') | |
63ccf4ff | 118 | |
119 | r''' | |
120 | def genDevId(): | |
121 | def genNumBlock(): | |
122 | return ''.join([str(random.randrange(10)) for i in range(6)]) | |
123 | return '-'.join([genNumBlock() for i in range(4)]) | |
124 | ||
125 | payload = { | |
126 | 'client_id': self._CLIENT_ID, | |
127 | 'recaptcha_pubkey': 'null', | |
128 | 'recaptcha_response': 'null', | |
129 | 'credentials': { | |
130 | 'identifier': username, | |
131 | 'password': password | |
132 | }, | |
133 | 'signature': self.sign(username, password, self._CLIENT_ID), | |
134 | 'device_id': genDevId(), | |
135 | 'user_agent': self._USER_AGENT | |
136 | } | |
137 | ||
138 | query = self._API_AUTH_QUERY_TEMPLATE % self._CLIENT_ID | |
139 | login = sanitized_Request(self._API_AUTH_URL_PW % query, json.dumps(payload).encode('utf-8')) | |
140 | response = self._download_json(login, None) | |
141 | self._access_token = response.get('session').get('access_token') | |
142 | if not self._access_token: | |
143 | self.report_warning('Unable to get access token, login may has failed') | |
144 | else: | |
145 | self._HEADERS = {'Authorization': 'OAuth ' + self._access_token} | |
146 | ''' | |
147 | ||
148 | # signature generation | |
149 | def sign(self, user, pw, clid): | |
150 | a = 33 | |
151 | i = 1 | |
152 | s = 440123 | |
153 | w = 117 | |
154 | u = 1800000 | |
155 | l = 1042 | |
156 | b = 37 | |
157 | k = 37 | |
158 | c = 5 | |
159 | n = '0763ed7314c69015fd4a0dc16bbf4b90' # _KEY | |
160 | y = '8' # _REV | |
161 | r = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36' # _USER_AGENT | |
162 | e = user # _USERNAME | |
163 | t = clid # _CLIENT_ID | |
164 | ||
165 | d = '-'.join([str(mInt) for mInt in [a, i, s, w, u, l, b, k]]) | |
166 | p = n + y + d + r + e + t + d + n | |
167 | h = p | |
168 | ||
169 | m = 8011470 | |
170 | f = 0 | |
171 | ||
172 | for f in range(f, len(h)): | |
173 | m = (m >> 1) + ((1 & m) << 23) | |
174 | m += ord(h[f]) | |
175 | m &= 16777215 | |
176 | ||
177 | # c is not even needed | |
178 | out = str(y) + ':' + str(d) + ':' + format(m, 'x') + ':' + str(c) | |
179 | ||
180 | return out | |
181 | ||
182 | @classmethod | |
183 | def _resolv_url(cls, url): | |
184 | return cls._API_V2_BASE + 'resolve?url=' + url | |
185 | ||
186 | ||
187 | class SoundcloudIE(SoundcloudBaseIE): | |
aad0d6d5 PH |
188 | """Information extractor for soundcloud.com |
189 | To access the media, the uid of the song and a stream token | |
190 | must be extracted from the page source and the script must make | |
191 | a request to media.soundcloud.com/crossdomain.xml. Then | |
192 | the media can be grabbed by requesting from an url composed | |
193 | of the stream token and uid | |
194 | """ | |
195 | ||
20991253 | 196 | _VALID_URL = r'''(?x)^(?:https?://)? |
71507a11 | 197 | (?:(?:(?:www\.|m\.)?soundcloud\.com/ |
836ef264 | 198 | (?!stations/track) |
4ff50ef8 | 199 | (?P<uploader>[\w\d-]+)/ |
3ef2da2d | 200 | (?!(?:tracks|albums|sets(?:/.+?)?|reposts|likes|spotlight)/?(?:$|[?#])) |
c2dedf12 L |
201 | (?P<title>[\w\d-]+) |
202 | (?:/(?P<token>(?!(?:albums|sets|recommended))[^?]+?))? | |
203 | (?:[?].*)?$) | |
548c3957 | 204 | |(?:api(?:-v2)?\.soundcloud\.com/tracks/(?P<track_id>\d+) |
0403b069 | 205 | (?:/?\?secret_token=(?P<secret_token>[^&]+))?) |
eb6a41ba JMF |
206 | ) |
207 | ''' | |
fbcd7b5f | 208 | IE_NAME = 'soundcloud' |
12c167c8 JMF |
209 | _TESTS = [ |
210 | { | |
fbcd7b5f | 211 | 'url': 'http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy', |
fbcd7b5f PH |
212 | 'md5': 'ebef0a451b909710ed1d7787dddbf0d7', |
213 | 'info_dict': { | |
0eb9fb9f JMF |
214 | 'id': '62986583', |
215 | 'ext': 'mp3', | |
f516f440 | 216 | 'title': 'Lostin Powers - She so Heavy (SneakPreview) Adrian Ackers Blueprint 1', |
0eb9fb9f JMF |
217 | 'description': 'No Downloads untill we record the finished version this weekend, i was too pumped n i had to post it , earl is prolly gonna b hella p.o\'d', |
218 | 'uploader': 'E.T. ExTerrestrial Music', | |
548c3957 | 219 | 'uploader_id': '1571244', |
f516f440 S |
220 | 'timestamp': 1349920598, |
221 | 'upload_date': '20121011', | |
e09965d5 | 222 | 'duration': 143.216, |
4bfd294e | 223 | 'license': 'all-rights-reserved', |
f516f440 S |
224 | 'view_count': int, |
225 | 'like_count': int, | |
226 | 'comment_count': int, | |
227 | 'repost_count': int, | |
12c167c8 JMF |
228 | } |
229 | }, | |
a6c5859d | 230 | # geo-restricted |
12c167c8 | 231 | { |
fbcd7b5f PH |
232 | 'url': 'https://soundcloud.com/the-concept-band/goldrushed-mastered?in=the-concept-band/sets/the-royal-concept-ep', |
233 | 'info_dict': { | |
234 | 'id': '47127627', | |
235 | 'ext': 'mp3', | |
236 | 'title': 'Goldrushed', | |
63ad0315 | 237 | 'description': 'From Stockholm Sweden\r\nPovel / Magnus / Filip / David\r\nwww.theroyalconcept.com', |
fbcd7b5f | 238 | 'uploader': 'The Royal Concept', |
548c3957 | 239 | 'uploader_id': '9615865', |
f516f440 | 240 | 'timestamp': 1337635207, |
fbcd7b5f | 241 | 'upload_date': '20120521', |
a6c5859d | 242 | 'duration': 227.155, |
4bfd294e | 243 | 'license': 'all-rights-reserved', |
f516f440 S |
244 | 'view_count': int, |
245 | 'like_count': int, | |
246 | 'comment_count': int, | |
247 | 'repost_count': int, | |
12c167c8 | 248 | }, |
12c167c8 | 249 | }, |
de2dd4c5 JMF |
250 | # private link |
251 | { | |
7a5c1cfe | 252 | 'url': 'https://soundcloud.com/jaimemf/youtube-dl-test-video-a-y-baw/s-8Pjrp', |
fbcd7b5f PH |
253 | 'md5': 'aa0dd32bfea9b0c5ef4f02aacd080604', |
254 | 'info_dict': { | |
255 | 'id': '123998367', | |
256 | 'ext': 'mp3', | |
257 | 'title': 'Youtube - Dl Test Video \'\' Ä↭', | |
fbcd7b5f | 258 | 'description': 'test chars: \"\'/\\ä↭', |
f516f440 | 259 | 'uploader': 'jaimeMF', |
548c3957 | 260 | 'uploader_id': '69767071', |
f516f440 | 261 | 'timestamp': 1386604920, |
fbcd7b5f | 262 | 'upload_date': '20131209', |
e09965d5 | 263 | 'duration': 9.927, |
4bfd294e | 264 | 'license': 'all-rights-reserved', |
f516f440 S |
265 | 'view_count': int, |
266 | 'like_count': int, | |
267 | 'comment_count': int, | |
268 | 'repost_count': int, | |
de2dd4c5 JMF |
269 | }, |
270 | }, | |
9296738f | 271 | # private link (alt format) |
272 | { | |
273 | 'url': 'https://api.soundcloud.com/tracks/123998367?secret_token=s-8Pjrp', | |
274 | 'md5': 'aa0dd32bfea9b0c5ef4f02aacd080604', | |
275 | 'info_dict': { | |
276 | 'id': '123998367', | |
277 | 'ext': 'mp3', | |
278 | 'title': 'Youtube - Dl Test Video \'\' Ä↭', | |
9296738f | 279 | 'description': 'test chars: \"\'/\\ä↭', |
f516f440 | 280 | 'uploader': 'jaimeMF', |
548c3957 | 281 | 'uploader_id': '69767071', |
f516f440 | 282 | 'timestamp': 1386604920, |
9296738f | 283 | 'upload_date': '20131209', |
e09965d5 | 284 | 'duration': 9.927, |
4bfd294e | 285 | 'license': 'all-rights-reserved', |
f516f440 S |
286 | 'view_count': int, |
287 | 'like_count': int, | |
288 | 'comment_count': int, | |
289 | 'repost_count': int, | |
9296738f | 290 | }, |
291 | }, | |
f67ca84d JMF |
292 | # downloadable song |
293 | { | |
be05d5cf TOH |
294 | 'url': 'https://soundcloud.com/the80m/the-following', |
295 | 'md5': '9ffcddb08c87d74fb5808a3c183a1d04', | |
fbcd7b5f | 296 | 'info_dict': { |
be05d5cf TOH |
297 | 'id': '343609555', |
298 | 'ext': 'wav', | |
f67ca84d JMF |
299 | }, |
300 | }, | |
d7c7100e S |
301 | # private link, downloadable format |
302 | { | |
303 | 'url': 'https://soundcloud.com/oriuplift/uponly-238-no-talking-wav/s-AyZUd', | |
304 | 'md5': '64a60b16e617d41d0bef032b7f55441e', | |
305 | 'info_dict': { | |
306 | 'id': '340344461', | |
307 | 'ext': 'wav', | |
308 | 'title': 'Uplifting Only 238 [No Talking] (incl. Alex Feed Guestmix) (Aug 31, 2017) [wav]', | |
309 | 'description': 'md5:fa20ee0fca76a3d6df8c7e57f3715366', | |
310 | 'uploader': 'Ori Uplift Music', | |
548c3957 | 311 | 'uploader_id': '12563093', |
f516f440 | 312 | 'timestamp': 1504206263, |
d7c7100e | 313 | 'upload_date': '20170831', |
e09965d5 | 314 | 'duration': 7449.096, |
d7c7100e | 315 | 'license': 'all-rights-reserved', |
f516f440 S |
316 | 'view_count': int, |
317 | 'like_count': int, | |
318 | 'comment_count': int, | |
319 | 'repost_count': int, | |
d7c7100e S |
320 | }, |
321 | }, | |
0b0870f9 PV |
322 | # no album art, use avatar pic for thumbnail |
323 | { | |
324 | 'url': 'https://soundcloud.com/garyvee/sideways-prod-mad-real', | |
325 | 'md5': '59c7872bc44e5d99b7211891664760c2', | |
326 | 'info_dict': { | |
327 | 'id': '309699954', | |
328 | 'ext': 'mp3', | |
329 | 'title': 'Sideways (Prod. Mad Real)', | |
330 | 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', | |
331 | 'uploader': 'garyvee', | |
548c3957 | 332 | 'uploader_id': '2366352', |
f516f440 | 333 | 'timestamp': 1488152409, |
0b0870f9 | 334 | 'upload_date': '20170226', |
e09965d5 | 335 | 'duration': 207.012, |
0b0870f9 PV |
336 | 'thumbnail': r're:https?://.*\.jpg', |
337 | 'license': 'all-rights-reserved', | |
f516f440 S |
338 | 'view_count': int, |
339 | 'like_count': int, | |
340 | 'comment_count': int, | |
341 | 'repost_count': int, | |
0b0870f9 PV |
342 | }, |
343 | 'params': { | |
344 | 'skip_download': True, | |
345 | }, | |
346 | }, | |
e09965d5 S |
347 | { |
348 | 'url': 'https://soundcloud.com/giovannisarani/mezzo-valzer', | |
349 | 'md5': 'e22aecd2bc88e0e4e432d7dcc0a1abf7', | |
350 | 'info_dict': { | |
351 | 'id': '583011102', | |
352 | 'ext': 'mp3', | |
353 | 'title': 'Mezzo Valzer', | |
354 | 'description': 'md5:4138d582f81866a530317bae316e8b61', | |
2a5c26c9 | 355 | 'uploader': 'Micronie', |
548c3957 | 356 | 'uploader_id': '3352531', |
e09965d5 S |
357 | 'timestamp': 1551394171, |
358 | 'upload_date': '20190228', | |
359 | 'duration': 180.157, | |
360 | 'thumbnail': r're:https?://.*\.jpg', | |
361 | 'license': 'all-rights-reserved', | |
362 | 'view_count': int, | |
363 | 'like_count': int, | |
364 | 'comment_count': int, | |
365 | 'repost_count': int, | |
366 | }, | |
75294a5e S |
367 | }, |
368 | { | |
bc842c27 | 369 | # AAC HQ format available (account with active subscription needed) |
75294a5e S |
370 | 'url': 'https://soundcloud.com/wandw/the-chainsmokers-ft-daya-dont-let-me-down-ww-remix-1', |
371 | 'only_matching': True, | |
372 | }, | |
bc842c27 U |
373 | { |
374 | # Go+ (account with active subscription needed) | |
375 | 'url': 'https://soundcloud.com/taylorswiftofficial/look-what-you-made-me-do', | |
376 | 'only_matching': True, | |
377 | }, | |
12c167c8 | 378 | ] |
aad0d6d5 | 379 | |
548c3957 RA |
380 | _IMAGE_REPL_RE = r'-([0-9a-z]+)\.jpg' |
381 | ||
382 | _ARTWORK_MAP = { | |
383 | 'mini': 16, | |
384 | 'tiny': 20, | |
385 | 'small': 32, | |
386 | 'badge': 47, | |
387 | 't67x67': 67, | |
388 | 'large': 100, | |
389 | 't300x300': 300, | |
390 | 'crop': 400, | |
391 | 't500x500': 500, | |
392 | 'original': 0, | |
393 | } | |
fbdf8d15 | 394 | |
a6c5859d | 395 | def _extract_info_dict(self, info, full_title=None, secret_token=None): |
12c167c8 | 396 | track_id = compat_str(info['id']) |
f516f440 | 397 | title = info['title'] |
e09965d5 S |
398 | |
399 | format_urls = set() | |
5e114e4b | 400 | formats = [] |
73602bcd | 401 | query = {'client_id': self._CLIENT_ID} |
548c3957 | 402 | if secret_token: |
73602bcd | 403 | query['secret_token'] = secret_token |
548c3957 | 404 | |
2e9ad59a | 405 | if info.get('downloadable') and info.get('has_downloads_left'): |
a6c5859d RA |
406 | download_url = update_url_query( |
407 | self._API_V2_BASE + 'tracks/' + track_id + '/download', query) | |
408 | redirect_url = (self._download_json(download_url, track_id, fatal=False) or {}).get('redirectUri') | |
409 | if redirect_url: | |
410 | urlh = self._request_webpage( | |
411 | HEADRequest(redirect_url), track_id, fatal=False) | |
412 | if urlh: | |
413 | format_url = urlh.geturl() | |
414 | format_urls.add(format_url) | |
415 | formats.append({ | |
416 | 'format_id': 'download', | |
417 | 'ext': urlhandle_detect_ext(urlh) or 'mp3', | |
418 | 'filesize': int_or_none(urlh.headers.get('Content-Length')), | |
419 | 'url': format_url, | |
f983b875 | 420 | 'quality': 10, |
a6c5859d | 421 | }) |
5e114e4b | 422 | |
548c3957 | 423 | def invalid_url(url): |
e4e5fa6e | 424 | return not url or url in format_urls |
e09965d5 | 425 | |
e4e5fa6e | 426 | def add_format(f, protocol, is_preview=False): |
548c3957 RA |
427 | mobj = re.search(r'\.(?P<abr>\d+)\.(?P<ext>[0-9a-z]{3,4})(?=[/?])', stream_url) |
428 | if mobj: | |
429 | for k, v in mobj.groupdict().items(): | |
430 | if not f.get(k): | |
431 | f[k] = v | |
432 | format_id_list = [] | |
433 | if protocol: | |
434 | format_id_list.append(protocol) | |
75294a5e S |
435 | ext = f.get('ext') |
436 | if ext == 'aac': | |
b9e5f872 | 437 | f['abr'] = '256' |
548c3957 RA |
438 | for k in ('ext', 'abr'): |
439 | v = f.get(k) | |
440 | if v: | |
441 | format_id_list.append(v) | |
e4e5fa6e S |
442 | preview = is_preview or re.search(r'/(?:preview|playlist)/0/30/', f['url']) |
443 | if preview: | |
444 | format_id_list.append('preview') | |
548c3957 RA |
445 | abr = f.get('abr') |
446 | if abr: | |
447 | f['abr'] = int(abr) | |
75294a5e S |
448 | if protocol == 'hls': |
449 | protocol = 'm3u8' if ext == 'aac' else 'm3u8_native' | |
450 | else: | |
451 | protocol = 'http' | |
548c3957 RA |
452 | f.update({ |
453 | 'format_id': '_'.join(format_id_list), | |
75294a5e | 454 | 'protocol': protocol, |
e4e5fa6e | 455 | 'preference': -10 if preview else None, |
548c3957 RA |
456 | }) |
457 | formats.append(f) | |
e09965d5 S |
458 | |
459 | # New API | |
460 | transcodings = try_get( | |
461 | info, lambda x: x['media']['transcodings'], list) or [] | |
462 | for t in transcodings: | |
463 | if not isinstance(t, dict): | |
3a194cb4 | 464 | continue |
e09965d5 | 465 | format_url = url_or_none(t.get('url')) |
e4e5fa6e | 466 | if not format_url: |
e09965d5 S |
467 | continue |
468 | stream = self._download_json( | |
fb4126a1 | 469 | format_url, track_id, query=query, fatal=False, headers=self._HEADERS) |
e09965d5 S |
470 | if not isinstance(stream, dict): |
471 | continue | |
472 | stream_url = url_or_none(stream.get('url')) | |
548c3957 | 473 | if invalid_url(stream_url): |
e09965d5 S |
474 | continue |
475 | format_urls.add(stream_url) | |
548c3957 RA |
476 | stream_format = t.get('format') or {} |
477 | protocol = stream_format.get('protocol') | |
e09965d5 S |
478 | if protocol != 'hls' and '/hls' in format_url: |
479 | protocol = 'hls' | |
480 | ext = None | |
481 | preset = str_or_none(t.get('preset')) | |
482 | if preset: | |
483 | ext = preset.split('_')[0] | |
548c3957 RA |
484 | if ext not in KNOWN_EXTENSIONS: |
485 | ext = mimetype2ext(stream_format.get('mime_type')) | |
486 | add_format({ | |
e09965d5 | 487 | 'url': stream_url, |
e09965d5 | 488 | 'ext': ext, |
e4e5fa6e S |
489 | }, 'http' if protocol == 'progressive' else protocol, |
490 | t.get('snipped') or '/preview/' in format_url) | |
548c3957 | 491 | |
3a194cb4 S |
492 | for f in formats: |
493 | f['vcodec'] = 'none' | |
2a15e706 | 494 | |
a6c5859d | 495 | if not formats and info.get('policy') == 'BLOCK': |
b7da73eb | 496 | self.raise_geo_restricted(metadata_available=True) |
562ceab1 | 497 | self._sort_formats(formats) |
64bb5187 | 498 | |
548c3957 RA |
499 | user = info.get('user') or {} |
500 | ||
501 | thumbnails = [] | |
502 | artwork_url = info.get('artwork_url') | |
503 | thumbnail = artwork_url or user.get('avatar_url') | |
504 | if isinstance(thumbnail, compat_str): | |
505 | if re.search(self._IMAGE_REPL_RE, thumbnail): | |
506 | for image_id, size in self._ARTWORK_MAP.items(): | |
507 | i = { | |
508 | 'id': image_id, | |
509 | 'url': re.sub(self._IMAGE_REPL_RE, '-%s.jpg' % image_id, thumbnail), | |
510 | } | |
511 | if image_id == 'tiny' and not artwork_url: | |
512 | size = 18 | |
513 | elif image_id == 'original': | |
514 | i['preference'] = 10 | |
515 | if size: | |
516 | i.update({ | |
517 | 'width': size, | |
518 | 'height': size, | |
519 | }) | |
520 | thumbnails.append(i) | |
521 | else: | |
522 | thumbnails = [{'url': thumbnail}] | |
523 | ||
524 | def extract_count(key): | |
525 | return int_or_none(info.get('%s_count' % key)) | |
526 | ||
527 | return { | |
528 | 'id': track_id, | |
529 | 'uploader': user.get('username'), | |
530 | 'uploader_id': str_or_none(user.get('id')) or user.get('permalink'), | |
531 | 'uploader_url': user.get('permalink_url'), | |
532 | 'timestamp': unified_timestamp(info.get('created_at')), | |
533 | 'title': title, | |
534 | 'description': info.get('description'), | |
535 | 'thumbnails': thumbnails, | |
536 | 'duration': float_or_none(info.get('duration'), 1000), | |
537 | 'webpage_url': info.get('permalink_url'), | |
538 | 'license': info.get('license'), | |
539 | 'view_count': extract_count('playback'), | |
540 | 'like_count': extract_count('favoritings') or extract_count('likes'), | |
541 | 'comment_count': extract_count('comment'), | |
542 | 'repost_count': extract_count('reposts'), | |
543 | 'genre': info.get('genre'), | |
544 | 'formats': formats | |
545 | } | |
7d239269 | 546 | |
aad0d6d5 | 547 | def _real_extract(self, url): |
5ad28e7f | 548 | mobj = self._match_valid_url(url) |
aad0d6d5 | 549 | |
eb6a41ba | 550 | track_id = mobj.group('track_id') |
4bfd294e | 551 | |
3bed6217 | 552 | query = {} |
548c3957 RA |
553 | if track_id: |
554 | info_json_url = self._API_V2_BASE + 'tracks/' + track_id | |
eb6a41ba | 555 | full_title = track_id |
9296738f | 556 | token = mobj.group('secret_token') |
557 | if token: | |
548c3957 | 558 | query['secret_token'] = token |
eb6a41ba | 559 | else: |
548c3957 | 560 | full_title = resolve_title = '%s/%s' % mobj.group('uploader', 'title') |
de2dd4c5 | 561 | token = mobj.group('token') |
de2dd4c5 JMF |
562 | if token: |
563 | resolve_title += '/%s' % token | |
548c3957 | 564 | info_json_url = self._resolv_url(self._BASE_URL + resolve_title) |
5f6a1245 | 565 | |
e09965d5 | 566 | info = self._download_json( |
fb4126a1 | 567 | info_json_url, full_title, 'Downloading info JSON', query=query, headers=self._HEADERS) |
a6c5859d RA |
568 | |
569 | return self._extract_info_dict(info, full_title, token) | |
aad0d6d5 | 570 | |
20991253 | 571 | |
63ccf4ff | 572 | class SoundcloudPlaylistBaseIE(SoundcloudBaseIE): |
2a5c26c9 RA |
573 | def _extract_set(self, playlist, token=None): |
574 | playlist_id = compat_str(playlist['id']) | |
575 | tracks = playlist.get('tracks') or [] | |
576 | if not all([t.get('permalink_url') for t in tracks]) and token: | |
577 | tracks = self._download_json( | |
578 | self._API_V2_BASE + 'tracks', playlist_id, | |
579 | 'Downloading tracks', query={ | |
580 | 'ids': ','.join([compat_str(t['id']) for t in tracks]), | |
581 | 'playlistId': playlist_id, | |
582 | 'playlistSecretToken': token, | |
fb4126a1 | 583 | }, headers=self._HEADERS) |
548c3957 RA |
584 | entries = [] |
585 | for track in tracks: | |
586 | track_id = str_or_none(track.get('id')) | |
587 | url = track.get('permalink_url') | |
588 | if not url: | |
589 | if not track_id: | |
590 | continue | |
591 | url = self._API_V2_BASE + 'tracks/' + track_id | |
592 | if token: | |
593 | url += '?secret_token=' + token | |
594 | entries.append(self.url_result( | |
595 | url, SoundcloudIE.ie_key(), track_id)) | |
2a5c26c9 RA |
596 | return self.playlist_result( |
597 | entries, playlist_id, | |
598 | playlist.get('title'), | |
599 | playlist.get('description')) | |
8e45e1cc S |
600 | |
601 | ||
7518a61d | 602 | class SoundcloudSetIE(SoundcloudPlaylistBaseIE): |
906f980a | 603 | _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/(?P<uploader>[\w\d-]+)/sets/(?P<slug_title>[:\w\d-]+)(?:/(?P<token>[^?/]+))?' |
fbcd7b5f | 604 | IE_NAME = 'soundcloud:set' |
22a6f150 PH |
605 | _TESTS = [{ |
606 | 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep', | |
607 | 'info_dict': { | |
a9551e90 | 608 | 'id': '2284613', |
22a6f150 | 609 | 'title': 'The Royal Concept EP', |
2a5c26c9 | 610 | 'description': 'md5:71d07087c7a449e8941a70a29e34671e', |
22a6f150 | 611 | }, |
bf2dc9cc | 612 | 'playlist_mincount': 5, |
f7043ef3 S |
613 | }, { |
614 | 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep/token', | |
615 | 'only_matching': True, | |
906f980a U |
616 | }, { |
617 | 'url': 'https://soundcloud.com/discover/sets/weekly::flacmatic', | |
618 | 'only_matching': True, | |
619 | }, { | |
620 | 'url': 'https://soundcloud.com/discover/sets/charts-top:all-music:de', | |
621 | 'only_matching': True, | |
622 | }, { | |
623 | 'url': 'https://soundcloud.com/discover/sets/charts-top:hiphoprap:kr', | |
624 | 'only_matching': True, | |
22a6f150 | 625 | }] |
aad0d6d5 | 626 | |
aad0d6d5 | 627 | def _real_extract(self, url): |
5ad28e7f | 628 | mobj = self._match_valid_url(url) |
aad0d6d5 | 629 | |
548c3957 | 630 | full_title = '%s/sets/%s' % mobj.group('uploader', 'slug_title') |
2f834e93 | 631 | token = mobj.group('token') |
632 | if token: | |
633 | full_title += '/' + token | |
aad0d6d5 | 634 | |
548c3957 | 635 | info = self._download_json(self._resolv_url( |
fb4126a1 | 636 | self._BASE_URL + full_title), full_title, headers=self._HEADERS) |
aad0d6d5 | 637 | |
aad0d6d5 | 638 | if 'errors' in info: |
214e74bf JMF |
639 | msgs = (compat_str(err['error_message']) for err in info['errors']) |
640 | raise ExtractorError('unable to download video webpage: %s' % ','.join(msgs)) | |
aad0d6d5 | 641 | |
2a5c26c9 | 642 | return self._extract_set(info, token) |
92790f4e JMF |
643 | |
644 | ||
63ccf4ff | 645 | class SoundcloudPagedPlaylistBaseIE(SoundcloudBaseIE): |
836ef264 | 646 | def _extract_playlist(self, base_url, playlist_id, playlist_title): |
aa6c2530 | 647 | return { |
648 | '_type': 'playlist', | |
649 | 'id': playlist_id, | |
650 | 'title': playlist_title, | |
651 | 'entries': self._entries(base_url, playlist_id), | |
652 | } | |
653 | ||
e04a1ff9 | 654 | def _entries(self, url, playlist_id): |
a0566bbf | 655 | # Per the SoundCloud documentation, the maximum limit for a linked partitioning query is 200. |
aa272535 | 656 | # https://developers.soundcloud.com/blog/offset-pagination-deprecated |
aa6c2530 | 657 | query = { |
38970916 | 658 | 'limit': 200, |
836ef264 | 659 | 'linked_partitioning': '1', |
aa6c2530 | 660 | 'offset': 0, |
836ef264 S |
661 | } |
662 | ||
836ef264 | 663 | for i in itertools.count(): |
be5c1ae8 | 664 | for retry in self.RetryManager(): |
e04a1ff9 | 665 | try: |
666 | response = self._download_json( | |
667 | url, playlist_id, query=query, headers=self._HEADERS, | |
be5c1ae8 | 668 | note=f'Downloading track page {i + 1}') |
e04a1ff9 | 669 | break |
670 | except ExtractorError as e: | |
671 | # Downloading page may result in intermittent 502 HTTP error | |
672 | # See https://github.com/yt-dlp/yt-dlp/issues/872 | |
be5c1ae8 | 673 | if not isinstance(e.cause, compat_HTTPError) or e.cause.code != 502: |
e04a1ff9 | 674 | raise |
be5c1ae8 | 675 | retry.error = e |
676 | continue | |
836ef264 | 677 | |
aa6c2530 | 678 | def resolve_entry(*candidates): |
7c5307f4 S |
679 | for cand in candidates: |
680 | if not isinstance(cand, dict): | |
681 | continue | |
682 | permalink_url = url_or_none(cand.get('permalink_url')) | |
aa6c2530 | 683 | if permalink_url: |
684 | return self.url_result( | |
685 | permalink_url, | |
686 | SoundcloudIE.ie_key() if SoundcloudIE.suitable(permalink_url) else None, | |
687 | str_or_none(cand.get('id')), cand.get('title')) | |
836ef264 | 688 | |
aa6c2530 | 689 | for e in response['collection'] or []: |
690 | yield resolve_entry(e, e.get('track'), e.get('playlist')) | |
836ef264 | 691 | |
e04a1ff9 | 692 | url = response.get('next_href') |
644149af | 693 | if not url: |
694 | break | |
aa6c2530 | 695 | query.pop('offset', None) |
836ef264 | 696 | |
836ef264 | 697 | |
836ef264 | 698 | class SoundcloudUserIE(SoundcloudPagedPlaylistBaseIE): |
16a08978 S |
699 | _VALID_URL = r'''(?x) |
700 | https?:// | |
701 | (?:(?:www|m)\.)?soundcloud\.com/ | |
702 | (?P<user>[^/]+) | |
703 | (?:/ | |
3ef2da2d | 704 | (?P<rsrc>tracks|albums|sets|reposts|likes|spotlight) |
16a08978 S |
705 | )? |
706 | /?(?:[?#].*)?$ | |
707 | ''' | |
fbcd7b5f | 708 | IE_NAME = 'soundcloud:user' |
22a6f150 | 709 | _TESTS = [{ |
b6423e6c | 710 | 'url': 'https://soundcloud.com/soft-cell-official', |
22a6f150 | 711 | 'info_dict': { |
b6423e6c S |
712 | 'id': '207965082', |
713 | 'title': 'Soft Cell (All)', | |
22a6f150 | 714 | }, |
b6423e6c | 715 | 'playlist_mincount': 28, |
22a6f150 | 716 | }, { |
b6423e6c | 717 | 'url': 'https://soundcloud.com/soft-cell-official/tracks', |
22a6f150 | 718 | 'info_dict': { |
b6423e6c S |
719 | 'id': '207965082', |
720 | 'title': 'Soft Cell (Tracks)', | |
22a6f150 | 721 | }, |
b6423e6c | 722 | 'playlist_mincount': 27, |
03b9c944 | 723 | }, { |
b6423e6c S |
724 | 'url': 'https://soundcloud.com/soft-cell-official/albums', |
725 | 'info_dict': { | |
726 | 'id': '207965082', | |
727 | 'title': 'Soft Cell (Albums)', | |
728 | }, | |
729 | 'playlist_mincount': 1, | |
730 | }, { | |
731 | 'url': 'https://soundcloud.com/jcv246/sets', | |
80fb6d4a | 732 | 'info_dict': { |
b6423e6c | 733 | 'id': '12982173', |
548c3957 | 734 | 'title': 'Jordi / cv (Sets)', |
80fb6d4a | 735 | }, |
8e45e1cc | 736 | 'playlist_mincount': 2, |
80fb6d4a | 737 | }, { |
b6423e6c | 738 | 'url': 'https://soundcloud.com/jcv246/reposts', |
80fb6d4a | 739 | 'info_dict': { |
b6423e6c S |
740 | 'id': '12982173', |
741 | 'title': 'Jordi / cv (Reposts)', | |
80fb6d4a | 742 | }, |
b6423e6c | 743 | 'playlist_mincount': 6, |
80fb6d4a | 744 | }, { |
b6423e6c | 745 | 'url': 'https://soundcloud.com/clalberg/likes', |
80fb6d4a | 746 | 'info_dict': { |
b6423e6c S |
747 | 'id': '11817582', |
748 | 'title': 'clalberg (Likes)', | |
80fb6d4a | 749 | }, |
b6423e6c | 750 | 'playlist_mincount': 5, |
80fb6d4a S |
751 | }, { |
752 | 'url': 'https://soundcloud.com/grynpyret/spotlight', | |
753 | 'info_dict': { | |
754 | 'id': '7098329', | |
bf2dc9cc | 755 | 'title': 'Grynpyret (Spotlight)', |
80fb6d4a S |
756 | }, |
757 | 'playlist_mincount': 1, | |
22a6f150 | 758 | }] |
92790f4e | 759 | |
80fb6d4a | 760 | _BASE_URL_MAP = { |
548c3957 RA |
761 | 'all': 'stream/users/%s', |
762 | 'tracks': 'users/%s/tracks', | |
763 | 'albums': 'users/%s/albums', | |
764 | 'sets': 'users/%s/playlists', | |
765 | 'reposts': 'stream/users/%s/reposts', | |
766 | 'likes': 'users/%s/likes', | |
767 | 'spotlight': 'users/%s/spotlight', | |
80fb6d4a S |
768 | } |
769 | ||
92790f4e | 770 | def _real_extract(self, url): |
5ad28e7f | 771 | mobj = self._match_valid_url(url) |
92790f4e JMF |
772 | uploader = mobj.group('user') |
773 | ||
20991253 | 774 | user = self._download_json( |
548c3957 | 775 | self._resolv_url(self._BASE_URL + uploader), |
fb4126a1 | 776 | uploader, 'Downloading user info', headers=self._HEADERS) |
80fb6d4a S |
777 | |
778 | resource = mobj.group('rsrc') or 'all' | |
80fb6d4a | 779 | |
836ef264 | 780 | return self._extract_playlist( |
548c3957 RA |
781 | self._API_V2_BASE + self._BASE_URL_MAP[resource] % user['id'], |
782 | str_or_none(user.get('id')), | |
783 | '%s (%s)' % (user['username'], resource.capitalize())) | |
97afd99a | 784 | |
92790f4e | 785 | |
836ef264 S |
786 | class SoundcloudTrackStationIE(SoundcloudPagedPlaylistBaseIE): |
787 | _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/stations/track/[^/]+/(?P<id>[^/?#&]+)' | |
788 | IE_NAME = 'soundcloud:trackstation' | |
789 | _TESTS = [{ | |
790 | 'url': 'https://soundcloud.com/stations/track/officialsundial/your-text', | |
791 | 'info_dict': { | |
792 | 'id': '286017854', | |
548c3957 | 793 | 'title': 'Track station: your text', |
836ef264 S |
794 | }, |
795 | 'playlist_mincount': 47, | |
796 | }] | |
80fb6d4a | 797 | |
836ef264 S |
798 | def _real_extract(self, url): |
799 | track_name = self._match_id(url) | |
80fb6d4a | 800 | |
fb4126a1 | 801 | track = self._download_json(self._resolv_url(url), track_name, headers=self._HEADERS) |
836ef264 | 802 | track_id = self._search_regex( |
548c3957 | 803 | r'soundcloud:track-stations:(\d+)', track['id'], 'track id') |
92790f4e | 804 | |
836ef264 | 805 | return self._extract_playlist( |
548c3957 RA |
806 | self._API_V2_BASE + 'stations/%s/tracks' % track['id'], |
807 | track_id, 'Track station: %s' % track['title']) | |
20991253 PH |
808 | |
809 | ||
c2dedf12 L |
810 | class SoundcloudRelatedIE(SoundcloudPagedPlaylistBaseIE): |
811 | _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/(?P<slug>[\w\d-]+/[\w\d-]+)/(?P<relation>albums|sets|recommended)' | |
812 | IE_NAME = 'soundcloud:related' | |
813 | _TESTS = [{ | |
814 | 'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/recommended', | |
815 | 'info_dict': { | |
816 | 'id': '1084577272', | |
817 | 'title': 'Sexapil - Pingers 5 (Recommended)', | |
818 | }, | |
819 | 'playlist_mincount': 50, | |
820 | }, { | |
821 | 'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/albums', | |
822 | 'info_dict': { | |
823 | 'id': '1084577272', | |
824 | 'title': 'Sexapil - Pingers 5 (Albums)', | |
825 | }, | |
826 | 'playlist_mincount': 1, | |
827 | }, { | |
828 | 'url': 'https://soundcloud.com/wajang/sexapil-pingers-5/sets', | |
829 | 'info_dict': { | |
830 | 'id': '1084577272', | |
831 | 'title': 'Sexapil - Pingers 5 (Sets)', | |
832 | }, | |
833 | 'playlist_mincount': 4, | |
834 | }] | |
835 | ||
836 | _BASE_URL_MAP = { | |
837 | 'albums': 'tracks/%s/albums', | |
838 | 'sets': 'tracks/%s/playlists_without_albums', | |
839 | 'recommended': 'tracks/%s/related', | |
840 | } | |
841 | ||
842 | def _real_extract(self, url): | |
843 | slug, relation = self._match_valid_url(url).group('slug', 'relation') | |
844 | ||
845 | track = self._download_json( | |
846 | self._resolv_url(self._BASE_URL + slug), | |
847 | slug, 'Downloading track info', headers=self._HEADERS) | |
848 | ||
849 | if track.get('errors'): | |
850 | raise ExtractorError(f'{self.IE_NAME} said: %s' % ','.join( | |
851 | str(err['error_message']) for err in track['errors']), expected=True) | |
852 | ||
853 | return self._extract_playlist( | |
854 | self._API_V2_BASE + self._BASE_URL_MAP[relation] % track['id'], str(track['id']), | |
855 | '%s (%s)' % (track.get('title') or slug, relation.capitalize())) | |
856 | ||
857 | ||
7518a61d | 858 | class SoundcloudPlaylistIE(SoundcloudPlaylistBaseIE): |
548c3957 | 859 | _VALID_URL = r'https?://api(?:-v2)?\.soundcloud\.com/playlists/(?P<id>[0-9]+)(?:/?\?secret_token=(?P<token>[^&]+?))?$' |
20991253 | 860 | IE_NAME = 'soundcloud:playlist' |
46f74bcf | 861 | _TESTS = [{ |
f1c05100 | 862 | 'url': 'https://api.soundcloud.com/playlists/4110309', |
46f74bcf PH |
863 | 'info_dict': { |
864 | 'id': '4110309', | |
865 | 'title': 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]', | |
866 | 'description': 're:.*?TILT Brass - Bowery Poetry Club', | |
867 | }, | |
868 | 'playlist_count': 6, | |
869 | }] | |
20991253 PH |
870 | |
871 | def _real_extract(self, url): | |
5ad28e7f | 872 | mobj = self._match_valid_url(url) |
20991253 | 873 | playlist_id = mobj.group('id') |
20991253 | 874 | |
3bed6217 | 875 | query = {} |
2f834e93 | 876 | token = mobj.group('token') |
2f834e93 | 877 | if token: |
548c3957 | 878 | query['secret_token'] = token |
2f834e93 | 879 | |
20991253 | 880 | data = self._download_json( |
548c3957 | 881 | self._API_V2_BASE + 'playlists/' + playlist_id, |
fb4126a1 | 882 | playlist_id, 'Downloading playlist', query=query, headers=self._HEADERS) |
20991253 | 883 | |
2a5c26c9 | 884 | return self._extract_set(data, token) |
2abf7cab | 885 | |
886 | ||
63ccf4ff | 887 | class SoundcloudSearchIE(SoundcloudBaseIE, SearchInfoExtractor): |
2abf7cab | 888 | IE_NAME = 'soundcloud:search' |
96565c7e | 889 | IE_DESC = 'Soundcloud search' |
890 | _SEARCH_KEY = 'scsearch' | |
2abf7cab | 891 | _TESTS = [{ |
892 | 'url': 'scsearch15:post-avant jazzcore', | |
893 | 'info_dict': { | |
894 | 'title': 'post-avant jazzcore', | |
895 | }, | |
896 | 'playlist_count': 15, | |
897 | }] | |
898 | ||
328a22e1 | 899 | _MAX_RESULTS_PER_PAGE = 200 |
900 | _DEFAULT_RESULTS_PER_PAGE = 50 | |
2abf7cab | 901 | |
902 | def _get_collection(self, endpoint, collection_id, **query): | |
a3372437 | 903 | limit = min( |
328a22e1 | 904 | query.get('limit', self._DEFAULT_RESULTS_PER_PAGE), |
905 | self._MAX_RESULTS_PER_PAGE) | |
548c3957 RA |
906 | query.update({ |
907 | 'limit': limit, | |
548c3957 RA |
908 | 'linked_partitioning': 1, |
909 | 'offset': 0, | |
910 | }) | |
911 | next_url = update_url_query(self._API_V2_BASE + endpoint, query) | |
2abf7cab | 912 | |
f6c903e7 | 913 | for i in itertools.count(1): |
7e347275 | 914 | response = self._download_json( |
cc16383f | 915 | next_url, collection_id, f'Downloading page {i}', |
fb4126a1 | 916 | 'Unable to download API page', headers=self._HEADERS) |
2abf7cab | 917 | |
cc16383f | 918 | for item in response.get('collection') or []: |
919 | if item: | |
920 | yield self.url_result(item['uri'], SoundcloudIE.ie_key()) | |
2abf7cab | 921 | |
7e347275 | 922 | next_url = response.get('next_href') |
f6c903e7 S |
923 | if not next_url: |
924 | break | |
2abf7cab | 925 | |
926 | def _get_n_results(self, query, n): | |
8863c8f0 | 927 | return self.playlist_result(itertools.islice( |
928 | self._get_collection('search/tracks', query, limit=n, q=query), | |
929 | 0, None if n == float('inf') else n), query, query) |