mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-19 13:10:16 +08:00
Refactor video thumbnail generation logic
Moved video thumbnail generation to occur before custom thumbnail copying, ensuring fallback to default thumbnail only if video info retrieval fails. Also reordered rkeyManager URLs for consistency.
This commit is contained in:
parent
aa6699d06e
commit
7ab44dcb34
@ -42,8 +42,8 @@ export class NTQQFileApi {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
this.rkeyManager = new RkeyManager([
|
this.rkeyManager = new RkeyManager([
|
||||||
'https://secret-service.bietiaop.com/rkeys',
|
|
||||||
'http://ss.xingzhige.com/music_card/rkey',
|
'http://ss.xingzhige.com/music_card/rkey',
|
||||||
|
'https://secret-service.bietiaop.com/rkeys',
|
||||||
],
|
],
|
||||||
this.context.logger
|
this.context.logger
|
||||||
);
|
);
|
||||||
@ -260,13 +260,6 @@ export class NTQQFileApi {
|
|||||||
const thumbDir = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`);
|
const thumbDir = path.replace(`${pathLib.sep}Ori${pathLib.sep}`, `${pathLib.sep}Thumb${pathLib.sep}`);
|
||||||
fs.mkdirSync(pathLib.dirname(thumbDir), { recursive: true });
|
fs.mkdirSync(pathLib.dirname(thumbDir), { recursive: true });
|
||||||
const thumbPath = pathLib.join(pathLib.dirname(thumbDir), `${md5}_0.png`);
|
const thumbPath = pathLib.join(pathLib.dirname(thumbDir), `${md5}_0.png`);
|
||||||
if (_diyThumbPath) {
|
|
||||||
try {
|
|
||||||
await this.copyFile(_diyThumbPath, thumbPath);
|
|
||||||
} catch (e) {
|
|
||||||
this.context.logger.logError('复制自定义缩略图失败', e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
videoInfo = await FFmpegService.getVideoInfo(filePath, thumbPath);
|
videoInfo = await FFmpegService.getVideoInfo(filePath, thumbPath);
|
||||||
if (!fs.existsSync(thumbPath)) {
|
if (!fs.existsSync(thumbPath)) {
|
||||||
@ -277,6 +270,12 @@ export class NTQQFileApi {
|
|||||||
this.context.logger.logError('获取视频信息失败', e);
|
this.context.logger.logError('获取视频信息失败', e);
|
||||||
fs.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64'));
|
fs.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64'));
|
||||||
}
|
}
|
||||||
|
if (_diyThumbPath) {
|
||||||
|
try {
|
||||||
|
await this.copyFile(_diyThumbPath, thumbPath);
|
||||||
|
} catch (e) {
|
||||||
|
this.context.logger.logError('复制自定义缩略图失败', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
context.deleteAfterSentFiles.push(thumbPath);
|
context.deleteAfterSentFiles.push(thumbPath);
|
||||||
const thumbSize = (await fsPromises.stat(thumbPath)).size;
|
const thumbSize = (await fsPromises.stat(thumbPath)).size;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user