diff --git a/appinfo/routes.php b/appinfo/routes.php index aa334e8..1b448f8 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -8,7 +8,7 @@ return [ ['name' => 'main#Download', 'url' => '/new', 'verb' => 'POST'], ['name' => 'Aria2#Action', 'url' => '/aria2/{path}', 'verb' => 'POST'], ['name' => 'Aria2#getStatus', 'url' => '/status/{path}', 'verb' => 'POST'], - ['name' => 'Main#scanFolder', 'url' => '/scanfolder', 'verb' => 'GET'], + ['name' => 'Main#scanFolder', 'url' => '/scanfolder', 'verb' => 'POST'], ['name' => 'Youtube#Index', 'url' => '/youtube/get', 'verb' => 'POST'], ['name' => 'Youtube#Download', 'url' => '/youtube/new', 'verb' => 'POST'], ['name' => 'Youtube#Delete', 'url' => '/youtube/delete', 'verb' => 'POST'], diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 85d7e1e..267a756 100644 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -202,7 +202,8 @@ class MainController extends Controller */ public function scanFolder() { - $resp = folderScan::sync(); + $force = $this->request->getParam('force') ?? false; + $resp = $force ? folderScan::create()->scan() : folderScan::sync(); return new JSONResponse($resp); } /** diff --git a/lib/Controller/YoutubeController.php b/lib/Controller/YoutubeController.php index d856f79..f7e02d5 100644 --- a/lib/Controller/YoutubeController.php +++ b/lib/Controller/YoutubeController.php @@ -81,10 +81,9 @@ class YoutubeController extends Controller $url = trim($this->request->getParam('text-input-value')); $yt = $this->youtube; if (in_array($this->request->getParam('extension'), $this->audio_extensions)) { - $yt->audioOnly = TRUE; + $yt->audioOnly = true; $yt->audioFormat = $this->request->getParam('extension'); } else { - $yt->audioOnly = FALSE; $yt->videoFormat = $this->request->getParam('extension'); } if (!$yt->isInstalled()) { @@ -158,10 +157,10 @@ class YoutubeController extends Controller if (!empty($data['link'])) { if (isset($data['ext'])) { if (in_array($data['ext'], $this->audio_extensions)) { - $this->youtube->audioOnly = TRUE; + $this->youtube->audioOnly = true; $this->youtube->audioFormat = $data['ext']; } else { - $this->youtube->audioOnly = FALSE; + $this->youtube->audioOnly = false; $this->youtube->videoFormat = $data['ext']; } } diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php index f59ebb3..1ffb021 100644 --- a/lib/Tools/Youtube.php +++ b/lib/Tools/Youtube.php @@ -7,9 +7,8 @@ use Symfony\Component\Process\Process; class Youtube { - private $ipv4Only; public $audioOnly = 0; - public $audioFormat = 'm4a', $videoFormat; + public $audioFormat = 'm4a', $videoFormat = null; private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'; private $options = []; private $downloadDir; @@ -129,7 +128,7 @@ class Youtube if ($this->audioOnly) { $this->audioMode(); } else { - if ((Helper::ffmpegInstalled()) && ($this->videoFormat != "")) { + if (Helper::ffmpegInstalled() && $this->videoFormat) { $this->setOption('--format', 'bestvideo+bestaudio/best'); $this->setVideoFormat($this->videoFormat); } else { @@ -145,9 +144,9 @@ class Youtube $process->setTimeout($this->timeout); $data = ['link' => $url]; if ($this->audioOnly) { - $data['ext'] = $this->audioFormat; + $data['ext'] = $this->audioFormat; } else { - $data['ext'] = $this->videoFormat; + $data['ext'] = $this->videoFormat; } $process->run(function ($type, $buffer) use ($data, $process) { if (Process::ERR === $type) { diff --git a/src/App.vue b/src/App.vue index 0514638..3b202c4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -91,7 +91,7 @@ export default { let formWrapper = element.closest("form"); let formData = helper.getData(formWrapper); let inputValue = formData["text-input-value"]; - if (inputValue && inputValue.length < 2) { + if (!inputValue || (inputValue && inputValue.length < 2)) { helper.error(t("ncdownloader", "Please enter valid keyword!")); vm.$data.loading = 0; return; diff --git a/src/actions/buttonActions.js b/src/actions/buttonActions.js index 3a34812..3b521b2 100644 --- a/src/actions/buttonActions.js +++ b/src/actions/buttonActions.js @@ -11,8 +11,9 @@ const buttonHandler = (event, type) => { let url = element.getAttribute("path"); let row, data = {}; let removeRow = true; - if (element.getAttribute("id") == "download-action-button"){ - helper.getCounters(); + if (element.getAttribute("id") == "download-action-button") { + helper.loop(helper.getCounters); + helper.setContentTableType("search-results"); } if (row = element.closest('.table-row-search')) { if (element.className == 'icon-clipboard') { diff --git a/src/index.js b/src/index.js index a682462..94bf2bd 100644 --- a/src/index.js +++ b/src/index.js @@ -81,8 +81,6 @@ window.addEventListener('DOMContentLoaded', function () { delegate('#app-ncdownloader-wrapper', { target: '[data-tippy-content]' } ); - - }); diff --git a/src/utils/helper.js b/src/utils/helper.js index c73b888..6786099 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -16,6 +16,9 @@ const helper = { return helper.vue[name]; }, generateUrl: generateUrl, + loop(callback, delay = 3000, ...args) { + Polling.create().setDelay(delay).run(callback, ...args); + }, isPolling() { return Polling.create().isEnabled(); }, @@ -28,10 +31,10 @@ const helper = { polling(delay = 1500, path) { Polling.create().setDelay(delay).run(helper.refresh, path); }, - scanFolder(path = "/apps/ncdownloader/scanfolder") { + scanFolder(forceScan = false, path = "/apps/ncdownloader/scanfolder") { let url = helper.generateUrl(path); return new Promise((resolve) => { - Http.getInstance(url).setMethod('GET').setHandler(function (data) { + Http.getInstance(url).setData({ "force": forceScan }).setHandler(function (data) { resolve(data.status); }).send(); });