added section for displaying aria2 and yt-dlp version info

This commit is contained in:
benson
2023-05-01 13:53:38 +08:00
parent 16e1fd47a8
commit b32971a55f
5 changed files with 76 additions and 25 deletions

View File

@@ -412,4 +412,8 @@ class Aria2
{
return $this->bin;
}
public function version(){
$resp = $this->getVersion();
return $resp['result']['version'] ?? null;
}
}

View File

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

View File

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

View File

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