From b32971a55f4fa6ee4c1b8b683bed317396bad739 Mon Sep 17 00:00:00 2001 From: benson Date: Mon, 1 May 2023 13:53:38 +0800 Subject: [PATCH] added section for displaying aria2 and yt-dlp version info --- lib/Aria2/Aria2.php | 4 +++ lib/Settings/Personal.php | 2 ++ lib/Tools/Helper.php | 13 +++++++ lib/Ytdl/Ytdl.php | 10 ++++++ src/personalSettings.vue | 72 +++++++++++++++++++++++++-------------- 5 files changed, 76 insertions(+), 25 deletions(-) diff --git a/lib/Aria2/Aria2.php b/lib/Aria2/Aria2.php index 9b7849c..4624ac5 100644 --- a/lib/Aria2/Aria2.php +++ b/lib/Aria2/Aria2.php @@ -412,4 +412,8 @@ class Aria2 { return $this->bin; } + public function version(){ + $resp = $this->getVersion(); + return $resp['result']['version'] ?? null; + } } diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 51686cd..1ff13ed 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -49,6 +49,8 @@ class Personal implements ISettings "path" => '/apps/ncdownloader/personal/save', "disallow_aria2_settings" => Helper::getAdminSettings("disallow_aria2_settings"), "is_admin" => \OC_User::isAdminUser($this->uid), + "aria2_version" => Helper::getAria2Version(), + "ytdl_version" => Helper::getYtdlVersion(), ] ]; diff --git a/lib/Tools/Helper.php b/lib/Tools/Helper.php index 907ec53..06fda5c 100644 --- a/lib/Tools/Helper.php +++ b/lib/Tools/Helper.php @@ -10,6 +10,8 @@ use OCP\IUser; use OC\Files\Filesystem; use OC_Util; use Psr\Log\LoggerInterface; +use OCA\NCDownloader\Aria2\Aria2; +use OCA\NCDownloader\Ytdl\Ytdl; class Helper { @@ -537,4 +539,15 @@ class Helper { return Helper::getSettings("ncd_admin_settings", [], Settings::TYPE["SYSTEM"]); } + public static function getAria2Version(): ?string + { + //get aria2 instance + $aria2 = self::query(Aria2::class); + return $aria2->version(); + } + public static function getYtdlVersion(): ?string + { + $ytdl = self::query(Ytdl::class); + return $ytdl->version(); + } } diff --git a/lib/Ytdl/Ytdl.php b/lib/Ytdl/Ytdl.php index 9385055..f142a87 100644 --- a/lib/Ytdl/Ytdl.php +++ b/lib/Ytdl/Ytdl.php @@ -265,4 +265,14 @@ class Ytdl { return "https://github.com/shiningw/ncdownloader-bin/raw/master/yt-dlp"; } + + public function version() + { + $process = new Process([$this->bin, '--version']); + $process->run(); + if ($process->isSuccessful()) { + return $process->getOutput(); + } + return false; + } } diff --git a/src/personalSettings.vue b/src/personalSettings.vue index 4eb298a..ec607a1 100644 --- a/src/personalSettings.vue +++ b/src/personalSettings.vue @@ -1,36 +1,30 @@ + \ No newline at end of file