From df4f42e79e2950cb20903488712505840bae9d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 13 Sep 2024 17:38:11 +0800 Subject: [PATCH] fix: video name --- src/core/apis/file.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 3d457720..586532f3 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -147,7 +147,7 @@ export class NTQQFileApi { } catch (e) { logger.logError('获取视频信息失败,将使用默认值', e); } - + let fileExt = 'mp4'; try { const tempExt = (await fileType.fileTypeFromFile(filePath))?.ext; @@ -155,7 +155,7 @@ export class NTQQFileApi { } catch (e) { this.context.logger.logError('获取文件类型失败', e); } - const newFilePath = filePath + '.'+fileExt; + const newFilePath = filePath + '.' + fileExt; fs.copyFileSync(filePath, newFilePath); context.deleteAfterSentFiles.push(newFilePath); filePath = newFilePath; @@ -197,11 +197,12 @@ export class NTQQFileApi { thumbPath.set(0, _thumbPath); const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : ''; context.deleteAfterSentFiles.push(path); + const uploadName = (fileName || _fileName).toLocaleLowerCase().endsWith('.' + fileExt.toLocaleLowerCase()) ? (fileName || _fileName) : (fileName || _fileName) + '.' + fileExt; return { elementType: ElementType.VIDEO, elementId: '', videoElement: { - fileName: (fileName || _fileName).replace(/\.[^/.]+$/, '.mp4'), + fileName: uploadName, filePath: path, videoMd5: md5, thumbMd5,