1
0
mirror of https://github.com/snobu/destreamer.git synced 2026-02-12 17:49:42 +00:00

added access token refresh logic (closes #255)

This commit is contained in:
Luca Armaroli
2020-10-11 21:56:08 +02:00
parent 3249759c29
commit 85f3beae71
2 changed files with 31 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ import { setProcessEvents } from './Events';
import { logger } from './Logger';
import { getPuppeteerChromiumPath } from './PuppeteerHelper';
import { drawThumbnail } from './Thumbnail';
import { TokenCache} from './TokenCache';
import { TokenCache, refreshSession} from './TokenCache';
import { Video, Session } from './Types';
import { checkRequirements, parseInputFile, parseCLIinput, getUrlsFromPlaylist} from './Utils';
import { getVideosInfo, createUniquePaths } from './VideoUtils';
@@ -195,6 +195,12 @@ async function downloadVideo(videoGUIDs: Array<string>,
continue;
}
if (argv.keepLoginCookies && tokenCache.isExpiring(session)) {
logger.info('Trying to refresh access token...');
session = await refreshSession('https://web.microsoftstream.com/');
apiClient.setSession(session);
}
masterParser.push(await apiClient.callUrl(video.playbackUrl).then(res => res?.data));
masterParser.end();