@@ -44,7 +44,6 @@ async function init(): Promise<void> {
44
44
45
45
46
46
async function DoInteractiveLogin ( url : string , username ?: string ) : Promise < Session > {
47
- const videoId : string = url . split ( '/' ) . pop ( ) ?? process . exit ( ERROR_CODE . INVALID_VIDEO_GUID ) ;
48
47
49
48
logger . info ( 'Launching headless Chrome to perform the OpenID Connect dance...' ) ;
50
49
@@ -81,7 +80,7 @@ async function DoInteractiveLogin(url: string, username?: string): Promise<Sessi
81
80
remember the credentials or it could still prompt the user for a password */
82
81
}
83
82
84
- await browser . waitForTarget ( ( target : puppeteer . Target ) => target . url ( ) . includes ( videoId ) , { timeout : 150000 } ) ;
83
+ await browser . waitForTarget ( ( target : puppeteer . Target ) => target . url ( ) . includes ( 'microsoftstream.com' ) , { timeout : 150000 } ) ;
85
84
logger . info ( 'We are logged in.' ) ;
86
85
87
86
let session : Session | null = null ;
@@ -142,16 +141,16 @@ async function downloadVideo(videoGUIDs: Array<string>, outputDirectories: Array
142
141
return ;
143
142
}
144
143
145
- for ( const video of videos ) {
144
+ for ( const [ index , video ] of videos . entries ( ) ) {
146
145
147
146
if ( argv . skip && fs . existsSync ( video . outPath ) ) {
148
147
logger . info ( `File already exists, skipping: ${ video . outPath } \n` ) ;
149
148
continue ;
150
149
}
151
150
152
- if ( argv . keepLoginCookies ) {
151
+ if ( argv . keepLoginCookies && index !== 0 ) {
153
152
logger . info ( 'Trying to refresh token...' ) ;
154
- session = await refreshSession ( ) ;
153
+ session = await refreshSession ( 'https://web.microsoftstream.com/video/' + videoGUIDs [ index ] ) ;
155
154
}
156
155
157
156
const pbar : cliProgress . SingleBar = new cliProgress . SingleBar ( {
0 commit comments