added aria2 start hook script to update file without a proper name;increased filename column to 50%;fixed minor issue in ripping audio

This commit is contained in:
huangjx
2021-10-11 22:09:29 +08:00
parent 871af03f7d
commit 0a492e9db9
7 changed files with 28 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
<summary>Aria2 and youtube-dl web gui for nextcloud</summary>
<description>built-in torrent search;Start and stop Aria2 process, manage Aria2 from the web;
Download videos from youtube, twitter and other sites;</description>
<version>0.2.5</version>
<version>0.2.8</version>
<licence>agpl</licence>
<author mail="freefallbenson@gmail.com" homepage="https://github.com/shiningw">jiaxinhuang</author>
<namespace>NCDownloader</namespace>

1
img/refresh.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13.5 2c-5.621 0-10.211 4.443-10.475 10h-3.025l5 6.625 5-6.625h-2.975c.257-3.351 3.06-6 6.475-6 3.584 0 6.5 2.916 6.5 6.5s-2.916 6.5-6.5 6.5c-1.863 0-3.542-.793-4.728-2.053l-2.427 3.216c1.877 1.754 4.389 2.837 7.155 2.837 5.79 0 10.5-4.71 10.5-10.5s-4.71-10.5-10.5-10.5z"/></svg>

After

Width:  |  Height:  |  Size: 371 B

View File

@@ -56,7 +56,11 @@ class Aria2Command extends base
$this->dbconn->updateStatus($gid, Helper::STATUS[$status]);
}
if ($action === 'start') {
//Helper::log("$gid started");
if ($path = $input->getArgument('path')) {
$filename = basename($path);
$this->dbconn->updateFilename($gid,$filename);
}
}
return 1;
}

View File

@@ -50,6 +50,7 @@ class Aria2
}
$this->php = Helper::findBinaryPath('php');
$this->completeHook = $completeHook;
$this->startHook = $startHook;
$this->rpcUrl = sprintf("http://%s:%s/jsonrpc", $host, $port);
$this->tokenString = $token ?? 'ncdownloader123';
$this->setToken($this->tokenString);
@@ -311,6 +312,7 @@ class Aria2
'--max-concurrent-downloads=10',
'--check-certificate=false',
'--on-download-complete=' . $this->completeHook,
'--on-download-start=' . $this->startHook,
];
}
public function start($bin = null)

View File

@@ -112,4 +112,16 @@ class DBConn
//$this->execute($sql, [$status, $gid]);
}
public function updateFilename($gid, $filename)
{
$query = $this->queryBuilder;
$query->update($this->table)
->set("filename", $query->createNamedParameter($filename))
->where('gid = :gid')
->andWhere('filename = :filename')
->setParameter('gid', $gid)
->setParameter('filename', 'unknown');
return $query->execute();
}
}

View File

@@ -61,11 +61,11 @@ class Youtube
$this->addOption('--prefer-ffmpeg');
$this->addOption('--add-metadata');
$this->addOption('--metadata-from-title');
$this->addOption("%(artist)s - %(title)s");
$this->audioFormat = 'mp3';
}
$this->setAudioFormat($this->audioFormat);
$this->addOption("%(artist)s-%(title)s");
$this->addOption('--extract-audio');
}
$this->outTpl = "/%(id)s-%(title)s.m4a";
$this->setAudioFormat($this->audioFormat);
return $this;
}
@@ -76,7 +76,7 @@ class Youtube
public function setAudioFormat($format)
{
$this->setOption('--audio-format',$format);
$this->setOption('--audio-format', $format);
}
public function setvideoFormat($format)
@@ -136,10 +136,8 @@ class Youtube
{
if ($this->audioOnly) {
$this->audioMode();
$this->outTpl = "/%(id)s-%(title)s." . $this->audioFormat;
} else {
$this->addOption('--format');
$this->addOption($this->format);
$this->setOption('--format',$this->format);
}
$this->helper = YoutubeHelper::create();
$this->downloadDir = $this->downloadDir ?? $this->defaultDir;
@@ -148,7 +146,7 @@ class Youtube
$this->setUrl($url);
$this->prependOption($this->bin);
$process = new Process($this->options, null, $this->env);
//\OC::$server->getLogger()->error($process->getCommandLine(), ['app' => 'PHP']);
//\OC::$server->getLogger()->error($process->getWorkingDirectory(), ['app' => 'PHP']);
$process->setTimeout($this->timeout);
$process->run(function ($type, $buffer) use ($url) {
if (Process::ERR === $type) {

View File

@@ -52,7 +52,7 @@
.table-cell:first-child {
flex : 1 1 auto;
width : 30%;
width : 50%;
overflow : hidden;
text-overflow: ellipsis;
white-space : nowrap;