mirror of
https://github.com/imputnet/cobalt.git
synced 2026-05-13 08:27:03 +00:00
api/youtube: try new session server
This commit is contained in:
parent
6678238a6c
commit
d8ca5855a9
1 changed files with 6 additions and 2 deletions
|
|
@ -9,6 +9,10 @@ const defaultAgent = new Agent();
|
|||
let session;
|
||||
|
||||
const validateSession = (sessionResponse) => {
|
||||
sessionResponse.visitor_data ??= sessionResponse.contentBinding;
|
||||
sessionResponse.potoken ??= sessionResponse.poToken;
|
||||
sessionResponse.updated ??= new Date().getTime();
|
||||
|
||||
if (!sessionResponse.potoken) {
|
||||
throw "no poToken in session response";
|
||||
}
|
||||
|
|
@ -33,11 +37,11 @@ const updateSession = (newSession) => {
|
|||
|
||||
const loadSession = async () => {
|
||||
const sessionServerUrl = new URL(env.ytSessionServer);
|
||||
sessionServerUrl.pathname = "/token";
|
||||
sessionServerUrl.pathname = "/get_pot";
|
||||
|
||||
const newSession = await fetch(
|
||||
sessionServerUrl,
|
||||
{ dispatcher: defaultAgent }
|
||||
{ method: 'POST', dispatcher: defaultAgent }
|
||||
).then(a => a.json());
|
||||
|
||||
validateSession(newSession);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue