This commit is contained in:
huangjx
2022-04-27 23:09:47 +08:00
parent acd9470a4b
commit 32b6484596
4 changed files with 9 additions and 8 deletions

View File

@@ -155,7 +155,7 @@ class MainController extends Controller
'uid' => $this->uid, 'uid' => $this->uid,
'gid' => $result, 'gid' => $result,
'type' => Helper::DOWNLOADTYPE['ARIA2'], 'type' => Helper::DOWNLOADTYPE['ARIA2'],
'filename' => $filename ?? 'unknown', 'filename' => empty($filename) ? "unknown" : $filename,
'timestamp' => time(), 'timestamp' => time(),
'data' => serialize(['link' => $url]), 'data' => serialize(['link' => $url]),
]; ];
@@ -202,7 +202,7 @@ class MainController extends Controller
*/ */
public function scanFolder() public function scanFolder()
{ {
$resp = folderScan::create()->scan(); $resp = folderScan::sync();
return new JSONResponse($resp); return new JSONResponse($resp);
} }
/** /**

View File

@@ -13,8 +13,6 @@ use OCP\IRequest;
class YoutubeController extends Controller class YoutubeController extends Controller
{ {
private $userId;
private $settings = null;
//@config OC\AppConfig //@config OC\AppConfig
private $l10n; private $l10n;
private $audio_extensions = array("mp3", "m4a", "vorbis"); private $audio_extensions = array("mp3", "m4a", "vorbis");
@@ -67,6 +65,7 @@ class YoutubeController extends Controller
$resp['title'] = ['filename', 'speed', 'progress', 'actions']; $resp['title'] = ['filename', 'speed', 'progress', 'actions'];
$resp['counter'] = ['youtube-dl' => count($data)]; $resp['counter'] = ['youtube-dl' => count($data)];
folderScan::sync();
return new JSONResponse($resp); return new JSONResponse($resp);
} }
/** /**

View File

@@ -70,14 +70,15 @@ class Helper
} }
return $filename; return $filename;
} }
public static function getFilename($url) public static function getFilename($url): string
{ {
if (self::isMagnet($url)) { if (self::isMagnet($url)) {
$filename = self::parseUrl($url)['dn']; $info = self::parseUrl($url);
$filename = $info["dn"] ?? "";
} else { } else {
$filename = self::getUrlPath($url); $filename = self::getUrlPath($url);
} }
return substr($filename, 0, self::MAXFILELEN); return self::clipFilename($filename);
} }
public static function formatBytes($size, $precision = 2) public static function formatBytes($size, $precision = 2)
{ {
@@ -483,6 +484,7 @@ class Helper
return false; return false;
} }
$checkFile = $dir . "/.lastmodified"; $checkFile = $dir . "/.lastmodified";
if (!file_exists($checkFile)) { if (!file_exists($checkFile)) {
$time = \filemtime($dir); $time = \filemtime($dir);
file_put_contents($checkFile, $time); file_put_contents($checkFile, $time);

View File

@@ -14,7 +14,7 @@ class folderScan
{ {
$this->user = $user ?? Helper::getUID(); $this->user = $user ?? Helper::getUID();
$this->path = $path ?? $this->getDefaultPath(); $this->path = $path ?? $this->getDefaultPath();
$this->realDir = $realDir ?? Helper::getLocalFolder($this->path); $this->realDir = Helper::getLocalFolder(Helper::getDownloadDir());
} }
public function getDefaultPath() public function getDefaultPath()