rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 2.06 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
//#region lib/routes/soundon/podcast.ts
const handler = async (ctx) => {
const { id } = ctx.req.param();
const apiEndpoint = "https://api.soundon.fm/v2/client";
const apiToken = "KilpEMLQeNzxmNBL55u5";
const podcastInfo = await cache_default.tryGet(`soundon:${id}`, async () => {
return (await ofetch_default(`${apiEndpoint}/podcasts/${id}`, { headers: { "api-token": apiToken } })).data.data;
});
const items = (await cache_default.tryGet(`soundon:${id}:episodes`, async () => {
return (await ofetch_default(`${apiEndpoint}/podcasts/${id}/episodes`, { headers: { "api-token": apiToken } })).data;
}, config.cache.routeExpire, false)).map(({ data: item }) => ({
title: item.title,
description: item.contentEncoded,
link: item.url,
author: item.artistName,
pubDate: parseDate(item.publishDate),
itunes_item_image: item.cover,
enclosure_url: item.audioUrl,
enclosure_type: item.audioType,
itunes_duration: item.duration,
category: item.itunesKeywords
}));
return {
title: podcastInfo.title,
description: podcastInfo.description,
itunes_author: podcastInfo.artistName,
itunes_category: podcastInfo.itunesCategories.join(", "),
itunes_explicit: podcastInfo.explicit,
image: podcastInfo.cover,
language: podcastInfo.language,
link: podcastInfo.url,
item: items
};
};
const route = {
path: "/p/:id",
categories: ["multimedia"],
example: "/soundon/p/33a68cdc-18ad-4192-84cc-22bd7fdc6a31",
parameters: { id: "Podcast ID" },
features: { supportPodcast: true },
radar: [{ source: ["player.soundon.fm/p/:id"] }],
name: "Podcast",
maintainers: ["TonyRL"],
view: ViewType.Audios,
handler
};
//#endregion
export { route };