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

View File

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

View File

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

View File

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