soundcloud.py 21 KB

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