mirror of
https://github.com/snobu/destreamer.git
synced 2026-04-04 01:31:49 +00:00
changes in the evaluation of sessionInfo (#54)
This commit is contained in:
@@ -123,8 +123,14 @@ async function DoInteractiveLogin(url: string, username?: string): Promise<Sessi
|
|||||||
await browser.waitForTarget(target => target.url().includes(videoId), { timeout: 150000 });
|
await browser.waitForTarget(target => target.url().includes(videoId), { timeout: 150000 });
|
||||||
console.info('We are logged in.');
|
console.info('We are logged in.');
|
||||||
|
|
||||||
|
let session = null;
|
||||||
|
let tries: number = 0;
|
||||||
|
|
||||||
|
//TODO: add proper process exit and corrisponding code
|
||||||
|
while (!session) {
|
||||||
|
try {
|
||||||
let sessionInfo: any;
|
let sessionInfo: any;
|
||||||
let session = await page.evaluate(
|
session = await page.evaluate(
|
||||||
() => {
|
() => {
|
||||||
return {
|
return {
|
||||||
AccessToken: sessionInfo.AccessToken,
|
AccessToken: sessionInfo.AccessToken,
|
||||||
@@ -133,6 +139,16 @@ async function DoInteractiveLogin(url: string, username?: string): Promise<Sessi
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
if (tries < 5){
|
||||||
|
session = null;
|
||||||
|
tries++;
|
||||||
|
await sleep(3000);
|
||||||
|
} else {
|
||||||
|
throw(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tokenCache.Write(session);
|
tokenCache.Write(session);
|
||||||
console.log('Wrote access token to token cache.');
|
console.log('Wrote access token to token cache.');
|
||||||
|
|||||||
Reference in New Issue
Block a user