This repository was archived by the owner on Aug 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11async function getDownloadLink ( { lessonID, lessonName} , echo360Domain , downloadHD ) {
2- const regex = / (?: \( \" ) (?: .* ) (?: \" \) ) / ;
2+ const classroomAppRegex = new RegExp ( '(classroomApp)' ) ;
3+ const dataRegex = / (?: \( \" ) (?: .* ) (?: \" \) ) / ;
34 const lessonHTMLPageRequest = new Request ( `${ echo360Domain } /lesson/${ lessonID } /classroom` , { method : 'GET' , credentials : 'include' } ) ;
45 const lessonHTMLPageResponse = await fetch ( lessonHTMLPageRequest )
56 const lessonHTMLPageText = await lessonHTMLPageResponse . text ( ) ;
67 const dummyEl = document . createElement ( 'html' )
78 dummyEl . innerHTML = lessonHTMLPageText ;
9+ const videoDataScript = Array . from ( dummyEl . getElementsByTagName ( 'script' ) ) . filter ( ( script ) => classroomAppRegex . test ( script . innerText ) ) ;
810
9- const videoDataString = dummyEl . getElementsByTagName ( 'script' ) [ 11 ] . innerText . match ( regex ) [ 0 ]
11+ if ( videoDataScript . length === 0 )
12+ {
13+ return null ;
14+ }
15+
16+ const videoDataString = videoDataScript [ 0 ] . innerText . match ( dataRegex ) [ 0 ] ;
17+
1018 const cleanString = videoDataString . substring ( 1 , videoDataString . length - 1 ) ;
1119 const videoDataObject = JSON . parse ( JSON . parse ( cleanString ) ) ;
1220
You can’t perform that action at this time.
0 commit comments