youtube-dl now updates in the same way as the other forks

pull/336/head
Isaac Abadi 5 years ago
parent a1b32e2851
commit c660c28422

@ -1681,9 +1681,8 @@ 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) {
logger.error(`Failed to get youtube-dl binary details at location '${current_app_details_path}'. Cancelling update check.`); logger.warn(`Failed to get youtube-dl binary details at location '${current_app_details_path}'. Generating file...`);
resolve(false); fs.writeJSONSync('node_modules/youtube-dl/bin/details', {"version":"2020.00.00", "downloader": default_downloader});
return;
} }
let current_app_details = JSON.parse(fs.readFileSync(current_app_details_path)); let current_app_details = JSON.parse(fs.readFileSync(current_app_details_path));
let current_version = current_app_details['version']; let current_version = current_app_details['version'];
@ -1739,20 +1738,15 @@ async function autoUpdateYoutubeDL() {
}); });
} }
async function downloadLatestYoutubeDLBinary() { async function downloadLatestYoutubeDLBinary(new_version) {
return new Promise(resolve => { const file_ext = is_windows ? '.exe' : '';
let binary_path = 'node_modules/youtube-dl/bin';
downloader(binary_path, function error(err, done) { const download_url = `https://github.com/ytdl-org/youtube-dl/releases/latest/download/youtube-dl${file_ext}`;
if (err) { const output_path = `node_modules/youtube-dl/bin/youtube-dl${file_ext}`;
logger.error(`youtube-dl failed to update. Restart the server to try again.`);
logger.error(err); await fetchFile(download_url, output_path, `youtube-dl ${new_version}`);
resolve(false);
} updateDetailsJSON(new_version, 'youtube-dl');
logger.info(`youtube-dl successfully updated!`);
updateDetailsJSON(null, 'youtube-dl');
resolve(true);
});
});
} }
async function downloadLatestYoutubeDLCBinary(new_version) { async function downloadLatestYoutubeDLCBinary(new_version) {

Loading…
Cancel
Save