UNPKG

rsshub

Version:
99 lines (97 loc) 2.92 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.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"; import { load } from "cheerio"; //#region lib/routes/changba/user.ts init_esm_shims(); const headers = { "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1" }; const route = { path: "/:userid", categories: ["social-media"], view: ViewType.Audios, example: "/changba/skp6hhF59n48R-UpqO3izw", parameters: { userid: "用户ID, 可在对应分享页面的 URL 中找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: true, supportScihub: false }, radar: [{ source: ["changba.com/s/:userid"] }], name: "用户", maintainers: [ "kt286", "xizeyoupan", "pseudoyu" ], handler }; async function handler(ctx) { const url = `https://changba.com/wap/index.php?s=${ctx.req.param("userid")}`; const data = (await got_default({ method: "get", url, headers })).data; const $ = load(data); const list = $(".user-work .work-info").toArray(); const author = $("div.user-main-info > span.txt-info > a.uname").text(); const authorimg = $("div.user-main-info > .poster > img").attr("data-src"); let items = await Promise.all(list.map((item) => { const $$1 = load(item); const link = $$1("a").attr("href"); return cache_default.tryGet(link, async () => { const result = await got_default({ method: "get", url: link, headers }); const re = /workid: '\d+'/; let workid; try { workid = result.data.match(re)[0]; } catch { return null; } workid = workid.split("'")[1]; if (!workid) return null; const mp3 = `https://upscuw.changba.com/${workid}.mp3`; const description = art(path.join(__dirname, "templates/work_description-7637ee4a.art"), { desc: $$1("div.des").text(), mp3url: mp3 }); const itunes_item_image = $$1("div.work-cover").attr("style").replace(")", "").split("url(")[1]; return { title: $$1(".work-title").text(), description, link, author, itunes_item_image, enclosure_url: mp3, enclosure_type: "audio/mpeg" }; }); })); items = items.filter(Boolean); return { title: author + " - 唱吧", link: url, description: $("meta[name=\"description\"]").attr("content") || author + " - 唱吧", item: items, image: authorimg, itunes_author: author, itunes_category: "唱吧" }; } //#endregion export { route };