UNPKG

rsshub

Version:
59 lines (57 loc) 1.77 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.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 got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/bandcamp/tag.ts const route = { path: "/tag/:tag?", categories: ["multimedia"], example: "/bandcamp/tag/united-kingdom", parameters: { tag: "Tag, can be found in URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["bandcamp.com/tag/:tag"], target: "/tag/:tag" }], name: "Tag", maintainers: ["nczitzk"], handler }; async function handler(ctx) { const currentUrl = `https://bandcamp.com/tag/${ctx.req.param("tag")}?tab=all_releases`; const response = await got_default({ method: "get", url: currentUrl }); const $ = load(response.data); const list = response.data.match(/tralbum_url":"(.*?)","audio_url/g).slice(0, 10).map((item) => ({ link: item.match(/tralbum_url":"(.*?)","audio_url/)[1].split(""")[0] })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); item.title = content(".trackTitle").eq(0).text(); item.author = content("h3 span a").text(); item.description = content("#tralbumArt").html() + content("#trackInfo").html(); return item; }))); return { title: $("title").text(), link: currentUrl, item: items }; } //#endregion export { route };