feat(core): 添加PSD/PSB图片格式支持并重构媒体文件处理
- 新增ReadPsdImage函数支持PSD/PSB格式图片信息读取 - 修改文件扫描逻辑,将视频处理改为媒体候选处理,使用ffprobe统一判定 - 添加对PSB格式的支持,与PSD共享相同8BPS文件头处理 - 重构handle_image.go中的图片处理逻辑,优化错误处理和记录保存 - 更新文件扫描过滤规则,支持更多图片格式并跳过数据库文件 - 添加文件MD5计算功能用于文件唯一性标识 - 修改媒体处理流程,支持音频文件识别和分类处理 - 移除废弃的视频时长转换函数和相关依赖 - 更新依赖版本并添加SQLite支持用于媒体信息存储
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"kenaito-media-picker/store"
|
||||
"kenaito-media-picker/util"
|
||||
"kenaito-media-picker/vars"
|
||||
"os"
|
||||
)
|
||||
|
||||
// saveMediaRecord 计算MD5并将媒体信息写入数据库
|
||||
func saveMediaRecord(filePath string, mediaType string, width int, height int, duration float64, codec string, format string, rawInfo string) {
|
||||
md5Str, err := util.CalcFileMd5(filePath)
|
||||
if err != nil {
|
||||
fmt.Printf("=== 计算MD5失败: %s, 错误: %v\n", filePath, err)
|
||||
return
|
||||
}
|
||||
info := &store.MediaInfo{
|
||||
FileMd5: md5Str,
|
||||
FilePath: filePath,
|
||||
FileName: vars.GlobalFilePath2FileNameMap[filePath],
|
||||
FileExt: vars.GlobalFilePath2FileExtMap[filePath],
|
||||
MimeType: vars.GlobalFilePath2MimeInfoMap[filePath],
|
||||
MediaType: mediaType,
|
||||
Width: width,
|
||||
Height: height,
|
||||
Duration: duration,
|
||||
Codec: codec,
|
||||
Format: format,
|
||||
RawInfo: rawInfo,
|
||||
}
|
||||
if st, err := os.Stat(filePath); err == nil {
|
||||
info.FileSize = st.Size()
|
||||
}
|
||||
if err := store.SaveMedia(info); err != nil {
|
||||
fmt.Printf("=== 保存媒体信息失败: %s, 错误: %v\n", filePath, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user