Skip to content

Commit

Permalink
fix: video name
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Sep 13, 2024
1 parent 5f80058 commit df4f42e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/apis/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ export class NTQQFileApi {
} catch (e) {
logger.logError('获取视频信息失败,将使用默认值', e);
}

let fileExt = 'mp4';
try {
const tempExt = (await fileType.fileTypeFromFile(filePath))?.ext;
if (tempExt) fileExt = tempExt;
} 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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit df4f42e

Please sign in to comment.