From dac672d3bba21ffd464dd65a745a87cbbbecae74 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 11 Nov 2025 15:27:47 +0800 Subject: [PATCH] fix(route/youtube): ensure youtubei is not invoked when using google api (#20465) --- lib/routes/youtube/channel.ts | 4 +++- lib/routes/youtube/live.ts | 2 +- lib/routes/youtube/playlist.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/routes/youtube/channel.ts b/lib/routes/youtube/channel.ts index 49906de43..aebc951da 100644 --- a/lib/routes/youtube/channel.ts +++ b/lib/routes/youtube/channel.ts @@ -65,10 +65,12 @@ async function handler(ctx) { throw new InvalidParameterError(`Invalid YouTube channel ID. \nYou may want to use /youtube/user/:id instead.`); } + const isJsonFeed = ctx.req.query('format') === 'json'; + const data = await callApi({ googleApi: getDataByChannelIdGoogle, youtubeiApi: getDataByChannelIdYoutubei, - params: { channelId: id, embed, filterShorts }, + params: { channelId: id, embed, filterShorts, isJsonFeed }, }); return data; diff --git a/lib/routes/youtube/live.ts b/lib/routes/youtube/live.ts index 59365f84a..639a7bb85 100644 --- a/lib/routes/youtube/live.ts +++ b/lib/routes/youtube/live.ts @@ -16,7 +16,7 @@ export const route: Route = { requireConfig: [ { name: 'YOUTUBE_KEY', - description: ' YouTube API Key, support multiple keys, split them with `,`, [API Key application](https://console.developers.google.com/)', + description: 'YouTube API Key, support multiple keys, split them with `,`, [API Key application](https://console.developers.google.com/)', }, ], requirePuppeteer: false, diff --git a/lib/routes/youtube/playlist.ts b/lib/routes/youtube/playlist.ts index bdbdaa52f..057351ddc 100644 --- a/lib/routes/youtube/playlist.ts +++ b/lib/routes/youtube/playlist.ts @@ -31,11 +31,12 @@ export const route: Route = { async function handler(ctx) { const id = ctx.req.param('id'); const embed = !ctx.req.param('embed'); + const isJsonFeed = ctx.req.query('format') === 'json'; const data = await callApi({ googleApi: getDataByPlaylistIdGoogle, youtubeiApi: getDataByPlaylistIdYoutubei, - params: { playlistId: id, embed }, + params: { playlistId: id, embed, isJsonFeed }, }); return data;