minor chages;

This commit is contained in:
huangjx
2022-04-29 22:49:59 +08:00
parent 3a13bfa244
commit 6195928b74
8 changed files with 19 additions and 18 deletions

View File

@@ -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'],

View File

@@ -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);
}
/**

View File

@@ -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'];
}
}

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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') {

View File

@@ -81,8 +81,6 @@ window.addEventListener('DOMContentLoaded', function () {
delegate('#app-ncdownloader-wrapper',
{ target: '[data-tippy-content]' }
);
});

View File

@@ -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();
});