mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-23 02:33:19 +03:00
Updater now grab new backend files
youtube-dl auto updater now guesses binary path, which makes the update process work much more reliably
This commit is contained in:
@@ -185,6 +185,9 @@ async function downloadUpdateFiles() {
|
|||||||
fs.removeSync(path.join(__dirname, 'public'));
|
fs.removeSync(path.join(__dirname, 'public'));
|
||||||
fs.mkdirSync(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
|
// 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())
|
fs.createReadStream(path.join(__dirname, 'youtubedl-material-latest-release.zip')).pipe(unzipper.Parse())
|
||||||
.on('entry', function (entry) {
|
.on('entry', function (entry) {
|
||||||
@@ -200,7 +203,7 @@ async function downloadUpdateFiles() {
|
|||||||
} else {
|
} else {
|
||||||
entry.autodrain();
|
entry.autodrain();
|
||||||
}
|
}
|
||||||
} else if (fileName === 'youtubedl-material/package.json') {
|
} else if (!replace_ignore_list.includes(fileName)) {
|
||||||
// get package.json
|
// get package.json
|
||||||
entry.pipe(fs.createWriteStream(path.join(__dirname, 'package.json')));
|
entry.pipe(fs.createWriteStream(path.join(__dirname, 'package.json')));
|
||||||
} else {
|
} else {
|
||||||
@@ -821,7 +824,7 @@ async function autoUpdateYoutubeDL() {
|
|||||||
let current_app_details_path = 'node_modules/youtube-dl/bin/details';
|
let current_app_details_path = 'node_modules/youtube-dl/bin/details';
|
||||||
let current_app_details_exists = fs.existsSync(current_app_details_path);
|
let current_app_details_exists = fs.existsSync(current_app_details_path);
|
||||||
if (!current_app_details_exists) {
|
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);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -829,10 +832,18 @@ async function autoUpdateYoutubeDL() {
|
|||||||
let current_version = current_app_details['version'];
|
let current_version = current_app_details['version'];
|
||||||
let stored_binary_path = current_app_details['path'];
|
let stored_binary_path = current_app_details['path'];
|
||||||
if (!stored_binary_path || typeof stored_binary_path !== 'string') {
|
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.`);
|
// 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);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// got version, now let's check the latest version from the youtube-dl API
|
// got version, now let's check the latest version from the youtube-dl API
|
||||||
let youtubedl_api_path = 'https://api.github.com/repos/ytdl-org/youtube-dl/tags';
|
let youtubedl_api_path = 'https://api.github.com/repos/ytdl-org/youtube-dl/tags';
|
||||||
|
|||||||
Reference in New Issue
Block a user