diff --git a/appinfo/info.xml b/appinfo/info.xml
index efac726..aa7fdee 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,7 +5,7 @@
Aria2 and youtube-dl web gui for nextcloud
built-in torrent search;Start and stop Aria2 process, manage Aria2 from the web;
Download videos from youtube, twitter and other sites;
- 0.0.3
+ 0.0.4
agpl
jiaxinhuang
NCDownloader
diff --git a/lib/Controller/Aria2Controller.php b/lib/Controller/Aria2Controller.php
index 471f633..c8852a2 100644
--- a/lib/Controller/Aria2Controller.php
+++ b/lib/Controller/Aria2Controller.php
@@ -54,14 +54,10 @@ class Aria2Controller extends Controller
case "start":
$resp = $this->Start();
break;
- case "pause":
- $resp = $this->doAction('pause', $gid);
- break;
- case "remove":
- $resp = $this->doAction('remove', $gid);
- break;
case "unpause":
- $resp = $this->doAction('unpause', $gid);
+ case "remove":
+ case "pause":
+ $resp = $this->doAction($path, $gid);
break;
case "get":
$resp = $this->doAction('tellStatus', $gid);
diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php
index c202081..f0693cf 100644
--- a/lib/Tools/Youtube.php
+++ b/lib/Tools/Youtube.php
@@ -16,6 +16,7 @@ class Youtube
private $timeout = 60 * 60 * 15;
private $outTpl = "/%(id)s-%(title)s.%(ext)s";
private $defaultDir = "/tmp/downloads";
+ private $env = [];
public function __construct($config)
{
@@ -23,14 +24,21 @@ class Youtube
$this->bin = Helper::findBinaryPath('youtube-dl');
$this->init();
$this->setDownloadDir($config['downloadDir']);
- $this->helper = YoutubeHelper::create();
}
-
public function init()
{
+ if (empty($lang = getenv('LANG')) || strpos(strtolower($lang), 'utf-8') === false) {
+ $lang = 'C.UTF-8';
+ }
+ $this->setEnv('LANG', $lang);
$this->addOption("--no-mtime");
}
+ public function setEnv($key, $val)
+ {
+ $this->env[$key] = $val;
+ }
+
public function GetUrlOnly()
{
$this->addOption('--get-filename');
@@ -66,7 +74,7 @@ class Youtube
$this->setUrl($url);
$this->prependOption($this->bin);
// $this->buildCMD();
- $process = new Process($this->options);
+ $process = new Process($this->options, null, $this->env);
//the maximum time required to download the file
$process->setTimeout($this->timeout);
try {
@@ -81,12 +89,13 @@ class Youtube
public function download($url)
{
+ $this->helper = YoutubeHelper::create();
$this->downloadDir = $this->downloadDir ?? $this->defaultDir;
$this->prependOption($this->downloadDir . $this->outTpl);
$this->prependOption("-o");
$this->setUrl($url);
$this->prependOption($this->bin);
- $process = new Process($this->options);
+ $process = new Process($this->options, null, $this->env);
$process->setTimeout($this->timeout);
$process->run(function ($type, $buffer) use ($url) {
if (Process::ERR === $type) {
diff --git a/lib/Tools/YoutubeHelper.php b/lib/Tools/YoutubeHelper.php
index 6d4dc5f..8fa2975 100644
--- a/lib/Tools/YoutubeHelper.php
+++ b/lib/Tools/YoutubeHelper.php
@@ -29,7 +29,7 @@ class YoutubeHelper
}
public function getFilePath($output)
{
- $rules = '#\[download\]\s+Destination:\s+(?.*\.(?(mp4|mp3|aac)))$#i';
+ $rules = '#\[download\]\s+Destination:\s+(?.*\.(?(mp4|mp3|aac|webm|m4a|ogg)))$#i';
preg_match($rules, $output, $matches);