You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

633 lines
23 KiB

10 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import itertools
  4. import re
  5. from .common import (
  6. InfoExtractor,
  7. SearchInfoExtractor
  8. )
  9. from ..compat import (
  10. compat_str,
  11. compat_urlparse,
  12. compat_urllib_parse_urlencode,
  13. )
  14. from ..utils import (
  15. ExtractorError,
  16. int_or_none,
  17. unified_strdate,
  18. update_url_query,
  19. )
  20. class SoundcloudIE(InfoExtractor):
  21. """Information extractor for soundcloud.com
  22. To access the media, the uid of the song and a stream token
  23. must be extracted from the page source and the script must make
  24. a request to media.soundcloud.com/crossdomain.xml. Then
  25. the media can be grabbed by requesting from an url composed
  26. of the stream token and uid
  27. """
  28. _VALID_URL = r'''(?x)^(?:https?://)?
  29. (?:(?:(?:www\.|m\.)?soundcloud\.com/
  30. (?!stations/track)
  31. (?P<uploader>[\w\d-]+)/
  32. (?!(?:tracks|sets(?:/.+?)?|reposts|likes|spotlight)/?(?:$|[?#]))
  33. (?P<title>[\w\d-]+)/?
  34. (?P<token>[^?]+?)?(?:[?].*)?$)
  35. |(?:api\.soundcloud\.com/tracks/(?P<track_id>\d+)
  36. (?:/?\?secret_token=(?P<secret_token>[^&]+))?)
  37. |(?P<player>(?:w|player|p.)\.soundcloud\.com/player/?.*?url=.*)
  38. )
  39. '''
  40. IE_NAME = 'soundcloud'
  41. _TESTS = [
  42. {
  43. 'url': 'http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy',
  44. 'md5': 'ebef0a451b909710ed1d7787dddbf0d7',
  45. 'info_dict': {
  46. 'id': '62986583',
  47. 'ext': 'mp3',
  48. 'upload_date': '20121011',
  49. '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',
  50. 'uploader': 'E.T. ExTerrestrial Music',
  51. 'title': 'Lostin Powers - She so Heavy (SneakPreview) Adrian Ackers Blueprint 1',
  52. 'duration': 143,
  53. 'license': 'all-rights-reserved',
  54. }
  55. },
  56. # not streamable song
  57. {
  58. 'url': 'https://soundcloud.com/the-concept-band/goldrushed-mastered?in=the-concept-band/sets/the-royal-concept-ep',
  59. 'info_dict': {
  60. 'id': '47127627',
  61. 'ext': 'mp3',
  62. 'title': 'Goldrushed',
  63. 'description': 'From Stockholm Sweden\r\nPovel / Magnus / Filip / David\r\nwww.theroyalconcept.com',
  64. 'uploader': 'The Royal Concept',
  65. 'upload_date': '20120521',
  66. 'duration': 227,
  67. 'license': 'all-rights-reserved',
  68. },
  69. 'params': {
  70. # rtmp
  71. 'skip_download': True,
  72. },
  73. },
  74. # private link
  75. {
  76. 'url': 'https://soundcloud.com/jaimemf/youtube-dl-test-video-a-y-baw/s-8Pjrp',
  77. 'md5': 'aa0dd32bfea9b0c5ef4f02aacd080604',
  78. 'info_dict': {
  79. 'id': '123998367',
  80. 'ext': 'mp3',
  81. 'title': 'Youtube - Dl Test Video \'\' Ä↭',
  82. 'uploader': 'jaimeMF',
  83. 'description': 'test chars: \"\'/\\ä↭',
  84. 'upload_date': '20131209',
  85. 'duration': 9,
  86. 'license': 'all-rights-reserved',
  87. },
  88. },
  89. # private link (alt format)
  90. {
  91. 'url': 'https://api.soundcloud.com/tracks/123998367?secret_token=s-8Pjrp',
  92. 'md5': 'aa0dd32bfea9b0c5ef4f02aacd080604',
  93. 'info_dict': {
  94. 'id': '123998367',
  95. 'ext': 'mp3',
  96. 'title': 'Youtube - Dl Test Video \'\' Ä↭',
  97. 'uploader': 'jaimeMF',
  98. 'description': 'test chars: \"\'/\\ä↭',
  99. 'upload_date': '20131209',
  100. 'duration': 9,
  101. 'license': 'all-rights-reserved',
  102. },
  103. },
  104. # downloadable song
  105. {
  106. 'url': 'https://soundcloud.com/oddsamples/bus-brakes',
  107. 'md5': '7624f2351f8a3b2e7cd51522496e7631',
  108. 'info_dict': {
  109. 'id': '128590877',
  110. 'ext': 'mp3',
  111. 'title': 'Bus Brakes',
  112. 'description': 'md5:0053ca6396e8d2fd7b7e1595ef12ab66',
  113. 'uploader': 'oddsamples',
  114. 'upload_date': '20140109',
  115. 'duration': 17,
  116. 'license': 'cc-by-sa',
  117. },
  118. },
  119. # private link, downloadable format
  120. {
  121. 'url': 'https://soundcloud.com/oriuplift/uponly-238-no-talking-wav/s-AyZUd',
  122. 'md5': '64a60b16e617d41d0bef032b7f55441e',
  123. 'info_dict': {
  124. 'id': '340344461',
  125. 'ext': 'wav',
  126. 'title': 'Uplifting Only 238 [No Talking] (incl. Alex Feed Guestmix) (Aug 31, 2017) [wav]',
  127. 'description': 'md5:fa20ee0fca76a3d6df8c7e57f3715366',
  128. 'uploader': 'Ori Uplift Music',
  129. 'upload_date': '20170831',
  130. 'duration': 7449,
  131. 'license': 'all-rights-reserved',
  132. },
  133. },
  134. # no album art, use avatar pic for thumbnail
  135. {
  136. 'url': 'https://soundcloud.com/garyvee/sideways-prod-mad-real',
  137. 'md5': '59c7872bc44e5d99b7211891664760c2',
  138. 'info_dict': {
  139. 'id': '309699954',
  140. 'ext': 'mp3',
  141. 'title': 'Sideways (Prod. Mad Real)',
  142. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  143. 'uploader': 'garyvee',
  144. 'upload_date': '20170226',
  145. 'duration': 207,
  146. 'thumbnail': r're:https?://.*\.jpg',
  147. 'license': 'all-rights-reserved',
  148. },
  149. 'params': {
  150. 'skip_download': True,
  151. },
  152. },
  153. ]
  154. _CLIENT_ID = 'LvWovRaJZlWCHql0bISuum8Bd2KX79mb'
  155. @staticmethod
  156. def _extract_urls(webpage):
  157. return [m.group('url') for m in re.finditer(
  158. r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?(?:w\.)?soundcloud\.com/player.+?)\1',
  159. webpage)]
  160. def report_resolve(self, video_id):
  161. """Report information extraction."""
  162. self.to_screen('%s: Resolving id' % video_id)
  163. @classmethod
  164. def _resolv_url(cls, url):
  165. return 'https://api.soundcloud.com/resolve.json?url=' + url + '&client_id=' + cls._CLIENT_ID
  166. def _extract_info_dict(self, info, full_title=None, quiet=False, secret_token=None):
  167. track_id = compat_str(info['id'])
  168. name = full_title or track_id
  169. if quiet:
  170. self.report_extraction(name)
  171. thumbnail = info.get('artwork_url') or info.get('user', {}).get('avatar_url')
  172. if isinstance(thumbnail, compat_str):
  173. thumbnail = thumbnail.replace('-large', '-t500x500')
  174. ext = 'mp3'
  175. result = {
  176. 'id': track_id,
  177. 'uploader': info.get('user', {}).get('username'),
  178. 'upload_date': unified_strdate(info.get('created_at')),
  179. 'title': info['title'],
  180. 'description': info.get('description'),
  181. 'thumbnail': thumbnail,
  182. 'duration': int_or_none(info.get('duration'), 1000),
  183. 'webpage_url': info.get('permalink_url'),
  184. 'license': info.get('license'),
  185. }
  186. formats = []
  187. query = {'client_id': self._CLIENT_ID}
  188. if secret_token is not None:
  189. query['secret_token'] = secret_token
  190. if info.get('downloadable', False):
  191. # We can build a direct link to the song
  192. format_url = update_url_query(
  193. 'https://api.soundcloud.com/tracks/%s/download' % track_id, query)
  194. formats.append({
  195. 'format_id': 'download',
  196. 'ext': info.get('original_format', 'mp3'),
  197. 'url': format_url,
  198. 'vcodec': 'none',
  199. 'preference': 10,
  200. })
  201. # We have to retrieve the url
  202. format_dict = self._download_json(
  203. 'https://api.soundcloud.com/i1/tracks/%s/streams' % track_id,
  204. track_id, 'Downloading track url', query=query)
  205. for key, stream_url in format_dict.items():
  206. abr = int_or_none(self._search_regex(
  207. r'_(\d+)_url', key, 'audio bitrate', default=None))
  208. if key.startswith('http'):
  209. stream_formats = [{
  210. 'format_id': key,
  211. 'ext': ext,
  212. 'url': stream_url,
  213. }]
  214. elif key.startswith('rtmp'):
  215. # The url doesn't have an rtmp app, we have to extract the playpath
  216. url, path = stream_url.split('mp3:', 1)
  217. stream_formats = [{
  218. 'format_id': key,
  219. 'url': url,
  220. 'play_path': 'mp3:' + path,
  221. 'ext': 'flv',
  222. }]
  223. elif key.startswith('hls'):
  224. stream_formats = self._extract_m3u8_formats(
  225. stream_url, track_id, 'mp3', entry_protocol='m3u8_native',
  226. m3u8_id=key, fatal=False)
  227. else:
  228. continue
  229. for f in stream_formats:
  230. f['abr'] = abr
  231. formats.extend(stream_formats)
  232. if not formats:
  233. # We fallback to the stream_url in the original info, this
  234. # cannot be always used, sometimes it can give an HTTP 404 error
  235. formats.append({
  236. 'format_id': 'fallback',
  237. 'url': update_url_query(info['stream_url'], query),
  238. 'ext': ext,
  239. })
  240. for f in formats:
  241. f['vcodec'] = 'none'
  242. self._check_formats(formats, track_id)
  243. self._sort_formats(formats)
  244. result['formats'] = formats
  245. return result
  246. def _real_extract(self, url):
  247. mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
  248. if mobj is None:
  249. raise ExtractorError('Invalid URL: %s' % url)
  250. track_id = mobj.group('track_id')
  251. if track_id is not None:
  252. info_json_url = 'https://api.soundcloud.com/tracks/' + track_id + '.json?client_id=' + self._CLIENT_ID
  253. full_title = track_id
  254. token = mobj.group('secret_token')
  255. if token:
  256. info_json_url += '&secret_token=' + token
  257. elif mobj.group('player'):
  258. query = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
  259. real_url = query['url'][0]
  260. # If the token is in the query of the original url we have to
  261. # manually add it
  262. if 'secret_token' in query:
  263. real_url += '?secret_token=' + query['secret_token'][0]
  264. return self.url_result(real_url)
  265. else:
  266. # extract uploader (which is in the url)
  267. uploader = mobj.group('uploader')
  268. # extract simple title (uploader + slug of song title)
  269. slug_title = mobj.group('title')
  270. token = mobj.group('token')
  271. full_title = resolve_title = '%s/%s' % (uploader, slug_title)
  272. if token:
  273. resolve_title += '/%s' % token
  274. self.report_resolve(full_title)
  275. url = 'https://soundcloud.com/%s' % resolve_title
  276. info_json_url = self._resolv_url(url)
  277. info = self._download_json(info_json_url, full_title, 'Downloading info JSON')
  278. return self._extract_info_dict(info, full_title, secret_token=token)
  279. class SoundcloudPlaylistBaseIE(SoundcloudIE):
  280. @staticmethod
  281. def _extract_id(e):
  282. return compat_str(e['id']) if e.get('id') else None
  283. def _extract_track_entries(self, tracks):
  284. return [
  285. self.url_result(
  286. track['permalink_url'], SoundcloudIE.ie_key(),
  287. video_id=self._extract_id(track))
  288. for track in tracks if track.get('permalink_url')]
  289. class SoundcloudSetIE(SoundcloudPlaylistBaseIE):
  290. _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/(?P<uploader>[\w\d-]+)/sets/(?P<slug_title>[\w\d-]+)(?:/(?P<token>[^?/]+))?'
  291. IE_NAME = 'soundcloud:set'
  292. _TESTS = [{
  293. 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep',
  294. 'info_dict': {
  295. 'id': '2284613',
  296. 'title': 'The Royal Concept EP',
  297. },
  298. 'playlist_mincount': 5,
  299. }, {
  300. 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep/token',
  301. 'only_matching': True,
  302. }]
  303. def _real_extract(self, url):
  304. mobj = re.match(self._VALID_URL, url)
  305. # extract uploader (which is in the url)
  306. uploader = mobj.group('uploader')
  307. # extract simple title (uploader + slug of song title)
  308. slug_title = mobj.group('slug_title')
  309. full_title = '%s/sets/%s' % (uploader, slug_title)
  310. url = 'https://soundcloud.com/%s/sets/%s' % (uploader, slug_title)
  311. token = mobj.group('token')
  312. if token:
  313. full_title += '/' + token
  314. url += '/' + token
  315. self.report_resolve(full_title)
  316. resolv_url = self._resolv_url(url)
  317. info = self._download_json(resolv_url, full_title)
  318. if 'errors' in info:
  319. msgs = (compat_str(err['error_message']) for err in info['errors'])
  320. raise ExtractorError('unable to download video webpage: %s' % ','.join(msgs))
  321. entries = self._extract_track_entries(info['tracks'])
  322. return {
  323. '_type': 'playlist',
  324. 'entries': entries,
  325. 'id': '%s' % info['id'],
  326. 'title': info['title'],
  327. }
  328. class SoundcloudPagedPlaylistBaseIE(SoundcloudPlaylistBaseIE):
  329. _API_BASE = 'https://api.soundcloud.com'
  330. _API_V2_BASE = 'https://api-v2.soundcloud.com'
  331. def _extract_playlist(self, base_url, playlist_id, playlist_title):
  332. COMMON_QUERY = {
  333. 'limit': 50,
  334. 'client_id': self._CLIENT_ID,
  335. 'linked_partitioning': '1',
  336. }
  337. query = COMMON_QUERY.copy()
  338. query['offset'] = 0
  339. next_href = base_url + '?' + compat_urllib_parse_urlencode(query)
  340. entries = []
  341. for i in itertools.count():
  342. response = self._download_json(
  343. next_href, playlist_id, 'Downloading track page %s' % (i + 1))
  344. collection = response['collection']
  345. if not collection:
  346. break
  347. def resolve_permalink_url(candidates):
  348. for cand in candidates:
  349. if isinstance(cand, dict):
  350. permalink_url = cand.get('permalink_url')
  351. entry_id = self._extract_id(cand)
  352. if permalink_url and permalink_url.startswith('http'):
  353. return permalink_url, entry_id
  354. for e in collection:
  355. permalink_url, entry_id = resolve_permalink_url((e, e.get('track'), e.get('playlist')))
  356. if permalink_url:
  357. entries.append(self.url_result(permalink_url, video_id=entry_id))
  358. next_href = response.get('next_href')
  359. if not next_href:
  360. break
  361. parsed_next_href = compat_urlparse.urlparse(response['next_href'])
  362. qs = compat_urlparse.parse_qs(parsed_next_href.query)
  363. qs.update(COMMON_QUERY)
  364. next_href = compat_urlparse.urlunparse(
  365. parsed_next_href._replace(query=compat_urllib_parse_urlencode(qs, True)))
  366. return {
  367. '_type': 'playlist',
  368. 'id': playlist_id,
  369. 'title': playlist_title,
  370. 'entries': entries,
  371. }
  372. class SoundcloudUserIE(SoundcloudPagedPlaylistBaseIE):
  373. _VALID_URL = r'''(?x)
  374. https?://
  375. (?:(?:www|m)\.)?soundcloud\.com/
  376. (?P<user>[^/]+)
  377. (?:/
  378. (?P<rsrc>tracks|sets|reposts|likes|spotlight)
  379. )?
  380. /?(?:[?#].*)?$
  381. '''
  382. IE_NAME = 'soundcloud:user'
  383. _TESTS = [{
  384. 'url': 'https://soundcloud.com/the-akashic-chronicler',
  385. 'info_dict': {
  386. 'id': '114582580',
  387. 'title': 'The Akashic Chronicler (All)',
  388. },
  389. 'playlist_mincount': 74,
  390. }, {
  391. 'url': 'https://soundcloud.com/the-akashic-chronicler/tracks',
  392. 'info_dict': {
  393. 'id': '114582580',
  394. 'title': 'The Akashic Chronicler (Tracks)',
  395. },
  396. 'playlist_mincount': 37,
  397. }, {
  398. 'url': 'https://soundcloud.com/the-akashic-chronicler/sets',
  399. 'info_dict': {
  400. 'id': '114582580',
  401. 'title': 'The Akashic Chronicler (Playlists)',
  402. },
  403. 'playlist_mincount': 2,
  404. }, {
  405. 'url': 'https://soundcloud.com/the-akashic-chronicler/reposts',
  406. 'info_dict': {
  407. 'id': '114582580',
  408. 'title': 'The Akashic Chronicler (Reposts)',
  409. },
  410. 'playlist_mincount': 7,
  411. }, {
  412. 'url': 'https://soundcloud.com/the-akashic-chronicler/likes',
  413. 'info_dict': {
  414. 'id': '114582580',
  415. 'title': 'The Akashic Chronicler (Likes)',
  416. },
  417. 'playlist_mincount': 321,
  418. }, {
  419. 'url': 'https://soundcloud.com/grynpyret/spotlight',
  420. 'info_dict': {
  421. 'id': '7098329',
  422. 'title': 'Grynpyret (Spotlight)',
  423. },
  424. 'playlist_mincount': 1,
  425. }]
  426. _BASE_URL_MAP = {
  427. 'all': '%s/profile/soundcloud:users:%%s' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  428. 'tracks': '%s/users/%%s/tracks' % SoundcloudPagedPlaylistBaseIE._API_BASE,
  429. 'sets': '%s/users/%%s/playlists' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  430. 'reposts': '%s/profile/soundcloud:users:%%s/reposts' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  431. 'likes': '%s/users/%%s/likes' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  432. 'spotlight': '%s/users/%%s/spotlight' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  433. }
  434. _TITLE_MAP = {
  435. 'all': 'All',
  436. 'tracks': 'Tracks',
  437. 'sets': 'Playlists',
  438. 'reposts': 'Reposts',
  439. 'likes': 'Likes',
  440. 'spotlight': 'Spotlight',
  441. }
  442. def _real_extract(self, url):
  443. mobj = re.match(self._VALID_URL, url)
  444. uploader = mobj.group('user')
  445. url = 'https://soundcloud.com/%s/' % uploader
  446. resolv_url = self._resolv_url(url)
  447. user = self._download_json(
  448. resolv_url, uploader, 'Downloading user info')
  449. resource = mobj.group('rsrc') or 'all'
  450. return self._extract_playlist(
  451. self._BASE_URL_MAP[resource] % user['id'], compat_str(user['id']),
  452. '%s (%s)' % (user['username'], self._TITLE_MAP[resource]))
  453. class SoundcloudTrackStationIE(SoundcloudPagedPlaylistBaseIE):
  454. _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/stations/track/[^/]+/(?P<id>[^/?#&]+)'
  455. IE_NAME = 'soundcloud:trackstation'
  456. _TESTS = [{
  457. 'url': 'https://soundcloud.com/stations/track/officialsundial/your-text',
  458. 'info_dict': {
  459. 'id': '286017854',
  460. 'title': 'Track station: your-text',
  461. },
  462. 'playlist_mincount': 47,
  463. }]
  464. def _real_extract(self, url):
  465. track_name = self._match_id(url)
  466. webpage = self._download_webpage(url, track_name)
  467. track_id = self._search_regex(
  468. r'soundcloud:track-stations:(\d+)', webpage, 'track id')
  469. return self._extract_playlist(
  470. '%s/stations/soundcloud:track-stations:%s/tracks'
  471. % (self._API_V2_BASE, track_id),
  472. track_id, 'Track station: %s' % track_name)
  473. class SoundcloudPlaylistIE(SoundcloudPlaylistBaseIE):
  474. _VALID_URL = r'https?://api\.soundcloud\.com/playlists/(?P<id>[0-9]+)(?:/?\?secret_token=(?P<token>[^&]+?))?$'
  475. IE_NAME = 'soundcloud:playlist'
  476. _TESTS = [{
  477. 'url': 'https://api.soundcloud.com/playlists/4110309',
  478. 'info_dict': {
  479. 'id': '4110309',
  480. 'title': 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]',
  481. 'description': 're:.*?TILT Brass - Bowery Poetry Club',
  482. },
  483. 'playlist_count': 6,
  484. }]
  485. def _real_extract(self, url):
  486. mobj = re.match(self._VALID_URL, url)
  487. playlist_id = mobj.group('id')
  488. base_url = '%s//api.soundcloud.com/playlists/%s.json?' % (self.http_scheme(), playlist_id)
  489. data_dict = {
  490. 'client_id': self._CLIENT_ID,
  491. }
  492. token = mobj.group('token')
  493. if token:
  494. data_dict['secret_token'] = token
  495. data = compat_urllib_parse_urlencode(data_dict)
  496. data = self._download_json(
  497. base_url + data, playlist_id, 'Downloading playlist')
  498. entries = self._extract_track_entries(data['tracks'])
  499. return {
  500. '_type': 'playlist',
  501. 'id': playlist_id,
  502. 'title': data.get('title'),
  503. 'description': data.get('description'),
  504. 'entries': entries,
  505. }
  506. class SoundcloudSearchIE(SearchInfoExtractor, SoundcloudIE):
  507. IE_NAME = 'soundcloud:search'
  508. IE_DESC = 'Soundcloud search'
  509. _MAX_RESULTS = float('inf')
  510. _TESTS = [{
  511. 'url': 'scsearch15:post-avant jazzcore',
  512. 'info_dict': {
  513. 'title': 'post-avant jazzcore',
  514. },
  515. 'playlist_count': 15,
  516. }]
  517. _SEARCH_KEY = 'scsearch'
  518. _MAX_RESULTS_PER_PAGE = 200
  519. _DEFAULT_RESULTS_PER_PAGE = 50
  520. _API_V2_BASE = 'https://api-v2.soundcloud.com'
  521. def _get_collection(self, endpoint, collection_id, **query):
  522. limit = min(
  523. query.get('limit', self._DEFAULT_RESULTS_PER_PAGE),
  524. self._MAX_RESULTS_PER_PAGE)
  525. query['limit'] = limit
  526. query['client_id'] = self._CLIENT_ID
  527. query['linked_partitioning'] = '1'
  528. query['offset'] = 0
  529. data = compat_urllib_parse_urlencode(query)
  530. next_url = '{0}{1}?{2}'.format(self._API_V2_BASE, endpoint, data)
  531. collected_results = 0
  532. for i in itertools.count(1):
  533. response = self._download_json(
  534. next_url, collection_id, 'Downloading page {0}'.format(i),
  535. 'Unable to download API page')
  536. collection = response.get('collection', [])
  537. if not collection:
  538. break
  539. collection = list(filter(bool, collection))
  540. collected_results += len(collection)
  541. for item in collection:
  542. yield self.url_result(item['uri'], SoundcloudIE.ie_key())
  543. if not collection or collected_results >= limit:
  544. break
  545. next_url = response.get('next_href')
  546. if not next_url:
  547. break
  548. def _get_n_results(self, query, n):
  549. tracks = self._get_collection('/search/tracks', query, limit=n, q=query)
  550. return self.playlist_result(tracks, playlist_title=query)