changes in the evaluation of sessionInfo (#54)
This commit is contained in:
parent
038832c50f
commit
b5df2a83b1
1 changed files with 26 additions and 10 deletions
|
@ -123,16 +123,32 @@ 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 sessionInfo: any;
|
let session = null;
|
||||||
let session = await page.evaluate(
|
let tries: number = 0;
|
||||||
() => {
|
|
||||||
return {
|
//TODO: add proper process exit and corrisponding code
|
||||||
AccessToken: sessionInfo.AccessToken,
|
while (!session) {
|
||||||
ApiGatewayUri: sessionInfo.ApiGatewayUri,
|
try {
|
||||||
ApiGatewayVersion: sessionInfo.ApiGatewayVersion
|
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);
|
tokenCache.Write(session);
|
||||||
console.log('Wrote access token to token cache.');
|
console.log('Wrote access token to token cache.');
|
||||||
|
@ -199,7 +215,7 @@ async function downloadVideo(videoUrls: string[], outputDirectory: string, sessi
|
||||||
console.info('Spawning ffmpeg with access token and HLS URL. This may take a few seconds...\n');
|
console.info('Spawning ffmpeg with access token and HLS URL. This may take a few seconds...\n');
|
||||||
|
|
||||||
const outputPath = outputDirectory + path.sep + video.title + '.mp4';
|
const outputPath = outputDirectory + path.sep + video.title + '.mp4';
|
||||||
|
|
||||||
// We probably need a way to be deterministic about
|
// We probably need a way to be deterministic about
|
||||||
// how we locate that ffmpeg-bar wrapper, npx maybe?
|
// how we locate that ffmpeg-bar wrapper, npx maybe?
|
||||||
// Do not remove those "useless" escapes or ffmpeg will
|
// Do not remove those "useless" escapes or ffmpeg will
|
||||||
|
|
Loading…
Reference in a new issue