rsshub
Version:
Make RSS Great Again!
74 lines (72 loc) • 2.1 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/userplaylist.ts
init_esm_shims();
const route = {
path: "/music/user/playlist/:uid",
categories: ["multimedia"],
example: "/163/music/user/playlist/45441555",
parameters: { uid: "用户 uid, 可在用户主页 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "用户歌单",
maintainers: ["DIYgod"],
handler
};
async function handler(ctx) {
const uid = ctx.req.param("uid");
const response = await got_default.post("https://music.163.com/api/user/playlist", {
headers: { Referer: "https://music.163.com/" },
form: {
uid,
limit: 1e3,
offset: 0
}
});
const playlist = response.data.playlist || [];
const { nickname, signature, avatarUrl } = (playlist[0] || {}).creator;
return {
title: `${nickname} 的所有歌单`,
link: `https://music.163.com/user/home?id=${uid}`,
subtitle: signature,
description: signature,
author: nickname,
updated: response.headers.date,
icon: avatarUrl,
image: avatarUrl,
item: playlist.map((pl) => {
const src = `http://music.163.com/playlist/${pl.id}`;
const html = art(path.join(__dirname, "templates/userplaylist-bfb26b20.art"), {
image: pl.coverImgUrl,
description: (pl.description || "").split("\n"),
src
});
return {
title: pl.name,
link: src,
pubDate: new Date(pl.createTime).toUTCString(),
published: new Date(pl.createTime).toISOString(),
updated: new Date(pl.updateTime).toISOString(),
author: pl.creator.nickname,
description: html,
content: { html },
category: pl.tags
};
})
};
}
//#endregion
export { route };