UNPKG

rsshub

Version:
96 lines (94 loc) 2.91 kB
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 { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as parseJSONP } from "./jsonp-helper-C3K8BKW5.mjs"; import path from "node:path"; //#region lib/routes/yoasobi-music/info.ts init_esm_shims(); const route = { path: "/info/:category?", categories: ["live"], example: "/yoasobi-music/info/news", parameters: { category: "`news`, `biography`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.yoasobi-music.jp/", "www.yoasobi-music.jp/:category"], target: "/info/:category" }], name: "News & Biography", maintainers: [], handler, url: "www.yoasobi-music.jp/" }; async function handler(ctx) { const category = ctx.req.param("category"); const ARTIST = "YOASOBI", SONYJPURL = "https://www.sonymusic.co.jp", BASEURL = "https://www.sonymusic.co.jp/json/v2/artist", POSTFIX = category === "news" ? "start/0/count/-1" : "start/0/count/-1/callback/hotCallback"; const officialUrl = `https://www.yoasobi-music.jp/${category}`; const api = `${BASEURL}/${ARTIST}/${category === "news" ? "information" : "hottopic"}/${POSTFIX}`; const title = `LATEST ${category.toUpperCase()}`; const data = parseJSONP((await got_default({ method: "get", url: api })).data).items.map((item) => { const isBio = category === "biography"; const randomEmoji = (() => { const emojis = [ "㊗️", "🎉", "🎊", "🎈", "🎁", "🎂", "🎀", "🎗", "🎆", "🎇", "🎐", "🎑", "🎃" ]; return emojis[Math.floor(Math.random() * emojis.length)]; })(); return { id: isBio ? null : item.id, guid: isBio ? `bio:${item.url}` : `news:${item.title}${item.date}`, title: isBio ? `${randomEmoji} ${item.url}` : item.title, category: item.category ?? "Achievement", date: isBio ? item.url : item.date, description: isBio ? item.kiji : item.article, image: isBio ? item.image_url === "" ? null : `${SONYJPURL}${item.image_url}` : null }; }); return { title, link: officialUrl, description: `Yoasobi's latest ${category}`, item: data.map((i) => ({ title: i.title, description: art(path.join(__dirname, "templates/info-57fe5b1c.art"), { image: i.image, category: i.category, description: i.description.replaceAll("\n", "<br>") }), pubDate: parseDate(i.date), guid: i.guid, link: i.id ? `${officialUrl}/${i.id}` : officialUrl, category: i.category })) }; } //#endregion export { route };