save download path in database

This commit is contained in:
huangjx
2022-05-12 22:42:41 +08:00
parent cab95529dd
commit 02fb165405
7 changed files with 21 additions and 10 deletions

View File

@@ -192,8 +192,9 @@ class Aria2Controller extends Controller
//internal nextcloud absolute path for nodeExists
//$file = $this->userFolder . $this->downloadDir . "/" . $filename;
// $dir = $this->rootFolder->nodeExists($file) ? $this->downloadDir . "/" . $filename : $this->downloadDir;
$file = $this->downloadDir . "/" . $filename;
$params = ['dir' => $this->downloadDir];
$dlDir = $extra['path'] ?? $this->downloadDir;
$file = $dlDir. "/" . $filename;
$params = ['dir' => $dlDir];
$fileInfo = Filesystem::getFileInfo($file);
if ($fileInfo) {
$fileType = $fileInfo->getType();

View File

@@ -158,7 +158,7 @@ class MainController extends Controller
'type' => Helper::DOWNLOADTYPE['ARIA2'],
'filename' => empty($filename) ? "unknown" : $filename,
'timestamp' => time(),
'data' => serialize(['link' => $url]),
'data' => serialize(['link' => $url,'path' => Helper::getDownloadDir()]),
];
$this->dbconn->save($data);
$resp = ['message' => $filename, 'result' => $result, 'file' => $filename];

View File

@@ -43,7 +43,7 @@ class YoutubeController extends Controller
}
$resp['title'] = [];
$resp['row'] = [];
$params = ['dir' => $this->downloadDir];
$params = ['dir' => $data['path'] ?? $this->downloadDir];
$folderLink = $this->urlGenerator->linkToRoute('files.view.index', $params);
foreach ($data as $value) {
$tmp = [];
@@ -92,7 +92,7 @@ class YoutubeController extends Controller
if (Helper::isGetUrlSite($url)) {
return new JSONResponse($this->downloadUrlSite($url));
}
$yt->dbDlPath = Helper::getDownloadDir();
$resp = $yt->forceIPV4()->download($url);
folderScan::sync();
return new JSONResponse($resp);
@@ -165,6 +165,7 @@ class YoutubeController extends Controller
}
}
//$this->dbconn->deleteByGid($gid);
$this->youtube->dbDlPath = Helper::getDownloadDir();
$resp = $this->youtube->forceIPV4()->download($data['link']);
folderScan::sync();
return new JSONResponse($resp);

View File

@@ -9,6 +9,8 @@ class Youtube
{
public $audioOnly = 0;
public $audioFormat = 'm4a', $videoFormat = null;
//path in nextcloud fs
public $dbDlPath = null;
private $format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best';
private $options = [];
private $downloadDir;
@@ -142,7 +144,7 @@ class Youtube
$this->prependOption($this->bin);
$process = new Process($this->options, null, $this->env);
$process->setTimeout($this->timeout);
$data = ['link' => $url];
$data = ['link' => $url,'path' => $this->dbDlPath];
if ($this->audioOnly) {
$data['ext'] = $this->audioFormat;
} else {