UNPKG

rsshub

Version:
64 lines (62 loc) 1.96 kB
import "./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 { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./config-not-found-Dyp3RlZZ.mjs"; import { t as utils_default } from "./utils-DrMb85iG.mjs"; //#region lib/routes/spotify/artist.ts const route = { path: "/artist/:id", categories: ["multimedia"], view: ViewType.Audios, example: "/spotify/artist/6k9TBCxyr4bXwZ8Y21Kwn1", parameters: { id: "Artist ID" }, features: { requireConfig: [{ name: "SPOTIFY_CLIENT_ID", description: "" }, { name: "SPOTIFY_CLIENT_SECRET", description: "" }], requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["open.spotify.com/artist/:id"] }], name: "Artist Albums", maintainers: ["outloudvi"], handler }; async function handler(ctx) { const token = await utils_default.getPublicToken(); const id = ctx.req.param("id"); const meta = await ofetch_default(`https://api.spotify.com/v1/artists/${id}`, { method: "GET", headers: { Authorization: `Bearer ${token}` } }); const albums = (await ofetch_default(`https://api.spotify.com/v1/artists/${id}/albums`, { method: "GET", headers: { Authorization: `Bearer ${token}` } })).items; return { title: `Albums of ${meta.name}`, link: meta.external_urls.spotify, allowEmpty: true, item: albums.map((x) => ({ title: x.name, author: x.artists.map((a) => a.name).join(", "), description: `"${x.name}" by ${x.artists.map((a) => a.name).join(", ")}, released at ${x.release_date} with ${x.total_tracks} tracks.`, pubDate: parseDate(x.release_date), link: x.external_urls.spotify })), image: meta.images.length ? meta.images[0].url : void 0 }; } //#endregion export { route };