Download original audio for m4a in playlists

pull/164/head
Andrew 2 years ago
parent e436907265
commit 283cb7155c

@ -46,7 +46,7 @@
<!-- Menu --> <!-- Menu -->
<div id="menu"> <div id="menu">
<a id="playlistWin" class="menuItem">Download Playlist</a> <a id="playlistWin" class="menuItem">Download Playlist</a>
<a id="newPlaylistWin" class="menuItem">New Playlist</a> <!-- <a id="newPlaylistWin" class="menuItem">New Playlist</a> -->
<a id="preferenceWin" class="menuItem">Preferences</a> <a id="preferenceWin" class="menuItem">Preferences</a>
<a id="aboutWin" class="menuItem">About</a> <a id="aboutWin" class="menuItem">About</a>
<span id="themeTxt" class="menuItem">Theme:</span> <span id="themeTxt" class="menuItem">Theme:</span>

@ -4,7 +4,7 @@
"yt-dlp-wrap-plus": "^2.3.16" "yt-dlp-wrap-plus": "^2.3.16"
}, },
"name": "ytdownloader", "name": "ytdownloader",
"version": "3.15.0", "version": "3.14.2",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"start": "electron .", "start": "electron .",

@ -118,11 +118,10 @@ function download(type) {
} else { } else {
if (videoType === "mp4") { if (videoType === "mp4") {
format = `-f "${formatId}+m4a/mp4[height=${quality}]+m4a/bv*[height<=${quality}]+ba/best[height<=${quality}]"`; format = `-f "${formatId}+m4a/mp4[height=${quality}]+m4a/bv*[height<=${quality}]+ba/best[height<=${quality}]"`;
} } else if (videoType === "webm") {
else if (videoType === "webm"){
format = `-f "webm[height<=${quality}]+opus/bv*[height<=${quality}]+ba/${formatId}+m4a/mp4[height=${quality}]+m4a/best[height<=${quality}]"`; format = `-f "webm[height<=${quality}]+opus/bv*[height<=${quality}]+ba/${formatId}+m4a/mp4[height=${quality}]+m4a/best[height<=${quality}]"`;
} else { } else {
format = `-f "bv*[height=${quality}]+ba/best[height=${quality}]/best[height<=${quality}]"` format = `-f "bv*[height=${quality}]+ba/best[height=${quality}]/best[height<=${quality}]"`;
} }
} }
} else { } else {
@ -152,6 +151,37 @@ function download(type) {
{ shell: true, detached: false }, { shell: true, detached: false },
controller.signal controller.signal
); );
} else {
// Youtube provides m4a as audio, so no need to convert
if (
(url.includes("youtube.com/") || url.includes("youtu.be/")) &&
format == "m4a"
) {
downloadProcess = ytdlp.exec(
[
"--yes-playlist",
"--no-warnings",
"-f",
`ba[ext=${format}]/ba`,
"-o",
`"${path.join(
downloadDir,
foldernameFormat,
filenameFormat
)}"`,
"-I",
`"${playlistIndex}:${playlistEnd}"`,
"--ffmpeg-location",
ffmpeg,
cookieArg,
browser,
configArg,
configTxt,
`"${url}"`,
],
{ shell: true, detached: false },
controller.signal
);
} else { } else {
downloadProcess = ytdlp.exec( downloadProcess = ytdlp.exec(
[ [
@ -161,7 +191,11 @@ function download(type) {
"--audio-format", "--audio-format",
format, format,
"-o", "-o",
`"${path.join(downloadDir, foldernameFormat, filenameFormat)}"`, `"${path.join(
downloadDir,
foldernameFormat,
filenameFormat
)}"`,
"-I", "-I",
`"${playlistIndex}:${playlistEnd}"`, `"${playlistIndex}:${playlistEnd}"`,
"--ffmpeg-location", "--ffmpeg-location",
@ -176,6 +210,7 @@ function download(type) {
controller.signal controller.signal
); );
} }
}
downloadProcess.on("ytDlpEvent", (eventType, eventData) => { downloadProcess.on("ytDlpEvent", (eventType, eventData) => {
// console.log(eventData); // console.log(eventData);
@ -509,14 +544,13 @@ audioToggle.addEventListener("click", (event) => {
}); });
getId("select").addEventListener("change", () => { getId("select").addEventListener("change", () => {
value = getId("select").value value = getId("select").value;
if (value == "best" || value == "worst" || value == "useConfig") { if (value == "best" || value == "worst" || value == "useConfig") {
getId("typeSelectBox").style.display = "none" getId("typeSelectBox").style.display = "none";
} } else {
else { getId("typeSelectBox").style.display = "block";
getId("typeSelectBox").style.display = "block"
} }
}) });
// More options // More options
@ -576,7 +610,7 @@ getId("downloadThumbnails").textContent = i18n.__("Download thumbnails");
getId("saveLinks").textContent = i18n.__("Save video links to a file"); getId("saveLinks").textContent = i18n.__("Save video links to a file");
getId("useConfigTxt").textContent = i18n.__("Use config file"); getId("useConfigTxt").textContent = i18n.__("Use config file");
getId("errorBtn").textContent = i18n.__("Error Details") + " ▼"; getId("errorBtn").textContent = i18n.__("Error Details") + " ▼";
getId("clText").textContent = i18n.__("Current download location - ") getId("clText").textContent = i18n.__("Current download location - ");
getId("selectLocation").textContent = i18n.__("Select Download Location"); getId("selectLocation").textContent = i18n.__("Select Download Location");
getId("themeTxt").textContent = i18n.__("Theme"); getId("themeTxt").textContent = i18n.__("Theme");
getId("autoTxt").textContent = i18n.__("Auto"); getId("autoTxt").textContent = i18n.__("Auto");

@ -1164,10 +1164,10 @@ getId("playlistWin").addEventListener("click", () => {
closeMenu(); closeMenu();
ipcRenderer.send("load-win", __dirname + "/playlist.html"); ipcRenderer.send("load-win", __dirname + "/playlist.html");
}); });
getId("newPlaylistWin").addEventListener("click", () => { // getId("newPlaylistWin").addEventListener("click", () => {
closeMenu(); // closeMenu();
ipcRenderer.send("load-win", __dirname + "/playlist_new.html"); // ipcRenderer.send("load-win", __dirname + "/playlist_new.html");
}); // });
ipcRenderer.on("link", (event, text) => { ipcRenderer.on("link", (event, text) => {
pasteFromTray(text); pasteFromTray(text);

Loading…
Cancel
Save