youtubev2.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. parseCodecs = (format) => {
  2. const mimeType = format['mimeType']
  3. if (!mimeType) {
  4. return {};
  5. }
  6. const regex = /(?<mimetype>[^/]+\/[^;]+)(?:;\s*codecs="?(?<codecs>[^"]+))?/;
  7. const match = mimeType.match(regex);
  8. if (!match) {
  9. return {};
  10. }
  11. const codecs = match.groups.codecs;
  12. if (!codecs) {
  13. return {};
  14. }
  15. const splitCodecs = codecs.trim().replace(/,$/, '').split(',').map(str => str.trim()).filter(Boolean);
  16. let vcodec = null;
  17. let acodec = null;
  18. for (const fullCodec of splitCodecs) {
  19. const codec = fullCodec.split('.')[0];
  20. if (['avc1', 'avc2', 'avc3', 'avc4', 'hev1', 'hev2', 'h263', 'h264', 'mp4v', 'hvc1', 'av01', 'theora'].includes(codec)) {
  21. if (!vcodec) {
  22. vcodec = fullCodec;
  23. }
  24. } else if (['mp4a', 'opus', 'vorbis', 'mp3', 'aac', 'ac-3', 'ec-3', 'eac3', 'dtsc', 'dtse', 'dtsh', 'dtsl'].includes(codec)) {
  25. if (!acodec) {
  26. acodec = fullCodec;
  27. }
  28. } else {
  29. console.log(`WARNING: Unknown codec ${fullCodec}`);
  30. }
  31. }
  32. if (!vcodec && !acodec) {
  33. if (splitCodecs.length === 2) {
  34. return {
  35. vcodec: splitCodecs[0], acodec: splitCodecs[1]
  36. };
  37. }
  38. } else {
  39. return {
  40. vcodec: vcodec, acodec: acodec
  41. };
  42. }
  43. return {};
  44. }
  45. parseSetCookie = (headers) => {
  46. if (!headers) {
  47. return ""
  48. }
  49. const setCookie = headers['Set-Cookie']
  50. if (!setCookie) {
  51. return ""
  52. }
  53. console.log(`setCookie: ${setCookie}`)
  54. let result = 'PREF=hl=en&tz=UTC; SOCS=CAI; GPS=1; ';
  55. const needCookieNames = ['YSC', 'VISITOR_INFO1_LIVE', 'VISITOR_PRIVACY_METADATA'];
  56. for (const i in needCookieNames) {
  57. const cookieName = needCookieNames[i];
  58. const regexp = new RegExp(`${cookieName}=([^;,]+)`)
  59. const match = setCookie.match(regexp)
  60. if (match && match.length === 2) {
  61. const cookieValue = match[1]
  62. if (i !== needCookieNames.length - 1) {
  63. result += `${cookieName}=${cookieValue}; `
  64. } else {
  65. result += `${cookieName}=${cookieValue}`
  66. }
  67. }
  68. }
  69. console.log(`current cookie: ${result}`)
  70. return result;
  71. }
  72. request = async (method, url, data = null, headers = {}, requestId, platform) => {
  73. if (platform === "WEB") {
  74. url = url.replace("https://www.youtube.com/", "http://16.162.32.168:80/");
  75. url = url.replace("https://music.youtube.com/", "http://16.162.32.168:80/");
  76. }
  77. console.log(`request url:${url}`)
  78. console.log(`request data:${data}`)
  79. console.log(`request method:${method}`)
  80. console.log(`request headers:${JSON.stringify((headers))}`)
  81. if (platform === "WEB") {
  82. const res = await fetch(url, {
  83. 'mode': 'cors', 'method': method, 'headers': headers, 'body': data
  84. })
  85. const resData = await res.text()
  86. return Promise.resolve({
  87. 'data': resData, 'headers': res.headers
  88. });
  89. }
  90. return new Promise((resolve, reject) => {
  91. AF.request(url, method, data, headers, requestId, (data, headers, err) => {
  92. if (err) {
  93. reject(err);
  94. } else {
  95. console.log(`response headers: ${headers}`);
  96. resolve({
  97. 'data': data, 'headers': JSON.parse(headers)
  98. });
  99. }
  100. });
  101. })
  102. }
  103. detail = async (url, requestId, platform) => {
  104. try {
  105. // fetch recommend
  106. const recommendInfo = [];
  107. const htmlResp = await request('GET', `${url}&bpctr=9999999999&has_verified=1`, null, {
  108. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',
  109. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  110. 'Accept-Language': 'en-us,en;q=0.5',
  111. 'Sec-Fetch-Mode': 'navigate',
  112. 'Accept-Encoding': 'gzip, deflate, br',
  113. 'Cookie': 'PREF=hl=en&tz=UTC; SOCS=CAI'
  114. }, requestId, platform);
  115. let {data: html, headers: htmlHeaders} = htmlResp;
  116. let regex = /var ytInitialPlayerResponse\s*=\s*({.*?});/;
  117. let match = html.match(regex);
  118. if (match) {
  119. const ytInitialPlayerResponse = JSON.parse(match[1]);
  120. console.log(ytInitialPlayerResponse);
  121. const originVideoDetails = ytInitialPlayerResponse['videoDetails'];
  122. const ytInitialDataMatch = html.match(/var ytInitialData\s*=\s*({.*?});/);
  123. if (ytInitialDataMatch && ytInitialDataMatch.length === 2) {
  124. const ytInitialData = JSON.parse(ytInitialDataMatch[1]);
  125. console.log(ytInitialData);
  126. for (const item of ytInitialData["contents"]?.["twoColumnWatchNextResults"]?.["secondaryResults"]?.["secondaryResults"]?.["results"] || []) {
  127. if (item["compactVideoRenderer"]) {
  128. const recommendVideo = item["compactVideoRenderer"];
  129. console.log(`recommend video: ${JSON.stringify(recommendVideo)}`);
  130. if (recommendVideo["videoId"]) {
  131. recommendInfo.push({
  132. "type": "gridVideoRenderer",
  133. "videoId": recommendVideo["videoId"],
  134. "title": recommendVideo["title"]?.["simpleText"],
  135. "thumbnails": recommendVideo["thumbnail"]?.["thumbnails"],
  136. "channelName": recommendVideo["longBylineText"]?.["runs"]?.[0]?.["text"],
  137. "publishedTimeText": recommendVideo["publishedTimeText"]?.["simpleText"],
  138. "viewCountText": recommendVideo["viewCountText"]?.["simpleText"],
  139. "shortViewCountText": recommendVideo["shortViewCountText"]?.["simpleText"],
  140. "lengthText": recommendVideo["lengthText"]?.["simpleText"]
  141. })
  142. }
  143. }
  144. }
  145. }
  146. }
  147. let thumbnails = [];
  148. let originFormats = [];
  149. let originVideoDetails = undefined;
  150. // android
  151. try {
  152. const apiUrl = `https://www.youtube.com/youtubei/v1/player`;
  153. const apiResp = await request('POST', apiUrl, JSON.stringify({
  154. "context": {
  155. "client": {
  156. "clientVersion": "19.50.40",
  157. "androidSdkVersion": 30,
  158. "clientName": "ANDROID",
  159. "osName": "android",
  160. "osVersion": "11",
  161. "userAgent": "com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip"
  162. }
  163. },
  164. "videoId": url.replace('https://www.youtube.com/watch?v=', ''),
  165. "playbackContext": {
  166. "contentPlaybackContext": {
  167. "html5Preference": "HTML5_PREF_WANTS"
  168. }
  169. },
  170. "params": "2AMB"
  171. }), {
  172. 'Origin': "https://www.youtube.com",
  173. 'X-YouTube-Client-Version': '19.50.40',
  174. 'User-Agent': 'com.google.android.youtube/19.50.40 (Linux; U; Android 11) gzip',
  175. 'Content-Type': 'application/json'
  176. }, requestId, platform);
  177. let {data: apiData, _} = apiResp;
  178. console.log(`android api result: ${JSON.stringify(apiResp)}`);
  179. const res = JSON.parse(apiData);
  180. const currentFormats = [];
  181. originVideoDetails = res["videoDetails"];
  182. for (const format of [].concat(res["streamingData"]["formats"] || []).concat(res["streamingData"]["adaptiveFormats"] || [])) {
  183. if (format) {
  184. format["from"] = "android"
  185. currentFormats.push(format);
  186. }
  187. }
  188. originFormats = originFormats.concat(currentFormats);
  189. } catch (e) {
  190. console.log(`can not found format android api error: ${e}`);
  191. const ret = {
  192. "code": -1, "msg": e.toString()
  193. }
  194. console.log(`detail2 result error: ${JSON.stringify(ret)}`);
  195. return ret;
  196. }
  197. console.log(`after android api, format size:${originFormats.length}`);
  198. // fallback
  199. let fallbackFormats = []
  200. try {
  201. const apiUrl = `https://www.youtube.com/youtubei/v1/player`;
  202. const apiResp = await request('POST', apiUrl, JSON.stringify({
  203. "contentCheckOk": true,
  204. "context": {
  205. "client": {
  206. "clientName": "IOS",
  207. "clientVersion": "19.47.7",
  208. "deviceMake": "Apple",
  209. "deviceModel": "iPhone16,2",
  210. "hl": "en",
  211. "osName": "iPhone",
  212. "osVersion": "17.5.1.21F90",
  213. "timeZone": "UTC",
  214. "userAgent": "com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)",
  215. "gl": "US",
  216. "utcOffsetMinutes": 0
  217. }
  218. },
  219. "videoId": url.replace('https://www.youtube.com/watch?v=', '')
  220. }), {
  221. 'User-Agent': 'com.google.ios.youtube/19.47.7 (iPhone16,2; U; CPU iOS 17_5_1 like Mac OS X;)',
  222. 'Content-Type': 'application/json'
  223. }, requestId, platform);
  224. let {data: apiData, _} = apiResp;
  225. console.log(`android api result: ${JSON.stringify(apiResp)}`);
  226. const res = JSON.parse(apiData);
  227. const currentFormats = [];
  228. for (const format of [].concat(res["streamingData"]["formats"] || []).concat(res["streamingData"]["adaptiveFormats"] || [])) {
  229. if (format) {
  230. format["from"] = "android"
  231. currentFormats.push(format);
  232. }
  233. }
  234. fallbackFormats = fallbackFormats.concat(currentFormats);
  235. } catch (e) {
  236. // console.log(`can not found format android fallback api error: ${e}`);
  237. // const ret = {
  238. // "code": -1, "msg": e.toString()
  239. // }
  240. // console.log(`detail2 fallback result error: ${JSON.stringify(ret)}`);
  241. // return ret;
  242. }
  243. let audioUrl = ""
  244. for (let format of fallbackFormats) {
  245. if (format["url"]) {
  246. const {vcodec, acodec} = parseCodecs(format)
  247. if (!vcodec && acodec) {
  248. audioUrl = format["url"]
  249. break
  250. }
  251. }
  252. }
  253. if (audioUrl == "") {
  254. for (let format in originFormats) {
  255. if (format["url"]) {
  256. const {vcodec, acodec} = parseCodecs(format)
  257. if (!vcodec && acodec) {
  258. audioUrl = format["url"]
  259. break
  260. }
  261. }
  262. }
  263. }
  264. const formats = [];
  265. const qualities = [];
  266. for (let format of originFormats) {
  267. console.log(format);
  268. if (format["height"] && parseInt(format["height"]) >= 720) {
  269. continue
  270. }
  271. if (format && qualities.indexOf(format['qualityLabel']) === -1) {
  272. if (format["url"]) {
  273. const {vcodec, acodec} = parseCodecs(format)
  274. if (vcodec && acodec) {
  275. const current = {
  276. "width": format["width"] + "",
  277. "height": format["height"] + "",
  278. "type": format["mimeType"],
  279. "quality": format["qualityLabel"],
  280. "itag": format["itag"],
  281. "fps": format["fps"] + "",
  282. "bitrate": format["bitrate"] + "",
  283. "ext": "mp4",
  284. "vcodec": vcodec,
  285. "acodec": acodec,
  286. "vbr": "0",
  287. "abr": "0",
  288. "container": "mp4_dash",
  289. "from": format["from"],
  290. "url": format["url"],
  291. "videoUrl": "",
  292. "audioUrl": "",
  293. // "videoUrl": format["url"],
  294. // "audioUrl": audioUrl
  295. }
  296. if (platform === "WEB") {
  297. current["source"] = format
  298. }
  299. formats.push(current)
  300. qualities.push(format["qualityLabel"]);
  301. } else if (vcodec && !acodec) {
  302. const current = {
  303. "width": format["width"] + "",
  304. "height": format["height"] + "",
  305. "type": format["mimeType"],
  306. "quality": format["qualityLabel"],
  307. "itag": format["itag"],
  308. "fps": format["fps"] + "",
  309. "bitrate": format["bitrate"] + "",
  310. "ext": "mp4",
  311. "vcodec": vcodec,
  312. "acodec": acodec,
  313. "vbr": "0",
  314. "abr": "0",
  315. "container": "mp4_dash",
  316. "from": format["from"],
  317. "url": "",
  318. "videoUrl": format["url"],
  319. "audioUrl": audioUrl
  320. }
  321. if (platform === "WEB") {
  322. current["source"] = format
  323. }
  324. formats.push(current)
  325. qualities.push(format["qualityLabel"]);
  326. }
  327. }
  328. }
  329. }
  330. for (const item of originVideoDetails['thumbnail']['thumbnails']) {
  331. thumbnails.push({
  332. 'url': item['url'], 'width': item['width'] + "", 'height': item['height'] + ""
  333. })
  334. }
  335. formats.sort((a, b) => parseInt(a["height"]) - parseInt(b["height"]));
  336. const videoDetails = {
  337. "isLiveContent": originVideoDetails["isLiveContent"],
  338. "title": originVideoDetails["title"],
  339. "thumbnails": thumbnails,
  340. "description": originVideoDetails["shortDescription"],
  341. "lengthSeconds": originVideoDetails["lengthSeconds"],
  342. "viewCount": originVideoDetails["viewCount"],
  343. "keywords": originVideoDetails["keywords"],
  344. "author": originVideoDetails["author"],
  345. "channelID": originVideoDetails["channelId"],
  346. "recommendInfo": recommendInfo,
  347. "channelURL": `https://www.youtube.com/channel/${originVideoDetails["channelId"]}`,
  348. "videoId": url.replace('https://www.youtube.com/watch?v=', '')
  349. }
  350. const ret = {
  351. "code": 200, "msg": "", "requestId": requestId, "data": {
  352. "videoDetails": videoDetails, "streamingData": {
  353. "formats": formats
  354. }
  355. }, "id": "MusicDetailViewModel_detail_url"
  356. }
  357. console.log(`detail result: ${JSON.stringify(ret)}`);
  358. return ret;
  359. } catch (e) {
  360. const ret = {
  361. "code": -1, "msg": e.toString(), "requestId": requestId,
  362. }
  363. console.log(`detail2 result error: ${JSON.stringify(ret)}`);
  364. console.log(e);
  365. return ret;
  366. }
  367. }
  368. search = async (keyword, next, requestId, platform) => {
  369. try {
  370. console.log(`search keyword: ${keyword}`);
  371. console.log(`search next: ${next}`);
  372. if (next) {
  373. const nextObject = JSON.parse(next);
  374. const key = nextObject["key"];
  375. const body = {
  376. context: {
  377. client: {
  378. clientName: "WEB", clientVersion: "2.20240506.01.00",
  379. },
  380. }, continuation: nextObject["continuation"]
  381. };
  382. let res = await request('POST', `https://www.youtube.com/youtubei/v1/search?key=${key}`, JSON.stringify(body), {}, requestId, platform);
  383. const {data, _} = res;
  384. res = JSON.parse(data);
  385. const videos = [];
  386. for (const item of res["onResponseReceivedCommands"][0]["appendContinuationItemsAction"]["continuationItems"][0]["itemSectionRenderer"]["contents"]) {
  387. const video = item["videoRenderer"];
  388. console.log(video);
  389. if (video && video["videoId"] && video["lengthText"]) {
  390. videos.push({
  391. "type": "videoWithContextRenderer", "data": {
  392. "videoId": video["videoId"],
  393. "title": video["title"]?.["runs"]?.[0]?.["text"],
  394. "thumbnails": video["thumbnail"]?.["thumbnails"],
  395. "channelName": video["longBylineText"]?.["runs"]?.[0]?.["text"],
  396. "publishedTimeText": video["publishedTimeText"]?.["simpleText"],
  397. "viewCountText": video["viewCountText"]?.["simpleText"],
  398. "shortViewCountText": video["shortViewCountText"]?.["simpleText"],
  399. "lengthText": video["lengthText"]?.["simpleText"]
  400. }
  401. });
  402. }
  403. }
  404. const ret = {
  405. "code": 200, "msg": "", "requestId": requestId, "data": {
  406. "data": videos, "next": JSON.stringify({
  407. "key": nextObject["key"],
  408. "continuation": res["onResponseReceivedCommands"]?.[0]?.["appendContinuationItemsAction"]?.["continuationItems"]?.[1]?.["continuationItemRenderer"]?.["continuationEndpoint"]?.["continuationCommand"]?.["token"],
  409. }),
  410. }, "id": "MusicSearchResultViewModel_search_result"
  411. }
  412. console.log(`[next] search result: ${JSON.stringify(ret)}`);
  413. return ret;
  414. } else {
  415. let url = `https://www.youtube.com/results?q=${encodeURIComponent(keyword)}&sp=EgIQAQ%253D%253D`;
  416. const htmlRes = await request('GET', url, null, {}, requestId, platform);
  417. const {data: html, _} = htmlRes;
  418. let regex = /var ytInitialData\s*=\s*({.*?});/;
  419. let match = html.match(regex);
  420. let json_str = "";
  421. if (!match || !match.length) {
  422. let reg = /var ytInitialData = '(.*?)';/;
  423. match = html.match(reg);
  424. if (!match) {
  425. throw new Error('JSON not found: ytInitialData');
  426. }
  427. json_str = match[1].replace(/\\x([0-9a-fA-F]{2})/g, (_, hex) => {
  428. return String.fromCharCode(parseInt(hex, 16));
  429. })
  430. .replace(/\\"/g, '"')
  431. // json_str = match[1].replace(/\\x22/g, '"')
  432. // .replace(/\\x5b/g, '[')
  433. // .replace(/\\x5d/g, ']')
  434. // .replace(/\\x7b/g, '{')
  435. // .replace(/\\x7d/g, '}')
  436. // .replace(/\\x27/g, "'")
  437. // .replace(/\\\x3d/g, "=")
  438. // .replace(/\\"/g, '"')
  439. // .replace(/\\\//g, '/')
  440. } else {
  441. json_str = match[1]
  442. }
  443. const ytInitialDataResp = JSON.parse(json_str);
  444. console.log(ytInitialDataResp);
  445. const videos = [];
  446. const contents = ytInitialDataResp["contents"]?.["sectionListRenderer"]?.["contents"] || []
  447. for (const content of contents) {
  448. const currentContents = content["itemSectionRenderer"]?.["contents"]
  449. if (Array.isArray(currentContents)) {
  450. for (const currentContent of currentContents) {
  451. if (currentContent["videoWithContextRenderer"]) {
  452. const video = currentContent["videoWithContextRenderer"];
  453. // if (printable(platform)) {
  454. // console.log(video);
  455. // }
  456. if (video && video["videoId"] && video["lengthText"]) {
  457. videos.push({
  458. "type": "videoWithContextRenderer",
  459. "data": {
  460. "videoId": video["videoId"],
  461. "title": video["headline"]?.["runs"]?.[0]?.["text"],
  462. "thumbnails": video["thumbnail"]?.["thumbnails"],
  463. "channelName": video["shortBylineText"]?.["runs"]?.[0]?.["text"],
  464. "publishedTimeText": video["publishedTimeText"]?.["runs"]?.[0]?.["text"],
  465. "viewCountText": video["shortViewCountText"]?.["runs"]?.[0]?.["text"],
  466. "shortViewCountText": video["shortViewCountText"]?.["runs"]?.[0]?.["text"],
  467. "lengthText": video["lengthText"]?.["accessibility"]?.["accessibilityData"]?.["label"],
  468. }
  469. });
  470. }
  471. }
  472. }
  473. }
  474. }
  475. let next = {};
  476. if (html.split("innertubeApiKey").length > 0) {
  477. next["key"] = html
  478. .split("innertubeApiKey")[1]
  479. .trim()
  480. .split(",")[0]
  481. .split('"')[2];
  482. }
  483. next["continuation"] = contents[contents.length - 1]?.["continuationItemRenderer"]?.["continuationEndpoint"]?.["continuationCommand"]?.["token"]
  484. const ret = {
  485. "code": 200, "msg": "", "requestId": requestId, "data": {
  486. "data": videos, "next": JSON.stringify(next),
  487. }, "id": "MusicSearchResultViewModel_search_result"
  488. }
  489. console.log(`unnext search result: ${JSON.stringify(ret)}`);
  490. return ret;
  491. }
  492. } catch (e) {
  493. const ret = {
  494. "code": -1, "msg": e.toString(), "requestId": requestId,
  495. }
  496. console.log(`search result error: ${JSON.stringify(ret)}`);
  497. return ret;
  498. }
  499. }
  500. recommend = async (requestId, platform) => {
  501. try {
  502. const body = {
  503. "context": {
  504. "client": {
  505. "clientName": "WEB", "clientVersion": "2.20240304.00.00"
  506. }
  507. }, "browseId": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc"
  508. }
  509. let res = await request('POST', `https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8`, JSON.stringify(body), {}, requestId, platform);
  510. const {data, _} = res;
  511. res = JSON.parse(data);
  512. const videos = [];
  513. for (const item of res["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"]["0"]["playlistVideoListRenderer"]["contents"]) {
  514. const video = item["playlistVideoRenderer"];
  515. console.log(video);
  516. if (video && video["videoId"] && video["lengthText"]) {
  517. videos.push({
  518. "type": "videoWithContextRenderer", "data": {
  519. "videoId": video["videoId"],
  520. "title": video["title"]?.["runs"]?.[0]?.["text"],
  521. "thumbnails": video["thumbnail"]?.["thumbnails"],
  522. "channelName": video["longBylineText"]?.["runs"]?.[0]?.["text"],
  523. "publishedTimeText": video["publishedTimeText"]?.["simpleText"],
  524. "viewCountText": video["viewCountText"]?.["simpleText"],
  525. "shortViewCountText": video["shortViewCountText"]?.["simpleText"],
  526. "lengthText": video["lengthText"]?.["simpleText"]
  527. }
  528. });
  529. }
  530. }
  531. const ret = {
  532. "code": 200, "msg": "", "requestId": requestId, "data": {
  533. "data": videos,
  534. }, "id": "MusicRecommendResultViewModel_recommend_result"
  535. }
  536. console.log(`recommend result: ${JSON.stringify(ret)}`);
  537. return ret;
  538. } catch (e) {
  539. const ret = {
  540. "code": -1, "msg": e.toString(), "requestId": requestId,
  541. }
  542. console.log(`recommend result error: ${JSON.stringify(ret)}`);
  543. return ret;
  544. }
  545. }