index.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import axios from "axios";
  2. const headers = {
  3. "user-agent":
  4. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
  5. host: "studio-api.suno.ai"
  6. }
  7. async function getTopLists() {
  8. return [
  9. {
  10. title: "趋势榜",
  11. data: [
  12. {
  13. id: "1190bf92-10dc-4ce5-968a-7a377f37f984",
  14. title: "趋势榜 - 最近一天",
  15. },
  16. {
  17. id: "08a079b2-a63b-4f9c-9f29-de3c1864ddef",
  18. title: "趋势榜 - 最近一周",
  19. },
  20. {
  21. id: "845539aa-2a39-4cf5-b4ae-16d3fe159a77",
  22. title: "趋势榜 - 最近一月",
  23. },
  24. {
  25. id: "6943c7ee-cbc5-4f72-bc4e-f3371a8be9d5",
  26. title: "趋势榜 - 全部时间",
  27. },
  28. ],
  29. },
  30. {
  31. title: "最新榜",
  32. data: [
  33. {
  34. id: "cc14084a-2622-4c4b-8258-1f6b4b4f54b3",
  35. title: "最新榜",
  36. },
  37. ],
  38. },
  39. {
  40. title: "其他类别",
  41. data: [
  42. {
  43. id: "1ac7823f-8faf-474f-b14c-e4f7c7bb373f",
  44. title: "动物开会",
  45. },
  46. {
  47. id: '6713d315-3541-460d-8788-162cce241336',
  48. title: 'Lo-Fi'
  49. }
  50. ],
  51. },
  52. ];
  53. }
  54. async function getTopListDetail(topListItem) {
  55. const result = (await axios.get(`https://studio-api.suno.ai/api/playlist/${topListItem.id}/?page=0`, {
  56. headers
  57. })).data;
  58. return {
  59. isEnd: true,
  60. musicList: result.playlist_clips.map(it => {
  61. const clip = it.clip;
  62. return {
  63. id: clip.id,
  64. url: clip.audio_url,
  65. artwork: clip.image_large_url || clip.image_url,
  66. duration: clip.metadata?.duration,
  67. title: clip.title,
  68. artist: clip.display_name,
  69. userId: clip.user_id,
  70. rawLrc: clip.metadata?.prompt
  71. }
  72. })
  73. }
  74. }
  75. async function getLyric(musicItem) {
  76. return {
  77. rawLrc: musicItem.rawLrc
  78. }
  79. }
  80. module.exports = {
  81. platform: "suno",
  82. version: "0.0.0",
  83. srcUrl:
  84. "https://gitee.com/maotoumao/MusicFreePlugins/raw/v0.1/dist/suno/index.js",
  85. cacheControl: "no-cache",
  86. getTopLists,
  87. getTopListDetail,
  88. getLyric
  89. };
  90. getTopListDetail( {
  91. id: "1ac7823f-8faf-474f-b14c-e4f7c7bb373f",
  92. title: "最新榜",
  93. }).then(e => console.log(e.musicList[0]))