UNPKG

rsshub

Version:
74 lines (71 loc) 2.83 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import "./not-found-Z_3JX2qs.mjs"; import "./cache-Bo__VnGm.mjs"; import "./render-BQo6B4tL.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { a as callApi, l as utils_default, t as getDataByChannelId } from "./google-Z2XIyS1r.mjs"; import { t as getDataByChannelId$1 } from "./youtubei-CgKx8K1D.mjs"; //#region lib/routes/youtube/channel.ts const route = { path: "/channel/:id/:routeParams?", categories: ["social-media"], example: "/youtube/channel/UCDwDMPOZfxVV0x_dz0eQ8KQ", parameters: { id: "YouTube channel id", routeParams: "Extra parameters, see the table below" }, radar: [{ source: ["www.youtube.com/channel/:id"], target: "/channel/:id" }], name: "Channel with id", maintainers: ["DIYgod", "pseudoyu"], handler, description: `::: tip Parameter | Name | Description | Default | | ---------- | ----------------------------------------------------------------------------------- | ------- | | embed | Whether to embed the video, fill in any value to disable embedding | embed | | filterShorts | Whether to filter out shorts from the feed, fill in any falsy value to show shorts | true | ::: ::: tip YouTube provides official RSS feeds for channels, for instance [https://www.youtube.com/feeds/videos.xml?channel\_id=UCDwDMPOZfxVV0x\_dz0eQ8KQ](https://www.youtube.com/feeds/videos.xml?channel_id=UCDwDMPOZfxVV0x_dz0eQ8KQ). :::`, features: { requireConfig: [{ name: "YOUTUBE_KEY", description: " YouTube API Key, support multiple keys, split them with `,`, [API Key application](https://console.developers.google.com/)", optional: true }], requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false } }; async function handler(ctx) { const id = ctx.req.param("id"); const routeParams = ctx.req.param("routeParams"); const params = new URLSearchParams(routeParams); const embed = !params.get("embed"); const filterShortsStr = params.get("filterShorts"); const filterShorts = filterShortsStr === null || filterShortsStr === "" || filterShortsStr === "true"; if (!utils_default.isYouTubeChannelId(id)) throw new invalid_parameter_default(`Invalid YouTube channel ID. \nYou may want to use <code>/youtube/user/:id</code> instead.`); return await callApi({ googleApi: getDataByChannelId, youtubeiApi: getDataByChannelId$1, params: { channelId: id, embed, filterShorts, isJsonFeed: ctx.req.query("format") === "json" } }); } //#endregion export { route };