soundcloud.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. 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 = 'JlZIsxg2hY5WnBgtn3jfS0UYCl0K8DOg'
  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. query = {'client_id': self._CLIENT_ID}
  154. if secret_token is not None:
  155. query['secret_token'] = secret_token
  156. if info.get('downloadable', False):
  157. # We can build a direct link to the song
  158. format_url = update_url_query(
  159. 'https://api.soundcloud.com/tracks/{0}/download'.format(track_id), query)
  160. formats.append({
  161. 'format_id': 'download',
  162. 'ext': info.get('original_format', 'mp3'),
  163. 'url': format_url,
  164. 'vcodec': 'none',
  165. 'preference': 10,
  166. })
  167. # We have to retrieve the url
  168. format_dict = self._download_json(
  169. 'https://api.soundcloud.com/i1/tracks/%s/streams' % track_id,
  170. track_id, 'Downloading track url', query=query)
  171. for key, stream_url in format_dict.items():
  172. abr = int_or_none(self._search_regex(
  173. r'_(\d+)_url', key, 'audio bitrate', default=None))
  174. if key.startswith('http'):
  175. stream_formats = [{
  176. 'format_id': key,
  177. 'ext': ext,
  178. 'url': stream_url,
  179. }]
  180. elif key.startswith('rtmp'):
  181. # The url doesn't have an rtmp app, we have to extract the playpath
  182. url, path = stream_url.split('mp3:', 1)
  183. stream_formats = [{
  184. 'format_id': key,
  185. 'url': url,
  186. 'play_path': 'mp3:' + path,
  187. 'ext': 'flv',
  188. }]
  189. elif key.startswith('hls'):
  190. stream_formats = self._extract_m3u8_formats(
  191. stream_url, track_id, 'mp3', entry_protocol='m3u8_native',
  192. m3u8_id=key, fatal=False)
  193. else:
  194. continue
  195. for f in stream_formats:
  196. f['abr'] = abr
  197. formats.extend(stream_formats)
  198. if not formats:
  199. # We fallback to the stream_url in the original info, this
  200. # cannot be always used, sometimes it can give an HTTP 404 error
  201. formats.append({
  202. 'format_id': 'fallback',
  203. 'url': update_url_query(info['stream_url'], query),
  204. 'ext': ext,
  205. })
  206. for f in formats:
  207. f['vcodec'] = 'none'
  208. self._check_formats(formats, track_id)
  209. self._sort_formats(formats)
  210. result['formats'] = formats
  211. return result
  212. def _real_extract(self, url):
  213. mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
  214. if mobj is None:
  215. raise ExtractorError('Invalid URL: %s' % url)
  216. track_id = mobj.group('track_id')
  217. if track_id is not None:
  218. info_json_url = 'https://api.soundcloud.com/tracks/' + track_id + '.json?client_id=' + self._CLIENT_ID
  219. full_title = track_id
  220. token = mobj.group('secret_token')
  221. if token:
  222. info_json_url += '&secret_token=' + token
  223. elif mobj.group('player'):
  224. query = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
  225. real_url = query['url'][0]
  226. # If the token is in the query of the original url we have to
  227. # manually add it
  228. if 'secret_token' in query:
  229. real_url += '?secret_token=' + query['secret_token'][0]
  230. return self.url_result(real_url)
  231. else:
  232. # extract uploader (which is in the url)
  233. uploader = mobj.group('uploader')
  234. # extract simple title (uploader + slug of song title)
  235. slug_title = mobj.group('title')
  236. token = mobj.group('token')
  237. full_title = resolve_title = '%s/%s' % (uploader, slug_title)
  238. if token:
  239. resolve_title += '/%s' % token
  240. self.report_resolve(full_title)
  241. url = 'https://soundcloud.com/%s' % resolve_title
  242. info_json_url = self._resolv_url(url)
  243. info = self._download_json(info_json_url, full_title, 'Downloading info JSON')
  244. return self._extract_info_dict(info, full_title, secret_token=token)
  245. class SoundcloudPlaylistBaseIE(SoundcloudIE):
  246. @staticmethod
  247. def _extract_id(e):
  248. return compat_str(e['id']) if e.get('id') else None
  249. def _extract_track_entries(self, tracks):
  250. return [
  251. self.url_result(
  252. track['permalink_url'], SoundcloudIE.ie_key(),
  253. video_id=self._extract_id(track))
  254. for track in tracks if track.get('permalink_url')]
  255. class SoundcloudSetIE(SoundcloudPlaylistBaseIE):
  256. _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/(?P<uploader>[\w\d-]+)/sets/(?P<slug_title>[\w\d-]+)(?:/(?P<token>[^?/]+))?'
  257. IE_NAME = 'soundcloud:set'
  258. _TESTS = [{
  259. 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep',
  260. 'info_dict': {
  261. 'id': '2284613',
  262. 'title': 'The Royal Concept EP',
  263. },
  264. 'playlist_mincount': 5,
  265. }, {
  266. 'url': 'https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep/token',
  267. 'only_matching': True,
  268. }]
  269. def _real_extract(self, url):
  270. mobj = re.match(self._VALID_URL, url)
  271. # extract uploader (which is in the url)
  272. uploader = mobj.group('uploader')
  273. # extract simple title (uploader + slug of song title)
  274. slug_title = mobj.group('slug_title')
  275. full_title = '%s/sets/%s' % (uploader, slug_title)
  276. url = 'https://soundcloud.com/%s/sets/%s' % (uploader, slug_title)
  277. token = mobj.group('token')
  278. if token:
  279. full_title += '/' + token
  280. url += '/' + token
  281. self.report_resolve(full_title)
  282. resolv_url = self._resolv_url(url)
  283. info = self._download_json(resolv_url, full_title)
  284. if 'errors' in info:
  285. msgs = (compat_str(err['error_message']) for err in info['errors'])
  286. raise ExtractorError('unable to download video webpage: %s' % ','.join(msgs))
  287. entries = self._extract_track_entries(info['tracks'])
  288. return {
  289. '_type': 'playlist',
  290. 'entries': entries,
  291. 'id': '%s' % info['id'],
  292. 'title': info['title'],
  293. }
  294. class SoundcloudPagedPlaylistBaseIE(SoundcloudPlaylistBaseIE):
  295. _API_BASE = 'https://api.soundcloud.com'
  296. _API_V2_BASE = 'https://api-v2.soundcloud.com'
  297. def _extract_playlist(self, base_url, playlist_id, playlist_title):
  298. COMMON_QUERY = {
  299. 'limit': 50,
  300. 'client_id': self._CLIENT_ID,
  301. 'linked_partitioning': '1',
  302. }
  303. query = COMMON_QUERY.copy()
  304. query['offset'] = 0
  305. next_href = base_url + '?' + compat_urllib_parse_urlencode(query)
  306. entries = []
  307. for i in itertools.count():
  308. response = self._download_json(
  309. next_href, playlist_id, 'Downloading track page %s' % (i + 1))
  310. collection = response['collection']
  311. if not collection:
  312. break
  313. def resolve_permalink_url(candidates):
  314. for cand in candidates:
  315. if isinstance(cand, dict):
  316. permalink_url = cand.get('permalink_url')
  317. entry_id = self._extract_id(cand)
  318. if permalink_url and permalink_url.startswith('http'):
  319. return permalink_url, entry_id
  320. for e in collection:
  321. permalink_url, entry_id = resolve_permalink_url((e, e.get('track'), e.get('playlist')))
  322. if permalink_url:
  323. entries.append(self.url_result(permalink_url, video_id=entry_id))
  324. next_href = response.get('next_href')
  325. if not next_href:
  326. break
  327. parsed_next_href = compat_urlparse.urlparse(response['next_href'])
  328. qs = compat_urlparse.parse_qs(parsed_next_href.query)
  329. qs.update(COMMON_QUERY)
  330. next_href = compat_urlparse.urlunparse(
  331. parsed_next_href._replace(query=compat_urllib_parse_urlencode(qs, True)))
  332. return {
  333. '_type': 'playlist',
  334. 'id': playlist_id,
  335. 'title': playlist_title,
  336. 'entries': entries,
  337. }
  338. class SoundcloudUserIE(SoundcloudPagedPlaylistBaseIE):
  339. _VALID_URL = r'''(?x)
  340. https?://
  341. (?:(?:www|m)\.)?soundcloud\.com/
  342. (?P<user>[^/]+)
  343. (?:/
  344. (?P<rsrc>tracks|sets|reposts|likes|spotlight)
  345. )?
  346. /?(?:[?#].*)?$
  347. '''
  348. IE_NAME = 'soundcloud:user'
  349. _TESTS = [{
  350. 'url': 'https://soundcloud.com/the-akashic-chronicler',
  351. 'info_dict': {
  352. 'id': '114582580',
  353. 'title': 'The Akashic Chronicler (All)',
  354. },
  355. 'playlist_mincount': 74,
  356. }, {
  357. 'url': 'https://soundcloud.com/the-akashic-chronicler/tracks',
  358. 'info_dict': {
  359. 'id': '114582580',
  360. 'title': 'The Akashic Chronicler (Tracks)',
  361. },
  362. 'playlist_mincount': 37,
  363. }, {
  364. 'url': 'https://soundcloud.com/the-akashic-chronicler/sets',
  365. 'info_dict': {
  366. 'id': '114582580',
  367. 'title': 'The Akashic Chronicler (Playlists)',
  368. },
  369. 'playlist_mincount': 2,
  370. }, {
  371. 'url': 'https://soundcloud.com/the-akashic-chronicler/reposts',
  372. 'info_dict': {
  373. 'id': '114582580',
  374. 'title': 'The Akashic Chronicler (Reposts)',
  375. },
  376. 'playlist_mincount': 7,
  377. }, {
  378. 'url': 'https://soundcloud.com/the-akashic-chronicler/likes',
  379. 'info_dict': {
  380. 'id': '114582580',
  381. 'title': 'The Akashic Chronicler (Likes)',
  382. },
  383. 'playlist_mincount': 321,
  384. }, {
  385. 'url': 'https://soundcloud.com/grynpyret/spotlight',
  386. 'info_dict': {
  387. 'id': '7098329',
  388. 'title': 'Grynpyret (Spotlight)',
  389. },
  390. 'playlist_mincount': 1,
  391. }]
  392. _BASE_URL_MAP = {
  393. 'all': '%s/profile/soundcloud:users:%%s' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  394. 'tracks': '%s/users/%%s/tracks' % SoundcloudPagedPlaylistBaseIE._API_BASE,
  395. 'sets': '%s/users/%%s/playlists' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  396. 'reposts': '%s/profile/soundcloud:users:%%s/reposts' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  397. 'likes': '%s/users/%%s/likes' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  398. 'spotlight': '%s/users/%%s/spotlight' % SoundcloudPagedPlaylistBaseIE._API_V2_BASE,
  399. }
  400. _TITLE_MAP = {
  401. 'all': 'All',
  402. 'tracks': 'Tracks',
  403. 'sets': 'Playlists',
  404. 'reposts': 'Reposts',
  405. 'likes': 'Likes',
  406. 'spotlight': 'Spotlight',
  407. }
  408. def _real_extract(self, url):
  409. mobj = re.match(self._VALID_URL, url)
  410. uploader = mobj.group('user')
  411. url = 'https://soundcloud.com/%s/' % uploader
  412. resolv_url = self._resolv_url(url)
  413. user = self._download_json(
  414. resolv_url, uploader, 'Downloading user info')
  415. resource = mobj.group('rsrc') or 'all'
  416. return self._extract_playlist(
  417. self._BASE_URL_MAP[resource] % user['id'], compat_str(user['id']),
  418. '%s (%s)' % (user['username'], self._TITLE_MAP[resource]))
  419. class SoundcloudTrackStationIE(SoundcloudPagedPlaylistBaseIE):
  420. _VALID_URL = r'https?://(?:(?:www|m)\.)?soundcloud\.com/stations/track/[^/]+/(?P<id>[^/?#&]+)'
  421. IE_NAME = 'soundcloud:trackstation'
  422. _TESTS = [{
  423. 'url': 'https://soundcloud.com/stations/track/officialsundial/your-text',
  424. 'info_dict': {
  425. 'id': '286017854',
  426. 'title': 'Track station: your-text',
  427. },
  428. 'playlist_mincount': 47,
  429. }]
  430. def _real_extract(self, url):
  431. track_name = self._match_id(url)
  432. webpage = self._download_webpage(url, track_name)
  433. track_id = self._search_regex(
  434. r'soundcloud:track-stations:(\d+)', webpage, 'track id')
  435. return self._extract_playlist(
  436. '%s/stations/soundcloud:track-stations:%s/tracks'
  437. % (self._API_V2_BASE, track_id),
  438. track_id, 'Track station: %s' % track_name)
  439. class SoundcloudPlaylistIE(SoundcloudPlaylistBaseIE):
  440. _VALID_URL = r'https?://api\.soundcloud\.com/playlists/(?P<id>[0-9]+)(?:/?\?secret_token=(?P<token>[^&]+?))?$'
  441. IE_NAME = 'soundcloud:playlist'
  442. _TESTS = [{
  443. 'url': 'https://api.soundcloud.com/playlists/4110309',
  444. 'info_dict': {
  445. 'id': '4110309',
  446. 'title': 'TILT Brass - Bowery Poetry Club, August \'03 [Non-Site SCR 02]',
  447. 'description': 're:.*?TILT Brass - Bowery Poetry Club',
  448. },
  449. 'playlist_count': 6,
  450. }]
  451. def _real_extract(self, url):
  452. mobj = re.match(self._VALID_URL, url)
  453. playlist_id = mobj.group('id')
  454. base_url = '%s//api.soundcloud.com/playlists/%s.json?' % (self.http_scheme(), playlist_id)
  455. data_dict = {
  456. 'client_id': self._CLIENT_ID,
  457. }
  458. token = mobj.group('token')
  459. if token:
  460. data_dict['secret_token'] = token
  461. data = compat_urllib_parse_urlencode(data_dict)
  462. data = self._download_json(
  463. base_url + data, playlist_id, 'Downloading playlist')
  464. entries = self._extract_track_entries(data['tracks'])
  465. return {
  466. '_type': 'playlist',
  467. 'id': playlist_id,
  468. 'title': data.get('title'),
  469. 'description': data.get('description'),
  470. 'entries': entries,
  471. }
  472. class SoundcloudSearchIE(SearchInfoExtractor, SoundcloudIE):
  473. IE_NAME = 'soundcloud:search'
  474. IE_DESC = 'Soundcloud search'
  475. _MAX_RESULTS = float('inf')
  476. _TESTS = [{
  477. 'url': 'scsearch15:post-avant jazzcore',
  478. 'info_dict': {
  479. 'title': 'post-avant jazzcore',
  480. },
  481. 'playlist_count': 15,
  482. }]
  483. _SEARCH_KEY = 'scsearch'
  484. _MAX_RESULTS_PER_PAGE = 200
  485. _DEFAULT_RESULTS_PER_PAGE = 50
  486. _API_V2_BASE = 'https://api-v2.soundcloud.com'
  487. def _get_collection(self, endpoint, collection_id, **query):
  488. limit = min(
  489. query.get('limit', self._DEFAULT_RESULTS_PER_PAGE),
  490. self._MAX_RESULTS_PER_PAGE)
  491. query['limit'] = limit
  492. query['client_id'] = self._CLIENT_ID
  493. query['linked_partitioning'] = '1'
  494. query['offset'] = 0
  495. data = compat_urllib_parse_urlencode(query)
  496. next_url = '{0}{1}?{2}'.format(self._API_V2_BASE, endpoint, data)
  497. collected_results = 0
  498. for i in itertools.count(1):
  499. response = self._download_json(
  500. next_url, collection_id, 'Downloading page {0}'.format(i),
  501. 'Unable to download API page')
  502. collection = response.get('collection', [])
  503. if not collection:
  504. break
  505. collection = list(filter(bool, collection))
  506. collected_results += len(collection)
  507. for item in collection:
  508. yield self.url_result(item['uri'], SoundcloudIE.ie_key())
  509. if not collection or collected_results >= limit:
  510. break
  511. next_url = response.get('next_href')
  512. if not next_url:
  513. break
  514. def _get_n_results(self, query, n):
  515. tracks = self._get_collection('/search/tracks', query, limit=n, q=query)
  516. return self.playlist_result(tracks, playlist_title=query)