rsshub
Version:
Make RSS Great Again!
62 lines (60 loc) • 1.85 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import path from "node:path";
//#region lib/routes/163/music/artist-songs.ts
init_esm_shims();
const route = {
path: "/music/artist/songs/:id",
categories: ["multimedia"],
example: "/163/music/artist/songs/2116",
parameters: { id: "歌手 id, 可在歌手详情页 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "歌手歌曲",
maintainers: ["ZhongMingKun"],
handler
};
async function handler(ctx) {
const id = ctx.req.param("id");
const { data } = await got_default(`https://music.163.com/api/v1/artist/songs`, {
headers: { Referer: "https://music.163.com/" },
searchParams: {
id,
private_cloud: "true",
work_type: 1,
order: "time",
offset: 0,
limit: 100
}
});
const artist = data.songs.find(({ ar }) => ar[0].id === Number.parseInt(id)).ar[0];
const items = data.songs.map((song) => ({
title: `${song.name} - ${song.ar.map(({ name }) => name).join(" / ")}`,
description: art(path.join(__dirname, "templates/playlist-a7669f99.art"), {
singer: song.ar.map(({ name }) => name).join(" / "),
album: song.al.name,
picUrl: song.al.picUrl
}),
link: `https://music.163.com/#/song?id=${song.id}`
}));
return {
title: `${artist.name} - 歌手歌曲`,
link: `https://music.163.com/#/artist?id=${id}`,
description: `网易云音乐 - 歌手歌曲 - ${artist.name}`,
item: items
};
}
//#endregion
export { route };