mirror of
https://github.com/imputnet/cobalt.git
synced 2026-05-13 08:27:03 +00:00
youtube: introduce YOUTUBE_PLAYER_ID envvar
This commit is contained in:
parent
e1ce1dbf69
commit
2283901dc2
3 changed files with 17 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue