1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-01-17 05:22:18 +00:00

changes in the evaluation of sessionInfo (#54)

This commit is contained in:
lukaarma
2020-04-10 22:18:13 +02:00
committed by GitHub
parent 038832c50f
commit b5df2a83b1

View File

@@ -123,16 +123,32 @@ async function DoInteractiveLogin(url: string, username?: string): Promise<Sessi
await browser.waitForTarget(target => target.url().includes(videoId), { timeout: 150000 });
console.info('We are logged in.');
let sessionInfo: any;
let session = await page.evaluate(
() => {
return {
AccessToken: sessionInfo.AccessToken,
ApiGatewayUri: sessionInfo.ApiGatewayUri,
ApiGatewayVersion: sessionInfo.ApiGatewayVersion
};
let session = null;
let tries: number = 0;
//TODO: add proper process exit and corrisponding code
while (!session) {
try {
let sessionInfo: any;
session = await page.evaluate(
() => {
return {
AccessToken: sessionInfo.AccessToken,
ApiGatewayUri: sessionInfo.ApiGatewayUri,
ApiGatewayVersion: sessionInfo.ApiGatewayVersion
};
}
);
} catch (error) {
if (tries < 5){
session = null;
tries++;
await sleep(3000);
} else {
throw(error);
}
}
);
}
tokenCache.Write(session);
console.log('Wrote access token to token cache.');