UNPKG

rsshub

Version:
72 lines (69 loc) 2.76 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { a as callApi, l as utils_default, t as getDataByChannelId } from "./google-CvcgN7WE.mjs"; import { t as getDataByChannelId$1 } from "./youtubei-DqP__aN-.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 };