tidying up

This commit is contained in:
huangjx
2022-07-24 10:54:02 +08:00
parent 96c7128ef7
commit 3a00325042
32 changed files with 146 additions and 144 deletions

View File

@@ -4,12 +4,12 @@ namespace OCA\NCDownloader\AppInfo;
use OCA\NCDownloader\Controller\Aria2Controller; use OCA\NCDownloader\Controller\Aria2Controller;
use OCA\NCDownloader\Controller\MainController; use OCA\NCDownloader\Controller\MainController;
use OCA\NCDownloader\Controller\YoutubeController; use OCA\NCDownloader\Controller\YtdlController;
use OCA\NCDownloader\Tools\Aria2; use OCA\NCDownloader\Aria2\Aria2;
use OCA\NCDownloader\Tools\Client; use OCA\NCDownloader\Http\Client;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
use OCA\NCDownloader\Tools\Youtube; use OCA\NCDownloader\Ytdl\Ytdl;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCP\IContainer; use OCP\IContainer;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
@@ -32,9 +32,9 @@ class Application extends App
return new Aria2(Helper::getAria2Config($this->uid)); return new Aria2(Helper::getAria2Config($this->uid));
}); });
$container->registerService('Youtube', function (IContainer $container) { $container->registerService('Ytdl', function (IContainer $container) {
$config = Helper::getYoutubeConfig($this->uid); $config = Helper::getYtdlConfig($this->uid);
return new Youtube($config); return new Ytdl($config);
}); });
$container->registerService('Settings', function (IContainer $container) { $container->registerService('Settings', function (IContainer $container) {
@@ -49,7 +49,7 @@ class Application extends App
\OC::$server->getL10N('ncdownloader'), \OC::$server->getL10N('ncdownloader'),
//\OC::$server->getRootFolder(), //\OC::$server->getRootFolder(),
$container->query('Aria2'), $container->query('Aria2'),
$container->query('Youtube') $container->query('Ytdl')
); );
}); });
@@ -63,14 +63,14 @@ class Application extends App
$container->query('Aria2') $container->query('Aria2')
); );
}); });
$container->registerService('YoutubeController', function (IContainer $container) { $container->registerService('YtdlController', function (IContainer $container) {
return new YoutubeController( return new YtdlController(
$container->query('AppName'), $container->query('AppName'),
$container->query('Request'), $container->query('Request'),
$container->query('UserId'), $container->query('UserId'),
\OC::$server->getL10N('ncdownloader'), \OC::$server->getL10N('ncdownloader'),
$container->query('Aria2'), $container->query('Aria2'),
$container->query('Youtube') $container->query('Ytdl')
); );
}); });
$container->registerService('httpClient', function () { $container->registerService('httpClient', function () {

View File

@@ -9,10 +9,10 @@ return [
['name' => 'Aria2#Action', 'url' => '/aria2/{path}', 'verb' => 'POST'], ['name' => 'Aria2#Action', 'url' => '/aria2/{path}', 'verb' => 'POST'],
['name' => 'Aria2#getStatus', 'url' => '/status/{path}', 'verb' => 'POST'], ['name' => 'Aria2#getStatus', 'url' => '/status/{path}', 'verb' => 'POST'],
['name' => 'Main#scanFolder', 'url' => '/scanfolder', 'verb' => 'POST'], ['name' => 'Main#scanFolder', 'url' => '/scanfolder', 'verb' => 'POST'],
['name' => 'Youtube#Index', 'url' => '/youtube/get', 'verb' => 'POST'], ['name' => 'Ytdl#Index', 'url' => '/ytdl/get', 'verb' => 'POST'],
['name' => 'Youtube#Download', 'url' => '/youtube/new', 'verb' => 'POST'], ['name' => 'Ytdl#Download', 'url' => '/ytdl/new', 'verb' => 'POST'],
['name' => 'Youtube#Delete', 'url' => '/youtube/delete', 'verb' => 'POST'], ['name' => 'Ytdl#Delete', 'url' => '/ytdl/delete', 'verb' => 'POST'],
['name' => 'Youtube#Redownload', 'url' => '/youtube/redownload', 'verb' => 'POST'], ['name' => 'Ytdl#Redownload', 'url' => '/ytdl/redownload', 'verb' => 'POST'],
['name' => 'Search#Execute', 'url' => '/search', 'verb' => 'POST'], ['name' => 'Search#Execute', 'url' => '/search', 'verb' => 'POST'],
// AdminSettings // AdminSettings
['name' => 'Settings#Admin', 'url' => '/admin/save', 'verb' => 'POST'], ['name' => 'Settings#Admin', 'url' => '/admin/save', 'verb' => 'POST'],
@@ -21,9 +21,9 @@ return [
['name' => 'Settings#aria2Get', 'url' => '/personal/aria2/get', 'verb' => 'POST'], ['name' => 'Settings#aria2Get', 'url' => '/personal/aria2/get', 'verb' => 'POST'],
['name' => 'Settings#aria2Save', 'url' => '/personal/aria2/save', 'verb' => 'POST'], ['name' => 'Settings#aria2Save', 'url' => '/personal/aria2/save', 'verb' => 'POST'],
['name' => 'Settings#aria2Delete', 'url' => '/personal/aria2/delete', 'verb' => 'POST'], ['name' => 'Settings#aria2Delete', 'url' => '/personal/aria2/delete', 'verb' => 'POST'],
['name' => 'Settings#youtubeGet', 'url' => '/personal/youtube-dl/get', 'verb' => 'POST'], ['name' => 'Settings#ytdlGet', 'url' => '/personal/ytdl/get', 'verb' => 'POST'],
['name' => 'Settings#youtubeSave', 'url' => '/personal/youtube-dl/save', 'verb' => 'POST'], ['name' => 'Settings#ytdlSave', 'url' => '/personal/ytdl/save', 'verb' => 'POST'],
['name' => 'Settings#youtubeDelete', 'url' => '/personal/youtube-dl/delete', 'verb' => 'POST'], ['name' => 'Settings#ytdlDelete', 'url' => '/personal/ytdl/delete', 'verb' => 'POST'],
['name' => 'Settings#getSettings', 'url' => '/getsettings', 'verb' => 'POST'], ['name' => 'Settings#getSettings', 'url' => '/getsettings', 'verb' => 'POST'],
], ],
]; ];

View File

@@ -55,9 +55,9 @@ OC.L10N.register(
"Active" : "活动的", "Active" : "活动的",
"No Torrent Files" : "无torrent文件", "No Torrent Files" : "无torrent文件",
"Upload" : "上传", "Upload" : "上传",
"ocDownloader" : "ocDownloader", "NCDownloader" : "NCDownloader",
"Easy to use download manager for Nextcloud" : "易用的Nextcloud下载管理器", "Easy to use download manager for Nextcloud" : "易用的Nextcloud下载管理器",
"Easy to use download manager using Curl/Aria2 and youtube-dl to allow downloading HTTP(S), FTP(S), YouTube videos and BitTorrent files. For more information on how to install, please go to https://github.com/e-alfred/ncdownloader/blob/master/README.md" : "易用的下载管理器使用Curl/Aria2和youtube-dl工具来下载HTTP(S)、FTP(S)、YouTube视频和BitTorrent文件。关于如何安装的更多信息请访问 https://github.com/e-alfred/ncdownloader/blob/master/README.md", "Easy to use download manager using Curl/Aria2 and ytdl to allow downloading HTTP(S), FTP(S), YouTube videos and BitTorrent files. For more information on how to install, please go to https://github.com/e-alfred/ncdownloader/blob/master/README.md" : "易用的下载管理器使用Curl/Aria2和youtube-dl工具来下载HTTP(S)、FTP(S)、YouTube视频和BitTorrent文件。关于如何安装的更多信息请访问 https://github.com/e-alfred/ncdownloader/blob/master/README.md",
"Active Downloads" : "活动的下载任务", "Active Downloads" : "活动的下载任务",
" using <strong>%s</strong>" : "正在使用<strong>%s</strong>", " using <strong>%s</strong>" : "正在使用<strong>%s</strong>",
"FILENAME" : "文件名", "FILENAME" : "文件名",

View File

@@ -53,9 +53,9 @@
"Active" : "活动的", "Active" : "活动的",
"No Torrent Files" : "无torrent文件", "No Torrent Files" : "无torrent文件",
"Upload" : "上传", "Upload" : "上传",
"ocDownloader" : "ocDownloader", "NCDownloader" : "NCDownloader",
"Easy to use download manager for Nextcloud" : "易用的Nextcloud下载管理器", "Easy to use download manager for Nextcloud" : "易用的Nextcloud下载管理器",
"Easy to use download manager using Curl/Aria2 and youtube-dl to allow downloading HTTP(S), FTP(S), YouTube videos and BitTorrent files. For more information on how to install, please go to https://github.com/e-alfred/ncdownloader/blob/master/README.md" : "易用的下载管理器使用Curl/Aria2和youtube-dl工具来下载HTTP(S)、FTP(S)、YouTube视频和BitTorrent文件。关于如何安装的更多信息请访问 https://github.com/e-alfred/ncdownloader/blob/master/README.md", "Easy to use download manager using Curl/Aria2 and ytdl to allow downloading HTTP(S), FTP(S), YouTube videos and BitTorrent files. For more information on how to install, please go to https://github.com/e-alfred/ncdownloader/blob/master/README.md" : "易用的下载管理器使用Curl/Aria2和youtube-dl工具来下载HTTP(S)、FTP(S)、YouTube视频和BitTorrent文件。关于如何安装的更多信息请访问 https://github.com/e-alfred/ncdownloader/blob/master/README.md",
"Active Downloads" : "活动的下载任务", "Active Downloads" : "活动的下载任务",
" using <strong>%s</strong>" : "正在使用<strong>%s</strong>", " using <strong>%s</strong>" : "正在使用<strong>%s</strong>",
"FILENAME" : "文件名", "FILENAME" : "文件名",

View File

@@ -1,10 +1,11 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Aria2;
//use Symfony\Component\Process\ExecutableFinder; //use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use OCA\NCDownloader\Tools\Helper;
class Aria2 class Aria2
{ {

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Aria2;
class aria2Options class Options
{ {
public static function get() public static function get()

View File

@@ -2,7 +2,7 @@
namespace OCA\NCDownloader\Command; namespace OCA\NCDownloader\Command;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OC\Core\Command\Base; use OC\Core\Command\Base;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;

View File

@@ -1,9 +1,9 @@
<?php <?php
namespace OCA\NCDownloader\Controller; namespace OCA\NCDownloader\Controller;
use OCA\NCDownloader\Tools\Aria2; use OCA\NCDownloader\Aria2\Aria2;
use OCA\NCDownloader\Tools\Counters; use OCA\NCDownloader\Tools\Counters;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
use OCA\NCDownloader\Tools\folderScan; use OCA\NCDownloader\Tools\folderScan;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;

View File

@@ -2,13 +2,13 @@
namespace OCA\NCDownloader\Controller; namespace OCA\NCDownloader\Controller;
use OCA\NCDownloader\Tools\Aria2; use OCA\NCDownloader\Aria2\Aria2;
use OCA\NCDownloader\Tools\Counters; use OCA\NCDownloader\Tools\Counters;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
use OCA\NCDownloader\Tools\folderScan; use OCA\NCDownloader\Tools\folderScan;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
use OCA\NCDownloader\Tools\Youtube; use OCA\NCDownloader\Ytdl\Ytdl;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
@@ -26,7 +26,7 @@ class MainController extends Controller
private $aria2Opts; private $aria2Opts;
private $l10n; private $l10n;
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube) public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{ {
parent::__construct($appName, $request); parent::__construct($appName, $request);
@@ -39,7 +39,7 @@ class MainController extends Controller
$this->urlGenerator = \OC::$server->getURLGenerator(); $this->urlGenerator = \OC::$server->getURLGenerator();
$this->dbconn = new DbHelper(); $this->dbconn = new DbHelper();
$this->counters = new Counters($aria2, $this->dbconn, $UserId); $this->counters = new Counters($aria2, $this->dbconn, $UserId);
$this->youtube = $youtube; $this->ytdl = $ytdl;
$this->isAdmin = \OC_User::isAdminUser($this->uid); $this->isAdmin = \OC_User::isAdminUser($this->uid);
$this->hideError = Helper::getSettings("ncd_hide_errors", false); $this->hideError = Helper::getSettings("ncd_hide_errors", false);
$this->disable_bt_nonadmin = Helper::getSettings("ncd_disable_bt", false, Settings::TYPE["SYSTEM"]); $this->disable_bt_nonadmin = Helper::getSettings("ncd_disable_bt", false, Settings::TYPE["SYSTEM"]);
@@ -67,9 +67,9 @@ class MainController extends Controller
$params['aria2_installed'] = $aria2_installed = $this->aria2->isInstalled(); $params['aria2_installed'] = $aria2_installed = $this->aria2->isInstalled();
$params['aria2_bin'] = $aria2_bin = $this->aria2->getBin(); $params['aria2_bin'] = $aria2_bin = $this->aria2->getBin();
$params['aria2_executable'] = $aria2_executable = $this->aria2->isExecutable(); $params['aria2_executable'] = $aria2_executable = $this->aria2->isExecutable();
$params['youtube_installed'] = $youtube_installed = $this->youtube->isInstalled(); $params['ytdlinstalled'] = $ytdlinstalled = $this->ytdl->isInstalled();
$params['youtube_bin'] = $youtube_bin = $this->youtube->getBin(); $params['ytdlbin'] = $ytdlbin = $this->ytdl->getBin();
$params['youtube_executable'] = $youtube_executable = $this->youtube->isExecutable(); $params['ytdlexecutable'] = $ytdlexecutable = $this->ytdl->isExecutable();
$params['ncd_hide_errors'] = $this->hideError; $params['ncd_hide_errors'] = $this->hideError;
$params['counter'] = $this->counters->getCounters(); $params['counter'] = $this->counters->getCounters();
$params['python_installed'] = Helper::pythonInstalled(); $params['python_installed'] = Helper::pythonInstalled();
@@ -92,8 +92,8 @@ class MainController extends Controller
$this->aria2->start(); $this->aria2->start();
} }
} }
if ($youtube_installed && (!$youtube_executable || !@is_readable($youtube_bin))) { if ($ytdlinstalled && (!$ytdlexecutable || !@is_readable($ytdlbin))) {
array_push($errors, sprintf("youtube-dl is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $youtube_bin)); array_push($errors, sprintf("ytdl is installed but don't have the right permissions.Please execute command sudo chmod 755 %s", $ytdlbin));
} }
foreach ($params as $key => $value) { foreach ($params as $key => $value) {

View File

@@ -3,7 +3,7 @@
namespace OCA\NCDownloader\Controller; namespace OCA\NCDownloader\Controller;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest; use OCP\IRequest;
@@ -101,33 +101,33 @@ class SettingsController extends Controller
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired
*/ */
public function youtubeGet() public function ytdlGet()
{ {
$data = json_decode($this->settings->get("custom_youtube_dl_settings")); $data = json_decode($this->settings->get("custom_ytdl_settings"));
return new JSONResponse($data); return new JSONResponse($data);
} }
public function youtubeSave() public function ytdlSave()
{ {
$params = $this->request->getParams(); $params = $this->request->getParams();
$data = array_filter($params, function ($key) { $data = array_filter($params, function ($key) {
return (bool) (!in_array(substr($key, 0, 1), ['_'])); return (bool) (!in_array(substr($key, 0, 1), ['_']));
}, ARRAY_FILTER_USE_KEY); }, ARRAY_FILTER_USE_KEY);
$resp = $this->settings->save("custom_youtube_dl_settings", json_encode($data)); $resp = $this->settings->save("custom_ytdl_settings", json_encode($data));
return new JSONResponse($resp); return new JSONResponse($resp);
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired
*/ */
public function youtubeDelete() public function ytdlDelete()
{ {
$saved = json_decode($this->settings->get("custom_youtube_dl_settings"), 1); $saved = json_decode($this->settings->get("custom_ytdl_settings"), 1);
$params = $this->request->getParams(); $params = $this->request->getParams();
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
unset($saved[$key]); unset($saved[$key]);
} }
$resp = $this->settings->save("custom_youtube_dl_settings", json_encode($saved)); $resp = $this->settings->save("custom_ytdl_settings", json_encode($saved));
return new JSONResponse($resp); return new JSONResponse($resp);
} }
public function save($key, $value) public function save($key, $value)

View File

@@ -1,23 +1,23 @@
<?php <?php
namespace OCA\NCDownloader\Controller; namespace OCA\NCDownloader\Controller;
use OCA\NCDownloader\Tools\Aria2; use OCA\NCDownloader\Aria2\Aria2;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
use OCA\NCDownloader\Tools\folderScan; use OCA\NCDownloader\Tools\folderScan;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\Youtube; use OCA\NCDownloader\Ytdl\Ytdl;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\IL10N; use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
class YoutubeController extends Controller class YtdlController extends Controller
{ {
//@config OC\AppConfig //@config OC\AppConfig
private $l10n; private $l10n;
private $audio_extensions = array("mp3", "m4a", "vorbis"); private $audio_extensions = array("mp3", "m4a", "vorbis");
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube) public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Ytdl $ytdl)
{ {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->appName = $appName; $this->appName = $appName;
@@ -26,7 +26,7 @@ class YoutubeController extends Controller
$this->l10n = $IL10N; $this->l10n = $IL10N;
$this->downloadDir = Helper::getDownloadDir(); $this->downloadDir = Helper::getDownloadDir();
$this->dbconn = new DbHelper(); $this->dbconn = new DbHelper();
$this->youtube = $youtube; $this->ytdl = $ytdl;
$this->aria2 = $aria2; $this->aria2 = $aria2;
$this->aria2->init(); $this->aria2->init();
$this->tablename = $this->dbconn->queryBuilder->getTableName("ncdownloader_info"); $this->tablename = $this->dbconn->queryBuilder->getTableName("ncdownloader_info");
@@ -37,7 +37,7 @@ class YoutubeController extends Controller
*/ */
public function Index() public function Index()
{ {
$data = $this->dbconn->getYoutubeByUid($this->uid); $data = $this->dbconn->getYtdlByUid($this->uid);
if (is_array($data) && count($data) < 1) { if (is_array($data) && count($data) < 1) {
return []; return [];
} }
@@ -54,9 +54,9 @@ class YoutubeController extends Controller
$tmp['speed'] = explode("|", $value['speed']); $tmp['speed'] = explode("|", $value['speed']);
$tmp['progress'] = $value['progress']; $tmp['progress'] = $value['progress'];
$path = $this->urlGenerator->linkToRoute('ncdownloader.Youtube.Delete'); $path = $this->urlGenerator->linkToRoute('ncdownloader.Ytdl.Delete');
$tmp['actions'][] = ['name' => 'delete', 'path' => $path]; $tmp['actions'][] = ['name' => 'delete', 'path' => $path];
$path = $this->urlGenerator->linkToRoute('ncdownloader.Youtube.Redownload'); $path = $this->urlGenerator->linkToRoute('ncdownloader.Ytdl.Redownload');
$tmp['actions'][] = ['name' => 'refresh', 'path' => $path]; $tmp['actions'][] = ['name' => 'refresh', 'path' => $path];
$tmp['data_gid'] = $value['gid'] ?? 0; $tmp['data_gid'] = $value['gid'] ?? 0;
@@ -64,7 +64,7 @@ class YoutubeController extends Controller
} }
$resp['title'] = ['filename', 'speed', 'progress', 'actions']; $resp['title'] = ['filename', 'speed', 'progress', 'actions'];
$resp['counter'] = ['youtube-dl' => count($data)]; $resp['counter'] = ['ytdl' => count($data)];
folderScan::sync(); folderScan::sync();
return new JSONResponse($resp); return new JSONResponse($resp);
} }
@@ -74,12 +74,12 @@ class YoutubeController extends Controller
*/ */
public function Download() public function Download()
{ {
$dlDir = $this->youtube->getDownloadDir(); $dlDir = $this->ytdl->getDownloadDir();
if (!is_writable($dlDir)) { if (!is_writable($dlDir)) {
return new JSONResponse(['error' => sprintf("%s is not writable", $dlDir)]); return new JSONResponse(['error' => sprintf("%s is not writable", $dlDir)]);
} }
$url = trim($this->request->getParam('text-input-value')); $url = trim($this->request->getParam('text-input-value'));
$yt = $this->youtube; $yt = $this->ytdl;
if (in_array($this->request->getParam('extension'), $this->audio_extensions)) { if (in_array($this->request->getParam('extension'), $this->audio_extensions)) {
$yt->audioOnly = true; $yt->audioOnly = true;
$yt->audioFormat = $this->request->getParam('extension'); $yt->audioFormat = $this->request->getParam('extension');
@@ -87,7 +87,7 @@ class YoutubeController extends Controller
$yt->videoFormat = $this->request->getParam('extension'); $yt->videoFormat = $this->request->getParam('extension');
} }
if (!$yt->isInstalled()) { if (!$yt->isInstalled()) {
return new JSONResponse(["error" => "Please install the latest youtube-dl or make the bundled binary file executable in ncdownloader/bin"]); return new JSONResponse(["error" => "Please install the latest yt-dlp or make the bundled binary file executable in ncdownloader/bin"]);
} }
if (Helper::isGetUrlSite($url)) { if (Helper::isGetUrlSite($url)) {
return new JSONResponse($this->downloadUrlSite($url)); return new JSONResponse($this->downloadUrlSite($url));
@@ -99,7 +99,7 @@ class YoutubeController extends Controller
} }
private function downloadUrlSite($url) private function downloadUrlSite($url)
{ {
$yt = $this->youtube; $yt = $this->ytdl;
if ($data = $yt->forceIPV4()->getDownloadUrl($url)) { if ($data = $yt->forceIPV4()->getDownloadUrl($url)) {
return $this->_download($data['url'], $data['filename']); return $this->_download($data['url'], $data['filename']);
} else { } else {
@@ -157,16 +157,16 @@ class YoutubeController extends Controller
if (!empty($data['link'])) { if (!empty($data['link'])) {
if (isset($data['ext'])) { if (isset($data['ext'])) {
if (in_array($data['ext'], $this->audio_extensions)) { if (in_array($data['ext'], $this->audio_extensions)) {
$this->youtube->audioOnly = true; $this->ytdl->audioOnly = true;
$this->youtube->audioFormat = $data['ext']; $this->ytdl->audioFormat = $data['ext'];
} else { } else {
$this->youtube->audioOnly = false; $this->ytdl->audioOnly = false;
$this->youtube->videoFormat = $data['ext']; $this->ytdl->videoFormat = $data['ext'];
} }
} }
//$this->dbconn->deleteByGid($gid); //$this->dbconn->deleteByGid($gid);
$this->youtube->dbDlPath = Helper::getDownloadDir(); $this->ytdl->dbDlPath = Helper::getDownloadDir();
$resp = $this->youtube->forceIPV4()->download($data['link']); $resp = $this->ytdl->forceIPV4()->download($data['link']);
folderScan::sync(); folderScan::sync();
return new JSONResponse($resp); return new JSONResponse($resp);
} }

View File

@@ -1,7 +1,8 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Db;
use OCA\NCDownloader\Tools\Helper as ToolsHelper;
class DbHelper class Helper
{ {
//@var OC\DB\ConnectionAdapter //@var OC\DB\ConnectionAdapter
private $conn; private $conn;
@@ -13,7 +14,7 @@ class DbHelper
$this->queryBuilder = $this->conn->getQueryBuilder(); $this->queryBuilder = $this->conn->getQueryBuilder();
$this->prefixedTable = $this->queryBuilder->getTableName($this->table); $this->prefixedTable = $this->queryBuilder->getTableName($this->table);
//$container = \OC::$server->query(\OCP\IServerContainer::class); //$container = \OC::$server->query(\OCP\IServerContainer::class);
//Helper::debug(get_class($container->query(\OCP\RichObjectStrings\IValidator::class))); //ToolsHelper::debug(get_class($container->query(\OCP\RichObjectStrings\IValidator::class)));
//$this->conn = \OC::$server->query(Connection::class);//working only with 22 //$this->conn = \OC::$server->query(Connection::class);//working only with 22
//$this->connAdapter = \OC::$server->getDatabaseConnection(); //$this->connAdapter = \OC::$server->getDatabaseConnection();
//$this->conn = $this->connAdapter->getInner(); //$this->conn = $this->connAdapter->getInner();
@@ -58,7 +59,7 @@ class DbHelper
return $queryBuilder->fetchColumn(); return $queryBuilder->fetchColumn();
} }
public function getYoutubeByUid($uid) public function getYtdlByUid($uid)
{ {
$qb = $this->queryBuilder $qb = $this->queryBuilder
->select('*') ->select('*')
@@ -66,7 +67,7 @@ class DbHelper
->where('uid = :uid') ->where('uid = :uid')
->andWhere('type = :type') ->andWhere('type = :type')
->setParameter('uid', $uid) ->setParameter('uid', $uid)
->setParameter('type', Helper::DOWNLOADTYPE['YOUTUBE-DL']) ->setParameter('type', ToolsHelper::DOWNLOADTYPE['YOUTUBE-DL'])
->orderBy('id', 'DESC') ->orderBy('id', 'DESC')
->execute(); ->execute();
return $qb->fetchAll(); return $qb->fetchAll();

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Db;
use OC\AllConfig; use OC\AllConfig;
@@ -60,9 +60,9 @@ class Settings extends AllConfig
return json_decode($settings, 1); return json_decode($settings, 1);
} }
public function getYoutube() public function getYtdl()
{ {
$settings = $this->get("custom_youtube_dl_settings"); $settings = $this->get("custom_ytdl_settings");
return json_decode($settings, 1); return json_decode($settings, 1);
} }
public function getAll() public function getAll()

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\http;
//require __DIR__ . "/../../vendor/autoload.php"; //require __DIR__ . "/../../vendor/autoload.php";
use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\HttpClient;

View File

@@ -7,7 +7,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
class Admin implements ISettings { class Admin implements ISettings {

View File

@@ -7,7 +7,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
class Personal implements ISettings { class Personal implements ISettings {

View File

@@ -2,8 +2,8 @@
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Tools;
use OCA\NCDownloader\Tools\Aria2; use OCA\NCDownloader\Aria2\Aria2;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
class Counters class Counters
{ {
@@ -22,13 +22,13 @@ class Counters
'waiting' => $this->getCounter('tellWaiting'), 'waiting' => $this->getCounter('tellWaiting'),
'complete' => $this->getCounter('tellStopped'), 'complete' => $this->getCounter('tellStopped'),
'fail' => $this->getCounter('tellFail'), 'fail' => $this->getCounter('tellFail'),
'youtube-dl' => $this->getCounter('youtube-dl'), 'ytdl' => $this->getCounter('ytdl'),
]; ];
} }
private function getCounter($action = 'tellActive') private function getCounter($action = 'tellActive')
{ {
if ($action === 'youtube-dl') { if ($action === 'ytdl') {
$data = $this->dbconn->getYoutubeByUid($this->uid); $data = $this->dbconn->getYtdlByUid($this->uid);
} else if ($action === 'tellActive') { } else if ($action === 'tellActive') {
$data = $this->aria2->{$action}([]); $data = $this->aria2->{$action}([]);
} else { } else {
@@ -38,7 +38,7 @@ class Counters
if (!is_array($data) && count($data) < 1) { if (!is_array($data) && count($data) < 1) {
return 0; return 0;
} }
if ($action !== 'youtube-dl') { if ($action !== 'ytdl') {
$data = $this->filterData($data); $data = $this->filterData($data);
} }
return count($data); return count($data);

View File

@@ -4,8 +4,8 @@ namespace OCA\NCDownloader\Tools;
use Exception; use Exception;
use OCA\NCDownloader\Search\Sites\searchInterface; use OCA\NCDownloader\Search\Sites\searchInterface;
use OCA\NCDownloader\Tools\aria2Options; use OCA\NCDownloader\Aria2\Options as aria2Options;
use OCA\NCDownloader\Tools\Settings; use OCA\NCDownloader\Db\Settings;
use OCP\IUser; use OCP\IUser;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC_Util; use OC_Util;
@@ -108,7 +108,7 @@ class Helper
public static function isYoutubeType($url) public static function isYoutubeType($url)
{ {
$regex = '%^(?:(?:https?)://)(?:[a-z0-9_]*\.)?(?:twitter|youtube)\.com/%i'; $regex = '%^(?:(?:https?)://)(?:[a-z0-9_]*\.)?(?:twitter|ytdl)\.com/%i';
return (bool) preg_match($regex, $url); return (bool) preg_match($regex, $url);
} }
@@ -435,12 +435,12 @@ class Helper
return Settings::create($uid); return Settings::create($uid);
} }
public static function getYoutubeConfig($uid = null): array public static function getYtdlConfig($uid = null): array
{ {
$config = [ $config = [
'binary' => self::getSettings("ncd_yt_binary", null, Settings::TYPE['SYSTEM']), 'binary' => self::getSettings("ncd_yt_binary", null, Settings::TYPE['SYSTEM']),
'downloadDir' => Helper::getRealDownloadDir(), 'downloadDir' => Helper::getRealDownloadDir(),
'settings' => self::newSettings()->getYoutube(), 'settings' => self::newSettings()->getYtdl(),
]; ];
return $config; return $config;
} }

View File

@@ -1,10 +1,10 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Ytdl;
use OCA\NCDownloader\Tools\DbHelper; use OCA\NCDownloader\Db\Helper as DbHelper;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper as ToolsHelper;
class YoutubeHelper class Helper
{ {
public $file = null; public $file = null;
protected $pid = 0; protected $pid = 0;
@@ -67,7 +67,7 @@ class YoutubeHelper
} }
public function log($message) public function log($message)
{ {
Helper::debug($message); ToolsHelper::debug($message);
} }
public function updateStatus($status = null) public function updateStatus($status = null)
{ {
@@ -84,10 +84,10 @@ class YoutubeHelper
{ {
$info = $this->getSiteInfo($buffer); $info = $this->getSiteInfo($buffer);
if (isset($info["id"])) { if (isset($info["id"])) {
$this->gid = Helper::generateGID($info["id"]); $this->gid = ToolsHelper::generateGID($info["id"]);
} }
if (!$this->gid) { if (!$this->gid) {
$this->gid = Helper::generateGID($extra["link"]); $this->gid = ToolsHelper::generateGID($extra["link"]);
} }
$downloadInfo = $this->getDownloadInfo($buffer); $downloadInfo = $this->getDownloadInfo($buffer);
if ($downloadInfo) { if ($downloadInfo) {
@@ -116,9 +116,9 @@ class YoutubeHelper
$data = [ $data = [
'uid' => $this->user, 'uid' => $this->user,
'gid' => $this->gid, 'gid' => $this->gid,
'type' => Helper::DOWNLOADTYPE['YOUTUBE-DL'], 'type' => ToolsHelper::DOWNLOADTYPE['YOUTUBE-DL'],
'filename' => basename($file), 'filename' => basename($file),
'status' => Helper::STATUS['ACTIVE'], 'status' => ToolsHelper::STATUS['ACTIVE'],
'timestamp' => time(), 'timestamp' => time(),
'data' => $extra, 'data' => $extra,
]; ];

View File

@@ -1,7 +1,7 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Ytdl;
class youtubedlOptions class Options
{ {
public static function get() public static function get()
@@ -65,7 +65,7 @@ class youtubedlOptions
'http-chunk-size' => 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). May be useful for', 'http-chunk-size' => 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). May be useful for',
'playlist-reverse' => 'playlist videos in reverse order', 'playlist-reverse' => 'playlist videos in reverse order',
'playlist-random' => 'playlist videos in random order', 'playlist-random' => 'playlist videos in random order',
'xattr-set-filesize' => 'file xattribute ytdl.filesize with expected file size', 'xattr-set-filesize' => 'file xattribute youtube-dl.filesize with expected file size',
'hls-prefer-native' => 'the native HLS downloader instead of ffmpeg', 'hls-prefer-native' => 'the native HLS downloader instead of ffmpeg',
'hls-prefer-ffmpeg' => 'ffmpeg instead of the native HLS downloader', 'hls-prefer-ffmpeg' => 'ffmpeg instead of the native HLS downloader',
'hls-use-mpegts' => 'the mpegts container for HLS videos; allowing some players to play the video while downloading, and reducing the', 'hls-use-mpegts' => 'the mpegts container for HLS videos; allowing some players to play the video while downloading, and reducing the',
@@ -130,7 +130,7 @@ class youtubedlOptions
'all-formats' => 'all available video formats', 'all-formats' => 'all available video formats',
'prefer-free-formats' => 'video formats with free containers over non-free ones of same quality. Use with "-S ext" to strictly prefer', 'prefer-free-formats' => 'video formats with free containers over non-free ones of same quality. Use with "-S ext" to strictly prefer',
'list-formats' => 'available formats of each video. Simulate unless --no-simulate is used', 'list-formats' => 'available formats of each video. Simulate unless --no-simulate is used',
'youtube-skip-dash-manifest' => 'not download the DASH manifests and related data on YouTube videos', 'youtube-dl-skip-dash-manifest' => 'not download the DASH manifests and related data on YouTube videos',
'merge-output-format' => 'If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm,', 'merge-output-format' => 'If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm,',
'write-sub' => 'subtitle file', 'write-sub' => 'subtitle file',
'write-auto-sub' => 'automatically generated subtitle file (YouTube only)', 'write-auto-sub' => 'automatically generated subtitle file (YouTube only)',
@@ -173,7 +173,7 @@ class youtubedlOptions
'no-live-from-start' => 'livestreams from the current time (default)', 'no-live-from-start' => 'livestreams from the current time (default)',
'no-wait-for-video' => 'not wait for scheduled streams (default)', 'no-wait-for-video' => 'not wait for scheduled streams (default)',
'no-colors' => 'not emit color codes in output', 'no-colors' => 'not emit color codes in output',
'compat-options' => 'Options that can help keep compatibility with youtube-dl or youtube-dlc configurations by reverting some of the', 'compat-options' => 'Options that can help keep compatibility with youtube-dl or youtube-dl-dlc configurations by reverting some of the',
'no-match-filter' => 'not use generic video filter (default)', 'no-match-filter' => 'not use generic video filter (default)',
'no-download-archive' => 'not use archive file (default)', 'no-download-archive' => 'not use archive file (default)',
'break-on-existing' => 'the download process when encountering a file that is in the archive', 'break-on-existing' => 'the download process when encountering a file that is in the archive',

View File

@@ -1,12 +1,12 @@
<?php <?php
namespace OCA\NCDownloader\Tools; namespace OCA\NCDownloader\Ytdl;
use OCA\NCDownloader\Tools\Helper; use OCA\NCDownloader\Tools\Helper;
use OCA\NCDownloader\Tools\YoutubeHelper; use OCA\NCDownloader\Ytdl\Helper as YtdHelper;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
class Youtube class Ytdl
{ {
public $audioOnly = 0; public $audioOnly = 0;
public $audioFormat = 'm4a', $videoFormat = null; public $audioFormat = 'm4a', $videoFormat = null;
@@ -32,7 +32,7 @@ class Youtube
if (isset($binary) && $this->isExecutable($binary)) { if (isset($binary) && $this->isExecutable($binary)) {
$this->bin = $binary; $this->bin = $binary;
} else { } else {
$this->bin = __DIR__ . "/../../bin/yt-dlp"; //Helper::findBinaryPath('youtube-dl', __DIR__ . "/../../bin/yt-dlp"); $this->bin = __DIR__ . "/../../bin/yt-dlp"; //Helper::findBinaryPath('ytdl', __DIR__ . "/../../bin/yt-dlp");
} }
if ($this->isInstalled() && !$this->isExecutable()) { if ($this->isInstalled() && !$this->isExecutable()) {
chmod($this->bin, 0744); chmod($this->bin, 0744);
@@ -138,7 +138,7 @@ class Youtube
$this->setOption('--format', $this->format); $this->setOption('--format', $this->format);
} }
} }
$this->helper = YoutubeHelper::create(); $this->helper = YtdHelper::create();
$this->downloadDir = $this->downloadDir ?? $this->defaultDir; $this->downloadDir = $this->downloadDir ?? $this->defaultDir;
$this->setOption("--output", $this->downloadDir . "/" . $this->outTpl); $this->setOption("--output", $this->downloadDir . "/" . $this->outTpl);
$this->setUrl($url); $this->setUrl($url);

View File

@@ -43,7 +43,7 @@ export default {
return { return {
display: { download: true, search: false }, display: { download: true, search: false },
uris: { uris: {
ytd_url: helper.generateUrl("/apps/ncdownloader/youtube/new"), ytd_url: helper.generateUrl("/apps/ncdownloader/ytdl/new"),
aria2_url: helper.generateUrl("/apps/ncdownloader/new"), aria2_url: helper.generateUrl("/apps/ncdownloader/new"),
search_url: helper.generateUrl("/apps/ncdownloader/search"), search_url: helper.generateUrl("/apps/ncdownloader/search"),
upload_url: helper.generateUrl("/apps/ncdownloader/upload"), upload_url: helper.generateUrl("/apps/ncdownloader/upload"),
@@ -62,15 +62,15 @@ export default {
helper.error(t("ncdownloader", inputValue + " is Invalid")); helper.error(t("ncdownloader", inputValue + " is Invalid"));
return; return;
} }
if (formData.type === "youtube-dl") { if (formData.type === "ytdl") {
formData["extension"] = ""; formData["extension"] = "";
if (formData["select-value-extension"] !== "defaultext") { if (formData["select-value-extension"] !== "defaultext") {
formData["extension"] = formData["select-value-extension"]; formData["extension"] = formData["select-value-extension"];
} }
message = helper.t("Download task started!"); message = helper.t("Download task started!");
helper.pollingYoutube(); helper.pollingYtdl();
helper.setContentTableType("youtube-dl-downloads"); helper.setContentTableType("ytdl-downloads");
} else { } else {
helper.polling(); helper.polling();
helper.setContentTableType("active-downloads"); helper.setContentTableType("active-downloads");

View File

@@ -17,11 +17,11 @@ export default {
} }
helper.setContentTableType(name); helper.setContentTableType(name);
let delay; let delay;
if (!['active-downloads', 'youtube-dl-downloads'].includes(name)) { if (!['active-downloads', 'ytdl-downloads'].includes(name)) {
delay = 15000; delay = 15000;
} }
if (name === "youtube-dl-downloads") { if (name === "ytdl-downloads") {
helper.pollingYoutube(); helper.pollingYtdl();
} else { } else {
helper.polling(delay, path); helper.polling(delay, path);
} }

View File

@@ -8,8 +8,8 @@
HTTP/MAGNET HTTP/MAGNET
</div> </div>
<div <div
class="youtube-dl-link option-buttons" class="ytdl-link option-buttons"
@click.prevent="whichType('youtube-dl', $event)" @click.prevent="whichType('ytdl', $event)"
> >
Youtube-dl Youtube-dl
</div> </div>
@@ -100,13 +100,13 @@ export default {
this.downloadType = type; this.downloadType = type;
if (type === "aria2") { if (type === "aria2") {
this.path = this.uris.aria2_url; this.path = this.uris.aria2_url;
} else if (type === "youtube-dl") { } else if (type === "ytdl") {
this.placeholder = t("ncdownloader", "Paste your video link here"); this.placeholder = t("ncdownloader", "Paste your video link here");
this.path = this.uris.ytd_url; this.path = this.uris.ytd_url;
} else { } else {
this.path = this.uris.search_url; this.path = this.uris.search_url;
} }
this.checkboxes = type === "youtube-dl" ? true : false; this.checkboxes = type === "ytdl" ? true : false;
this.inputType = type === "search" ? "search" : "download"; this.inputType = type === "search" ? "search" : "download";
}, },
download(event) { download(event) {
@@ -219,7 +219,7 @@ export default {
border-radius: 15px 0px 0px 15px; border-radius: 15px 0px 0px 15px;
} }
.youtube-dl-link { .ytdl-link {
background-color: #b8b8ca; background-color: #b8b8ca;
} }
.search-torrents { .search-torrents {
@@ -227,7 +227,7 @@ export default {
} }
.search-torrents, .search-torrents,
.youtube-dl-link, .ytdl-link,
.magnet-link, .magnet-link,
.choose-file { .choose-file {
color: #181616; color: #181616;

View File

@@ -88,7 +88,7 @@
flex: 1 1 0; flex: 1 1 0;
} }
} }
#ncdownloader-table-wrapper.youtube-dl-downloads { #ncdownloader-table-wrapper.ytdl-downloads {
#table-cell-speed, #table-cell-speed,
.table-heading-speed { .table-heading-speed {

View File

@@ -7,7 +7,7 @@ import settingsForm from './lib/settingsForm'
import autoComplete from './lib/autoComplete'; import autoComplete from './lib/autoComplete';
import eventHandler from './lib/eventHandler'; import eventHandler from './lib/eventHandler';
import aria2Options from './utils/aria2Options'; import aria2Options from './utils/aria2Options';
import { options as ytdFullOptions, names as ytdOptions } from './utils/youtubedlOptions'; import { options as ytdlFullOptions, names as ytdlOptions } from './utils/ytdlOptions';
import helper from './utils/helper'; import helper from './utils/helper';
import './css/autoComplete.css' import './css/autoComplete.css'
import './css/settings.scss' import './css/settings.scss'
@@ -26,9 +26,9 @@ window.addEventListener('DOMContentLoaded', function () {
OC_msg.startSaving('#ncdownloader-message-banner'); OC_msg.startSaving('#ncdownloader-message-banner');
helper.makePair(data, name); helper.makePair(data, name);
let badOptions = []; let badOptions = [];
if (name === 'youtube-dl-settings') { if (name === 'ytdl-settings') {
for (let key in data) { for (let key in data) {
if (!ytdOptions.includes(key) && !customOptions.includes(key)) { if (!ytdlOptions.includes(key) && !customOptions.includes(key)) {
delete data[key]; delete data[key];
badOptions.push(key) badOptions.push(key)
} }
@@ -105,10 +105,10 @@ window.addEventListener('DOMContentLoaded', function () {
eventHandler.add('click', '.ncdownloader-admin-settings', 'input[type="button"]', (e) => saveHandler(e)); eventHandler.add('click', '.ncdownloader-admin-settings', 'input[type="button"]', (e) => saveHandler(e));
eventHandler.add('click', '.ncdownloader-personal-settings', 'input[type="button"]', (e) => saveHandler(e)); eventHandler.add('click', '.ncdownloader-personal-settings', 'input[type="button"]', (e) => saveHandler(e));
eventHandler.add("click", "#custom-aria2-settings-container", "button.save-custom-aria2-settings", (e) => saveHandler(e)) eventHandler.add("click", "#custom-aria2-settings-container", "button.save-custom-aria2-settings", (e) => saveHandler(e))
eventHandler.add("click", "#custom-youtube-dl-settings-container", "button.save-custom-youtube-dl-settings", (e) => saveHandler(e, 'youtube-dl-settings')) eventHandler.add("click", "#custom-ytdl-settings-container", "button.save-custom-ytdl-settings", (e) => saveHandler(e, 'ytdl-settings'))
eventHandler.add('click', '#custom-aria2-settings-container', "button.add-custom-aria2-settings", (e) => addOption(e, 'aria2', aria2Options)) eventHandler.add('click', '#custom-aria2-settings-container', "button.add-custom-aria2-settings", (e) => addOption(e, 'aria2', aria2Options))
eventHandler.add('click', '#custom-youtube-dl-settings-container', "button.add-custom-youtube-dl-settings", (e) => addOption(e, 'youtube-dl', ytdFullOptions)) eventHandler.add('click', '#custom-ytdl-settings-container', "button.add-custom-ytdl-settings", (e) => addOption(e, 'ytdl', ytdlFullOptions))
eventHandler.add('click', '.ncdownloader-personal-settings', 'button.icon-close', function (e) { eventHandler.add('click', '.ncdownloader-personal-settings', 'button.icon-close', function (e) {
@@ -128,7 +128,7 @@ window.addEventListener('DOMContentLoaded', function () {
settingsForm.getInstance().render(input); settingsForm.getInstance().render(input);
}).send(); }).send();
helper.httpClient(generateUrl("/apps/ncdownloader/personal/youtube-dl/get")).setHandler(function (data) { helper.httpClient(generateUrl("/apps/ncdownloader/personal/ytdl/get")).setHandler(function (data) {
if (!data) { if (!data) {
return; return;
} }
@@ -136,7 +136,7 @@ window.addEventListener('DOMContentLoaded', function () {
for (let key in data) { for (let key in data) {
input.push({ name: key, value: data[key], id: key }); input.push({ name: key, value: data[key], id: key });
} }
settingsForm.getInstance().setParent("custom-youtube-dl-settings-container").render(input); settingsForm.getInstance().setParent("custom-ytdl-settings-container").render(input);
}).send(); }).send();
const filepicker = function (event) { const filepicker = function (event) {

View File

@@ -42,8 +42,8 @@ const helper = {
pollingFolder(delay = 1500) { pollingFolder(delay = 1500) {
Polling.create().setDelay(delay).run(helper.scanFolder); Polling.create().setDelay(delay).run(helper.scanFolder);
}, },
pollingYoutube(delay = 1500) { pollingYtdl(delay = 1500) {
Polling.create().setDelay(delay).run(helper.refresh, "/apps/ncdownloader/youtube/get"); Polling.create().setDelay(delay).run(helper.refresh, "/apps/ncdownloader/ytdl/get");
}, },
refresh(path) { refresh(path) {
path = path || "/apps/ncdownloader/status/active"; path = path || "/apps/ncdownloader/status/active";

File diff suppressed because one or more lines are too long

3
src/utils/ytdlOptions.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@ $downloadsList = [
["name" => "waiting", "label" => "Waiting Downloads", "id" => "waiting-downloads", "path" => "/apps/ncdownloader/status/waiting"], ["name" => "waiting", "label" => "Waiting Downloads", "id" => "waiting-downloads", "path" => "/apps/ncdownloader/status/waiting"],
["name" => "fail", "label" => "Failed Downloads", "id" => "failed-downloads", "path" => "/apps/ncdownloader/status/fail"], ["name" => "fail", "label" => "Failed Downloads", "id" => "failed-downloads", "path" => "/apps/ncdownloader/status/fail"],
["name" => "complete", "label" => "Complete Downloads", "id" => "complete-downloads", "path" => "/apps/ncdownloader/status/complete"], ["name" => "complete", "label" => "Complete Downloads", "id" => "complete-downloads", "path" => "/apps/ncdownloader/status/complete"],
["name" => "youtube-dl", "label" => "Youtube-dl Downloads", "id" => "youtube-dl-downloads", "path" => "/apps/ncdownloader/youtube/get"], ["name" => "ytdl", "label" => "Youtube-dl Downloads", "id" => "ytdl-downloads", "path" => "/apps/ncdownloader/ytdl/get"],
]; ];
?> ?>
<div id="app-navigation"> <div id="app-navigation">

View File

@@ -21,8 +21,8 @@ extract($_);
<?php print($l->t('Youtube-dl Binary Path'));?> <?php print($l->t('Youtube-dl Binary Path'));?>
</label> </label>
<input type="text" class="ncd_yt_binary" id="ncd_yt_binary" name="ncd_yt_binary" <input type="text" class="ncd_yt_binary" id="ncd_yt_binary" name="ncd_yt_binary"
value="<?php print($ncd_yt_binary ?? '/usr/local/bin/youtube-dl');?>" value="<?php print($ncd_yt_binary ?? '/usr/local/bin/ytdl');?>"
placeholder='/usr/local/bin/youtube-dl' /> placeholder='/usr/local/bin/ytdl' />
<input type="button" value="<?php print($l->t('Save'));?>" data-rel="ncd_yt_binary_container" /> <input type="button" value="<?php print($l->t('Save'));?>" data-rel="ncd_yt_binary_container" />
</div> </div>
<div id="ncd_aria2_binary_container" path="<?php print $path;?>"> <div id="ncd_aria2_binary_container" path="<?php print $path;?>">

View File

@@ -74,17 +74,17 @@ $time_map = array('i' => 'minutes', 'h' => 'hours', 'w' => 'weeks', 'd' => 'days
</button> </button>
</div> </div>
</div> </div>
<div class="ncdownloader-youtube-dl-settings"> <div class="ncdownloader-ytdl-settings">
<h3 class="title"> <h3 class="title">
<?php print($l->t('Custom Youtube-dl Settings'));?> <?php print($l->t('Custom Youtube-dl Settings'));?>
</h3> </h3>
<div classs="section" id="custom-youtube-dl-settings-container" <div classs="section" id="custom-ytdl-settings-container"
path="/apps/ncdownloader/personal/youtube-dl/save"> path="/apps/ncdownloader/personal/ytdl/save">
<button class="add-custom-youtube-dl-settings"> <button class="add-custom-ytdl-settings">
<?php print $l->t('Add Options');?> <?php print $l->t('Add Options');?>
</button> </button>
<button class="save-custom-youtube-dl-settings" data-tippy-content='' <button class="save-custom-ytdl-settings" data-tippy-content=''
data-rel="custom-youtube-dl-settings-container"> data-rel="custom-ytdl-settings-container">
<?php print $l->t('Save');?> <?php print $l->t('Save');?>
</button> </button>
</div> </div>