From 77af792f1bfc46effd84fb4c8e027ab6645e7bbe Mon Sep 17 00:00:00 2001 From: Moahmed-Ismail MEJRI Date: Wed, 16 Mar 2022 14:28:45 +0100 Subject: [PATCH 1/6] Change services default order. --- src/components/mainForm.vue | 27 ++++++++++++++------------- src/components/searchInput.vue | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/mainForm.vue b/src/components/mainForm.vue index 9aaa246..8ba091f 100644 --- a/src/components/mainForm.vue +++ b/src/components/mainForm.vue @@ -2,13 +2,7 @@
- +
@@ -64,12 +64,12 @@ export default { data() { return { checkedValue: false, - path: this.uris.aria2_url, + path: this.uris.ytd_url, inputType: "download", - checkboxes: false, - downloadType: "aria2", - placeholder: t("ncdownloader", "Paste your http/magnet link here"), - searchLabel: t("ncdownloader", "Search Torrents"), + checkboxes: true, + downloadType: "youtube-dl", + placeholder: t("ncdownloader", "Paste your video link here"), + searchLabel: t("ncdownloader", "Search Music"), searchOptions: this.search_sites ? this.search_sites : this.noOptions(), }; }, @@ -92,6 +92,7 @@ export default { this.downloadType = type; if (type === "aria2") { this.path = this.uris.aria2_url; + this.placeholder = t("ncdownloader", "Paste your http/magnet link here"); } else if (type === "youtube-dl") { this.placeholder = t("ncdownloader", "Paste your video link here"); this.path = this.uris.ytd_url; @@ -208,11 +209,11 @@ export default { .magnet-link, .choose-file { background-color: #a0a0ae; - border-radius: 15px 0px 0px 15px; } .youtube-dl-link { background-color: #b8b8ca; + border-radius: 15px 0px 0px 15px; } .search-torrents { background-color: #d0d0e0; diff --git a/src/components/searchInput.vue b/src/components/searchInput.vue index dae9213..bcb179f 100644 --- a/src/components/searchInput.vue +++ b/src/components/searchInput.vue @@ -28,7 +28,7 @@ export default { data() { return { placeholder: t("ncdownloader", "Enter keyword to search"), - selected: "TPB", + selected: "sliderkz", }; }, components: { From 2c171152b2418aa6daab1b65dbed55bf68abc80f Mon Sep 17 00:00:00 2001 From: Moahmed-Ismail MEJRI Date: Wed, 16 Mar 2022 17:20:51 +0100 Subject: [PATCH 2/6] Add youtube-dl extension format select --- lib/Controller/YoutubeController.php | 5 ++++ lib/Tools/Youtube.php | 14 ++++++++-- src/App.vue | 10 +++++-- src/components/mainForm.vue | 42 +++++++++++++++++++++------- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/lib/Controller/YoutubeController.php b/lib/Controller/YoutubeController.php index c691ef6..b9d87ab 100644 --- a/lib/Controller/YoutubeController.php +++ b/lib/Controller/YoutubeController.php @@ -80,6 +80,11 @@ class YoutubeController extends Controller $url = trim($this->request->getParam('text-input-value')); $yt = $this->youtube; $yt->audioOnly = (bool) $this->request->getParam('audio-only'); + if ($yt->audioOnly) { + $yt->audioFormat = $this->request->getParam('extension'); + } else { + $yt->videoFormat = $this->request->getParam('extension'); + } if (!$yt->isInstalled()) { return new JSONResponse(["error" => "Please install the latest youtube-dl or make the bundled binary file executable in ncdownloader/bin"]); } diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php index e126c39..0623d58 100644 --- a/lib/Tools/Youtube.php +++ b/lib/Tools/Youtube.php @@ -71,9 +71,11 @@ class Youtube $this->addOption('--add-metadata'); $this->setOption('--metadata-from-title', "%(artist)s-%(title).64s"); $this->addOption('--extract-audio'); + } else { + $this->audioFormat = "m4a"; } $pos = strrpos($this->outTpl, '.'); - $this->outTpl = substr($this->outTpl, 0, $pos) . ".m4a"; + $this->outTpl = substr($this->outTpl, 0, $pos) . "." . $this->audioFormat; //$this->outTpl = "/%(id)s-%(title)s.m4a"; $this->setAudioFormat($this->audioFormat); return $this; @@ -91,7 +93,8 @@ class Youtube public function setVideoFormat($format) { - $this->videoFormat = $format; + //$this->videoFormat = $format; + $this->setOption('--recode-video', $format); } public function GetUrlOnly() @@ -126,7 +129,12 @@ class Youtube if ($this->audioOnly) { $this->audioMode(); } else { - $this->setOption('--format', $this->format); + if ((Helper::ffmpegInstalled()) && ($this->videoFormat != "")) { + $this->setOption('--format', 'bestvideo+bestaudio/best'); + $this->setVideoFormat($this->videoFormat); + } else { + $this->setOption('--format', $this->format); + } } $this->helper = YoutubeHelper::create(); $this->downloadDir = $this->downloadDir ?? $this->defaultDir; diff --git a/src/App.vue b/src/App.vue index 4a6c685..5db44c8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -58,9 +58,15 @@ export default { let formData = helper.getData(formWrapper); let inputValue = formData["text-input-value"]; let message; - //formData.audioOnly = document.getElementById('audio-only').checked; if (formData.type === "youtube-dl") { - formData["audio-only"] = formData["audio-only"] === "true"; + formData["audio-only"] = ""; + formData["extension"] = formData["select-value-extension"]; + if (formData["select-value-extension"] === "Default") { + formData["extension"] = ""; + } else if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" )) { + formData["audio-only"] = "true"; + } + helper.info(formData["extension"]); message = helper.t("Download task started!"); } if (!helper.isURL(inputValue) && !helper.isMagnetURI(inputValue)) { diff --git a/src/components/mainForm.vue b/src/components/mainForm.vue index 8ba091f..b009d44 100644 --- a/src/components/mainForm.vue +++ b/src/components/mainForm.vue @@ -24,16 +24,37 @@
-
- +
+
Date: Thu, 17 Mar 2022 16:11:50 +0100 Subject: [PATCH 3/6] Add new extension webm and vorbis --- src/App.vue | 2 +- src/components/mainForm.vue | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index 5db44c8..1a3c95c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -63,7 +63,7 @@ export default { formData["extension"] = formData["select-value-extension"]; if (formData["select-value-extension"] === "Default") { formData["extension"] = ""; - } else if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" )) { + } else if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" ) || (formData["select-value-extension"] === "vorbis" ) ) { formData["audio-only"] = "true"; } helper.info(formData["extension"]); diff --git a/src/components/mainForm.vue b/src/components/mainForm.vue index b009d44..d6bba5b 100644 --- a/src/components/mainForm.vue +++ b/src/components/mainForm.vue @@ -39,6 +39,12 @@ > mp4 + +
From 23392958da8b216036904772c6100756f66c1eb1 Mon Sep 17 00:00:00 2001 From: Moahmed-Ismail MEJRI Date: Thu, 17 Mar 2022 16:18:00 +0100 Subject: [PATCH 4/6] Revert "Change services default order." This reverts commit 77af792f1bfc46effd84fb4c8e027ab6645e7bbe. --- src/components/mainForm.vue | 27 +++++++++++++-------------- src/components/searchInput.vue | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/components/mainForm.vue b/src/components/mainForm.vue index d6bba5b..7d2ef2a 100644 --- a/src/components/mainForm.vue +++ b/src/components/mainForm.vue @@ -2,7 +2,13 @@
+ -
@@ -97,12 +97,12 @@ export default { data() { return { checkedValue: false, - path: this.uris.ytd_url, + path: this.uris.aria2_url, inputType: "download", - checkboxes: true, - downloadType: "youtube-dl", - placeholder: t("ncdownloader", "Paste your video link here"), - searchLabel: t("ncdownloader", "Search Music"), + checkboxes: false, + downloadType: "aria2", + placeholder: t("ncdownloader", "Paste your http/magnet link here"), + searchLabel: t("ncdownloader", "Search Torrents"), searchOptions: this.search_sites ? this.search_sites : this.noOptions(), selectedExt: "Default", }; @@ -126,7 +126,6 @@ export default { this.downloadType = type; if (type === "aria2") { this.path = this.uris.aria2_url; - this.placeholder = t("ncdownloader", "Paste your http/magnet link here"); } else if (type === "youtube-dl") { this.placeholder = t("ncdownloader", "Paste your video link here"); this.path = this.uris.ytd_url; @@ -243,11 +242,11 @@ export default { .magnet-link, .choose-file { background-color: #a0a0ae; + border-radius: 15px 0px 0px 15px; } .youtube-dl-link { background-color: #b8b8ca; - border-radius: 15px 0px 0px 15px; } .search-torrents { background-color: #d0d0e0; diff --git a/src/components/searchInput.vue b/src/components/searchInput.vue index bcb179f..dae9213 100644 --- a/src/components/searchInput.vue +++ b/src/components/searchInput.vue @@ -28,7 +28,7 @@ export default { data() { return { placeholder: t("ncdownloader", "Enter keyword to search"), - selected: "sliderkz", + selected: "TPB", }; }, components: { From 14f5b386f9902ac73158f62699fbcd6cdba4d7b2 Mon Sep 17 00:00:00 2001 From: Moahmed-Ismail MEJRI Date: Thu, 17 Mar 2022 16:42:44 +0100 Subject: [PATCH 5/6] Cleanup code --- src/App.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1a3c95c..6f3a35c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -60,13 +60,13 @@ export default { let message; if (formData.type === "youtube-dl") { formData["audio-only"] = ""; - formData["extension"] = formData["select-value-extension"]; - if (formData["select-value-extension"] === "Default") { - formData["extension"] = ""; - } else if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" ) || (formData["select-value-extension"] === "vorbis" ) ) { - formData["audio-only"] = "true"; + formData["extension"] = ""; + if (formData["select-value-extension"] !== "Default") { + formData["extension"] = formData["select-value-extension"]; + if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" ) || (formData["select-value-extension"] === "vorbis" ) ) { + formData["audio-only"] = "true"; + } } - helper.info(formData["extension"]); message = helper.t("Download task started!"); } if (!helper.isURL(inputValue) && !helper.isMagnetURI(inputValue)) { From 4c9b9e06d209701c857c884419f5c139b90c13fc Mon Sep 17 00:00:00 2001 From: jiaxin huang Date: Fri, 18 Mar 2022 08:28:42 +0800 Subject: [PATCH 6/6] Update mainForm.vue --- src/components/mainForm.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/mainForm.vue b/src/components/mainForm.vue index 7d2ef2a..0e205df 100644 --- a/src/components/mainForm.vue +++ b/src/components/mainForm.vue @@ -35,13 +35,13 @@ @@ -49,19 +49,19 @@