UNPKG

rsshub

Version:
59 lines (57 loc) 1.77 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.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 };