Open twicer-is-coder opened 3 months ago
I ran into the same issue and was able to solve it by adding extra headers for the Youtube iframe request:
Innertube.create({
client_type: ClientType.TV_EMBEDDED,
retrieve_player: false,
generate_session_locally: true,
device_category: 'mobile',
fetch: async (input, init) => {
init ??= {};
init.headers ??= {};
const headers = init.headers as Record<string, string>;
if (input.toString().includes('iframe')) {
headers['User-Agent'] = yt?.session.context.client.userAgent ?? '';
headers['X-Goog-Visitor-Id'] = yt?.session.context.client.visitorData ?? '';
headers['X-Youtube-Client-Version'] = yt?.session.context.client.clientVersion ?? '';
headers['X-Youtube-Client-Name'] = yt?.session.context.client.clientName ?? '';
headers['Origin'] = 'https://www.youtube.com';
}
init.headers = {
...init?.headers,
...headers
};
return await fetch(input, init);
}
})
client_type: ClientType.TV_EMBEDDED, retrieve_player: false, generate_session_locally: true, device_category: 'mobile',
I tried this, with these settings it always failed with "message: Request to https://www.youtube.com/youtubei/v1/pla…prettyPrint=false&alt=json failed with status 404". Specially using this client type.
Steps to reproduce
const basicInfo = await yt.getBasicInfo(videoId);
Failure Logs
Expected behavior
Should return basic info.
Current behavior
Throwing error: Failed to request player id.
Version
Default
Anything else?
I am importing from "youtubei.js/cf-worker".
Checklist