youtube: fix custom fetch breakage
https://github.com/LuanRT/YouTube.js/issues/962#issuecomment-2864091135
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import HLS from "hls-parser";
|
import HLS from "hls-parser";
|
||||||
|
|
||||||
import { fetch } from "undici";
|
import { fetch, Request } from "undici";
|
||||||
import { Innertube, Session } from "youtubei.js";
|
import { Innertube, Platform, Session } from "youtubei.js";
|
||||||
|
|
||||||
import { env } from "../../config.js";
|
import { env } from "../../config.js";
|
||||||
import { getCookie } from "../cookie/manager.js";
|
import { getCookie } from "../cookie/manager.js";
|
||||||
@@ -206,10 +206,24 @@ export default async function (o) {
|
|||||||
let yt;
|
let yt;
|
||||||
try {
|
try {
|
||||||
yt = await cloneInnertube(
|
yt = await cloneInnertube(
|
||||||
(input, init) => fetch(input, {
|
(input, init) => {
|
||||||
...init,
|
const url = typeof input === 'string'
|
||||||
dispatcher: o.dispatcher
|
? new URL(input)
|
||||||
}),
|
: input instanceof URL
|
||||||
|
? input
|
||||||
|
: new URL(input.url);
|
||||||
|
|
||||||
|
const request = new Request(
|
||||||
|
url,
|
||||||
|
input instanceof Platform.shim.Request
|
||||||
|
? input : undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
return fetch(request, {
|
||||||
|
...init,
|
||||||
|
dispatcher: o.dispatcher
|
||||||
|
});
|
||||||
|
},
|
||||||
useSession
|
useSession
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user