Skip to content

Commit

Permalink
Support for updating yt-dlp
Browse files Browse the repository at this point in the history
updated all packages
made drag and drop more intuitive
removed stray console.log
  • Loading branch information
Joery-M committed Feb 23, 2023
1 parent aa3ae79 commit e00ad21
Show file tree
Hide file tree
Showing 5 changed files with 3,704 additions and 7,143 deletions.
2 changes: 0 additions & 2 deletions downloaders/convertHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ function testGPU (url, isHDR)
.addOptions(isHDR ? ["-pix_fmt", "yuv420p10le"] : [])
.on("end", (...args) =>
{
console.log("b");
resolve(true);
stream.destroy();
})
Expand All @@ -262,7 +261,6 @@ function testGPU (url, isHDR)
})
.on("progress", (...args) =>
{
console.log("a");
resolve(true);
stream.destroy();
})
Expand Down
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,39 @@ if (!gotTheLock)
console.log(err.statusMessage);
dialog.showErrorBox("An error occured downloading yt-dlp!", err.statusCode + ": " + err.statusMessage);
});
}else {
// Check version if yt-dlp needs updating
var dlp = new YTDlpWrap(path.join(process.resourcesPath, "./yt-dlp" + ext))

YTDlpWrap.getGithubReleases(1, 1).then(async (versions) => {
const remoteVersion = versions[0].tag_name.replace(/[^A-z0-9.]/g, "")
const localVersion = (await dlp.getVersion()).replace(/[^A-z0-9.]/g, "")

if (remoteVersion !== localVersion) {
YTDlpWrap.downloadFromGithub(path.join(process.resourcesPath, "./yt-dlp" + ext)).then(() =>
{
dialog.showMessageBox(BrowserWindow.getAllWindows()[0], {
title: "Restart required.",
message:
"The YouTube downloader used internally has updated, would you like to restart the application?\n\n" +
"A non-updated version may result in videos not being able to download.",
buttons: ["OK", "Continue without update"],
noLink: true
}).then((val) => {
if (val.response == 0) {
app.quit()
app.relaunch()
}
})
}).catch((err) =>
{
console.log(err.statusMessage);
dialog.showErrorBox("An error occured downloading yt-dlp!", err.statusCode + ": " + err.statusMessage);
});
}
})
}


app.on('activate', () =>
{
Expand Down
Loading

0 comments on commit e00ad21

Please sign in to comment.