diff --git a/.gitignore b/.gitignore
index c2e088a..23a0eb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,6 @@ package-lock.json
test.js
.*
!/.gitignore
-todo.txt
\ No newline at end of file
+todo.txt
+ffmpeg
+ffmpeg.exe
\ No newline at end of file
diff --git a/html/index.html b/html/index.html
index 230ad59..e30b775 100644
--- a/html/index.html
+++ b/html/index.html
@@ -82,7 +82,7 @@
-
+
@@ -92,7 +92,7 @@
-
+
diff --git a/linux.sh b/linux.sh
new file mode 100755
index 0000000..616cb94
--- /dev/null
+++ b/linux.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# Script to download the latest x64 linux version of custom ffmpeg build for yt-dlp
+# The binary will be placed in the root dir of the app
+
+wget "https://github.com/yt-dlp/FFmpeg-Builds/releases/latest/download/ffmpeg-n5.1-latest-linux64-gpl-5.1.tar.xz"
+tar xvf ffmpeg-n5.1-latest-linux64-gpl-5.1.tar.xz
+cp ffmpeg-n5.1-latest-linux64-gpl-5.1/bin/ffmpeg ffmpeg
+chmod 777 ffmpeg
+rm -rf ffmpeg-n5.1-latest-linux64-gpl-5.1
+rm ffmpeg-n5.1-latest-linux64-gpl-5.1.tar.xz
\ No newline at end of file
diff --git a/package.json b/package.json
index 33f33b8..3415ecb 100644
--- a/package.json
+++ b/package.json
@@ -1,21 +1,20 @@
{
"dependencies": {
"electron-updater": "^5.2.1",
- "ffmpeg-static": "^5.1.0",
- "yt-dlp-wrap": "^2.3.11"
+ "yt-dlp-wrap": "^2.3.11",
+ "yt-dlp-wrap-extended": "^2.3.12"
},
"name": "ytdownloader",
- "version": "3.0.2",
+ "version": "3.1.0",
"main": "main.js",
"scripts": {
"start": "electron .",
"watch": "nodemon --exec electron .",
"debug": "electron --inspect=5858 .",
- "windows": "rm -rf ./node_modules && electron-builder -w",
- "linux": "rm -rf ./node_modules && electron-builder -l",
- "mac": "rm -rf ./node_modules && electron-builder -m",
- "publish-linux": "rm -rf ./node_modules && electron-builder -l --publish=always",
- "publish-windows": "rm -rf ./node_modules && electron-builder -w --publish=always"
+ "windows": "./windows.sh && electron-builder -w",
+ "linux": "./linux.sh && electron-builder -l",
+ "publish-linux": "./linux.sh && electron-builder -l --publish=always",
+ "publish-windows": "./windows.sh && electron-builder -w --publish=always"
},
"author": {
"name": "Andrew",
diff --git a/src/renderer.js b/src/renderer.js
index d954ef0..33c47a4 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -1,10 +1,10 @@
const fs = require("fs");
const cp = require("child_process");
const os = require("os");
-const ffmpeg = require("ffmpeg-static");
+const ffmpeg = __dirname + "/../ffmpeg"
const path = require("path");
const { shell, ipcRenderer, clipboard } = require("electron");
-const { default: YTDlpWrap } = require("yt-dlp-wrap");
+const { default: YTDlpWrap } = require("yt-dlp-wrap-extended");
// Directories
const homedir = os.homedir();
@@ -357,46 +357,46 @@ getId("audioDownload").addEventListener("click", (event) => {
// Time formatting
-// function timeFormat(duration) {
-// // Hours, minutes and seconds
-// var hrs = ~~(duration / 3600);
-// var mins = ~~((duration % 3600) / 60);
-// var secs = ~~duration % 60;
-// // Ouput like "1:01" or "4:03:59" or "123:03:59"
-// var ret = "";
-// if (hrs > 0) {
-// ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
-// }
-// ret += "" + mins + ":" + (secs < 10 ? "0" : "");
-// ret += "" + secs;
-// return ret;
-// }
+function timeFormat(duration) {
+ // Hours, minutes and seconds
+ var hrs = ~~(duration / 3600);
+ var mins = ~~((duration % 3600) / 60);
+ var secs = ~~duration % 60;
+ // Ouput like "1:01" or "4:03:59" or "123:03:59"
+ var ret = "";
+ if (hrs > 0) {
+ ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
+ }
+ ret += "" + mins + ":" + (secs < 10 ? "0" : "");
+ ret += "" + secs;
+ return ret;
+}
// Manage advanced options, needs to be called
-// function manageAdvanced(duration) {
-// let startTime = getId("startTime").value;
-// let endTime = getId("endTime").value;
-
-// if (startTime && !endTime) {
-// rangeCmd = `*${startTime}-${timeFormat(duration)}`;
-// } else if (!startTime && endTime) {
-// rangeCmd = `*0-${endTime}`;
-// } else if (startTime && endTime) {
-// rangeCmd = `*${startTime}-${endTime}`;
-// } else {
-// rangeOption = "";
-// }
+function manageAdvanced(duration) {
+ let startTime = getId("startTime").value;
+ let endTime = getId("endTime").value;
-// console.log("Range option: " + rangeOption);
-// console.log("rangeCmd:" + rangeCmd);
-// }
+ if (startTime && !endTime) {
+ rangeCmd = `*${startTime}-${timeFormat(duration)}`;
+ } else if (!startTime && endTime) {
+ rangeCmd = `*0-${endTime}`;
+ } else if (startTime && endTime) {
+ rangeCmd = `*${startTime}-${endTime}`;
+ } else {
+ rangeOption = "";
+ }
+
+ console.log("Range option: " + rangeOption);
+ console.log("rangeCmd:" + rangeCmd);
+}
//////////////////////////////
// Downloading with yt-dlp
//////////////////////////////
function download(type) {
- // manageAdvanced(duration);
+ manageAdvanced(duration);
const url = getId("url").value;
let ext;
@@ -495,8 +495,8 @@ function download(type) {
downloadProcess = ytdlp.exec(
[
url,
- // rangeOption,
- // rangeCmd,
+ rangeOption,
+ rangeCmd,
"-f",
`${format_id}+${audioFormat}`,
"-o",
@@ -513,8 +513,8 @@ function download(type) {
downloadProcess = ytdlp.exec(
[
url,
- // rangeOption,
- // rangeCmd,
+ rangeOption,
+ rangeCmd,
"-f",
format_id,
"-o",
@@ -533,6 +533,7 @@ function download(type) {
controller.abort();
});
+
downloadProcess
.on("progress", (progress) => {
getId(randomId + "prog").textContent = `Progress: ${
@@ -601,9 +602,15 @@ function afterSave(location, filename, progressId) {
body: "File saved successfully.",
icon: "../assets/images/icon.png",
});
+ let finalLocation = location
+ let finalFilename = filename
+ if (os.platform() === "win32"){
+ finalLocation = location.split(path.sep).join("\\\\")
+ finalFilename = filename.split(path.sep).join("\\\\")
+ }
getId(
progressId
- ).innerHTML = `File saved. Click to Open`;
+ ).innerHTML = `File saved. Click to Open`;
}
function showItem(location, filename) {
diff --git a/windows.sh b/windows.sh
new file mode 100644
index 0000000..b3e383b
--- /dev/null
+++ b/windows.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Script to download the latest x64 windows version of custom ffmpeg build for yt-dlp
+# The binary will be placed in the root dir of the app
+
+
+wget "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-n5.1-latest-win64-gpl-5.1.zip"
+tar xvf ffmpeg-n5.1-latest-linux64-gpl-5.1.tar.xz
+cp ffmpeg-n5.1-latest-linux64-gpl-5.1/bin/ffmpeg ffmpeg.exe
+chmod 777 ffmpeg.exe
+rm -rf ffmpeg-n5.1-latest-linux64-gpl-5.1
+rm ffmpeg-n5.1-latest-linux64-gpl-5.1.tar.xz
\ No newline at end of file