feat(core): 添加PSD/PSB图片格式支持并重构媒体文件处理
- 新增ReadPsdImage函数支持PSD/PSB格式图片信息读取 - 修改文件扫描逻辑,将视频处理改为媒体候选处理,使用ffprobe统一判定 - 添加对PSB格式的支持,与PSD共享相同8BPS文件头处理 - 重构handle_image.go中的图片处理逻辑,优化错误处理和记录保存 - 更新文件扫描过滤规则,支持更多图片格式并跳过数据库文件 - 添加文件MD5计算功能用于文件唯一性标识 - 修改媒体处理流程,支持音频文件识别和分类处理 - 移除废弃的视频时长转换函数和相关依赖 - 更新依赖版本并添加SQLite支持用于媒体信息存储
This commit is contained in:
+11
-15
@@ -3,6 +3,7 @@ package core
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/redmask-hb/GoSimplePrint/goPrint"
|
||||
"kenaito-media-picker/store"
|
||||
"kenaito-media-picker/util"
|
||||
"kenaito-media-picker/vars"
|
||||
"log"
|
||||
@@ -55,29 +56,21 @@ func (FileScanner) DoFilter() {
|
||||
for _, globalFilePath := range vars.GlobalFilePathList {
|
||||
fileMime := vars.GlobalFilePath2MimeInfoMap[globalFilePath]
|
||||
count = count + 1
|
||||
if strings.Contains(fileMime, "video/") { // 视频
|
||||
vars.GlobalVideoPathList = append(vars.GlobalVideoPathList, globalFilePath)
|
||||
bar.PrintBar(util.CalcPercentage(count, total))
|
||||
continue
|
||||
}
|
||||
// mime格式为application/octet-stream的视频
|
||||
// 图片
|
||||
ext := path.Ext(globalFilePath)
|
||||
if util.IsSupportVideo(ext) {
|
||||
vars.GlobalVideoPathList = append(vars.GlobalVideoPathList, globalFilePath)
|
||||
bar.PrintBar(util.CalcPercentage(count, total))
|
||||
continue
|
||||
}
|
||||
if strings.Contains(fileMime, "image/") { // 图片
|
||||
if strings.Contains(fileMime, "image/") || util.IsSupportImage(ext) || strings.EqualFold(ext, ".psd") {
|
||||
vars.GlobalImagePathList = append(vars.GlobalImagePathList, globalFilePath)
|
||||
bar.PrintBar(util.CalcPercentage(count, total))
|
||||
continue
|
||||
}
|
||||
if util.IsSupportImage(ext) {
|
||||
vars.GlobalImagePathList = append(vars.GlobalImagePathList, globalFilePath)
|
||||
// 其余作为媒体候选,由ffprobe最终判定(视频/音频/不支持),
|
||||
// 只要ffmpeg支持的格式都会被识别,不再依赖扩展名白名单
|
||||
if util.IsPotentialMedia(fileMime) {
|
||||
vars.GlobalMediaPathList = append(vars.GlobalMediaPathList, globalFilePath)
|
||||
bar.PrintBar(util.CalcPercentage(count, total))
|
||||
continue
|
||||
}
|
||||
// 其他的文件不处理
|
||||
// 明显的非媒体文件(代码/文档/压缩包等)直接不处理
|
||||
}
|
||||
bar.PrintEnd("=== Finish")
|
||||
}
|
||||
@@ -91,6 +84,9 @@ func visit(currentPath string, info os.FileInfo, err error) error {
|
||||
return filepath.SkipDir // 跳过白名单目录(已整理文件的输出目录)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
if filepath.Base(currentPath) == store.DBFileName {
|
||||
return nil // 跳过媒体信息数据库文件
|
||||
}
|
||||
vars.GlobalFilePathList = append(vars.GlobalFilePathList, currentPath)
|
||||
// filename, include ext
|
||||
vars.GlobalFilePath2FileNameMap[currentPath] = filepath.Base(currentPath)
|
||||
|
||||
Reference in New Issue
Block a user