rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 1.85 kB
JavaScript
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/playlist.ts
const route = {
path: "/playlist/:id",
categories: ["multimedia"],
view: ViewType.Audios,
example: "/spotify/playlist/4UBVy1LttvodwivPUuwJk2",
parameters: { id: "Playlist ID" },
features: {
requireConfig: [{
name: "SPOTIFY_CLIENT_ID",
description: ""
}, {
name: "SPOTIFY_CLIENT_SECRET",
description: ""
}],
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
description: `::: warning
Due to [limitations by Spotify](https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api), this endpoint is unable to access "Algorithmic and Spotify-owned editorial playlists".
:::`,
radar: [{ source: ["open.spotify.com/playlist/:id"] }],
name: "Playlist",
maintainers: ["outloudvi"],
handler
};
async function handler(ctx) {
const token = await utils_default.getPublicToken();
const meta = await ofetch_default(`https://api.spotify.com/v1/playlists/${ctx.req.param("id")}`, {
method: "GET",
headers: { Authorization: `Bearer ${token}` }
});
const tracks = meta.tracks.items;
return {
title: meta.name,
link: meta.external_urls.spotify,
description: meta.description,
allowEmpty: true,
item: tracks.map((x) => ({
...utils_default.parseTrack(x.track),
pubDate: parseDate(x.added_at)
})),
image: meta.images.length ? meta.images[0].url : void 0
};
}
//#endregion
export { route };