@ -185,6 +185,9 @@ async function downloadUpdateFiles() {
fs . removeSync ( path . join ( _ _dirname , 'public' ) ) ;
fs . mkdirSync ( path . join ( _ _dirname , 'public' ) ) ;
let replace _ignore _list = [ 'youtubedl-material/appdata/default.json' ,
'youtubedl-material/appdata/db.json' ]
// downloads new package.json and adds new public dir files from the downloaded zip
fs . createReadStream ( path . join ( _ _dirname , 'youtubedl-material-latest-release.zip' ) ) . pipe ( unzipper . Parse ( ) )
. on ( 'entry' , function ( entry ) {
@ -200,7 +203,7 @@ async function downloadUpdateFiles() {
} else {
entry . autodrain ( ) ;
}
} else if ( fileName === 'youtubedl-material/package.json' ) {
} else if ( ! replace _ignore _list . includes ( fileName ) ) {
// get package.json
entry . pipe ( fs . createWriteStream ( path . join ( _ _dirname , 'package.json' ) ) ) ;
} else {
@ -821,7 +824,7 @@ async function autoUpdateYoutubeDL() {
let current _app _details _path = 'node_modules/youtube-dl/bin/details' ;
let current _app _details _exists = fs . existsSync ( current _app _details _path ) ;
if ( ! current _app _details _exists ) {
console . log ( ` Failed to get youtube-dl binary details at location: ${ current _app _details _path } . Cancelling update check.` ) ;
console . log ( ` ERROR: Failed to get youtube-dl binary details at location ' ${ current _app _details _path } ' . Cancelling update check.` ) ;
resolve ( false ) ;
return ;
}
@ -829,9 +832,17 @@ async function autoUpdateYoutubeDL() {
let current _version = current _app _details [ 'version' ] ;
let stored _binary _path = current _app _details [ 'path' ] ;
if ( ! stored _binary _path || typeof stored _binary _path !== 'string' ) {
console . log ( ` Failed to get youtube-dl binary path at location: ${ current _app _details _path } . Cancelling update check. ` ) ;
resolve ( false ) ;
return ;
// console.log(`INFO: Failed to get youtube-dl binary path at location: ${current_app_details_path}, attempting to guess actual path...`);
const guessed _base _path = 'node_modules/youtube-dl/bin/' ;
const guessed _file _path = guessed _base _path + 'youtube-dl' + ( process . platform === 'win32' ? '.exe' : '' ) ;
if ( fs . existsSync ( guessed _file _path ) ) {
stored _binary _path = guessed _file _path ;
// console.log('INFO: Guess successful! Update process continuing...')
} else {
console . log ( ` ERROR: Guess ' ${ guessed _file _path } ' is not correct. Cancelling update check. Verify that your youtube-dl binaries exist by running npm install. ` ) ;
resolve ( false ) ;
return ;
}
}
// got version, now let's check the latest version from the youtube-dl API