mirror of
https://github.com/imputnet/cobalt.git
synced 2026-03-17 19:23:37 +00:00
youtube: introduce YOUTUBE_PLAYER_ID envvar
This commit is contained in:
parent
e1ce1dbf69
commit
2283901dc2
@ -121,6 +121,7 @@ export const loadEnvs = (env = process.env) => {
|
|||||||
ytSessionReloadInterval: 300,
|
ytSessionReloadInterval: 300,
|
||||||
ytSessionInnertubeClient: env.YOUTUBE_SESSION_INNERTUBE_CLIENT,
|
ytSessionInnertubeClient: env.YOUTUBE_SESSION_INNERTUBE_CLIENT,
|
||||||
ytAllowBetterAudio: env.YOUTUBE_ALLOW_BETTER_AUDIO !== "0",
|
ytAllowBetterAudio: env.YOUTUBE_ALLOW_BETTER_AUDIO !== "0",
|
||||||
|
ytPlayerIds: env.YOUTUBE_PLAYER_ID?.split(',')?.map(p => p.trim()),
|
||||||
|
|
||||||
// "never" | "session" | "always"
|
// "never" | "session" | "always"
|
||||||
forceLocalProcessing: env.FORCE_LOCAL_PROCESSING ?? "never",
|
forceLocalProcessing: env.FORCE_LOCAL_PROCESSING ?? "never",
|
||||||
|
|||||||
@ -77,12 +77,20 @@ const cloneInnertube = async (customFetch, useSession) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!innertube || shouldRefreshPlayer) {
|
if (!innertube || shouldRefreshPlayer) {
|
||||||
|
let player_id;
|
||||||
|
if (env.ytPlayerIds) {
|
||||||
|
player_id = env.ytPlayerIds[
|
||||||
|
Math.floor(Math.random() * env.ytPlayerIds.length)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
innertube = await Innertube.create({
|
innertube = await Innertube.create({
|
||||||
fetch: customFetch,
|
fetch: customFetch,
|
||||||
retrieve_player,
|
retrieve_player,
|
||||||
cookie,
|
cookie,
|
||||||
po_token: useSession ? sessionTokens?.potoken : undefined,
|
po_token: useSession ? sessionTokens?.potoken : undefined,
|
||||||
visitor_data: useSession ? sessionTokens?.visitor_data : undefined,
|
visitor_data: useSession ? sessionTokens?.visitor_data : undefined,
|
||||||
|
player_id,
|
||||||
});
|
});
|
||||||
lastRefreshedAt = +new Date();
|
lastRefreshedAt = +new Date();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,7 @@ this document is not final and will expand over time. feel free to improve it!
|
|||||||
| YOUTUBE_SESSION_INNERTUBE_CLIENT | `WEB_EMBEDDED` |
|
| YOUTUBE_SESSION_INNERTUBE_CLIENT | `WEB_EMBEDDED` |
|
||||||
| YOUTUBE_ALLOW_BETTER_AUDIO | `1` |
|
| YOUTUBE_ALLOW_BETTER_AUDIO | `1` |
|
||||||
| ENABLE_DEPRECATED_YOUTUBE_HLS | `key` |
|
| ENABLE_DEPRECATED_YOUTUBE_HLS | `key` |
|
||||||
|
| YOUTUBE_PLAYER_ID | `abcdefff` |
|
||||||
|
|
||||||
[*view details*](#service-specific)
|
[*view details*](#service-specific)
|
||||||
|
|
||||||
@ -271,6 +272,13 @@ innertube client that's compatible with botguard's (web) `poToken` and `visitor_
|
|||||||
|
|
||||||
the value is a string.
|
the value is a string.
|
||||||
|
|
||||||
|
### YOUTUBE_PLAYER_ID
|
||||||
|
a comma-separated-list of player IDs to use for youtube fetching.
|
||||||
|
if defined, cobalt chooses one of them at each client initialization, otherwise
|
||||||
|
defaults to the current latest player ID.
|
||||||
|
|
||||||
|
the value is a string.
|
||||||
|
|
||||||
### YOUTUBE_ALLOW_BETTER_AUDIO
|
### YOUTUBE_ALLOW_BETTER_AUDIO
|
||||||
when set to `1`, cobalt will try to use higher quality audio if user requests it via `youtubeBetterAudio`. will negatively impact the rate limit of a secondary youtube client with a session.
|
when set to `1`, cobalt will try to use higher quality audio if user requests it via `youtubeBetterAudio`. will negatively impact the rate limit of a secondary youtube client with a session.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user