feat(youtube): customize fetch method for Innertube instance

This commit is contained in:
DIYgod 2025-10-28 21:42:22 +08:00
parent 49a58764fa
commit 6197f745b4
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,16 @@ import { Innertube } from 'youtubei.js';
import utils, { getVideoUrl } from '../utils';
import { getSrtAttachmentBatch } from './subtitles';
const innertubePromise = Innertube.create();
const innertubePromise = Innertube.create({
fetch: (input, init) => {
const url = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url;
return fetch(url, {
method: input?.method,
...init,
});
},
});
export const getChannelIdByUsername = (username: string) =>
cache.tryGet(`youtube:getChannelIdByUsername:${username}`, async () => {