mirror of
https://github.com/imputnet/cobalt.git
synced 2026-03-11 16:43:56 +00:00
youtube: introduce YOUTUBE_PLAYER_ID envvar
This commit is contained in:
@@ -121,6 +121,7 @@ export const loadEnvs = (env = process.env) => {
|
||||
ytSessionReloadInterval: 300,
|
||||
ytSessionInnertubeClient: env.YOUTUBE_SESSION_INNERTUBE_CLIENT,
|
||||
ytAllowBetterAudio: env.YOUTUBE_ALLOW_BETTER_AUDIO !== "0",
|
||||
ytPlayerIds: env.YOUTUBE_PLAYER_ID?.split(',')?.map(p => p.trim()),
|
||||
|
||||
// "never" | "session" | "always"
|
||||
forceLocalProcessing: env.FORCE_LOCAL_PROCESSING ?? "never",
|
||||
|
||||
@@ -77,12 +77,20 @@ const cloneInnertube = async (customFetch, useSession) => {
|
||||
}
|
||||
|
||||
if (!innertube || shouldRefreshPlayer) {
|
||||
let player_id;
|
||||
if (env.ytPlayerIds) {
|
||||
player_id = env.ytPlayerIds[
|
||||
Math.floor(Math.random() * env.ytPlayerIds.length)
|
||||
];
|
||||
}
|
||||
|
||||
innertube = await Innertube.create({
|
||||
fetch: customFetch,
|
||||
retrieve_player,
|
||||
cookie,
|
||||
po_token: useSession ? sessionTokens?.potoken : undefined,
|
||||
visitor_data: useSession ? sessionTokens?.visitor_data : undefined,
|
||||
player_id,
|
||||
});
|
||||
lastRefreshedAt = +new Date();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user