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:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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->addOption("%(artist)s-%(title)s");
|
||||
$this->addOption('--extract-audio');
|
||||
}
|
||||
$this->outTpl = "/%(id)s-%(title)s.m4a";
|
||||
$this->setAudioFormat($this->audioFormat);
|
||||
$this->addOption('--extract-audio');
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user