提取cover服务
All checks were successful
Go CI / test-and-build (push) Successful in 11s

This commit is contained in:
2026-04-08 20:44:04 +08:00
parent 55c017f60d
commit 4bc160284d
6 changed files with 88 additions and 60 deletions

View File

@@ -1,12 +1,8 @@
package service
import (
"butterfliu/config"
"butterfliu/internal/model"
"butterfliu/internal/repository"
"butterfliu/internal/util"
"path"
"strconv"
)
type SongService struct {
@@ -37,13 +33,3 @@ func (s *SongService) GetMediaFile(id int) (model.MediaFile, error) {
}
return s.mediaRepo.Get(song.MediaFileID)
}
func (s *SongService) GetCover(id int) (string, error) {
file, err := s.GetMediaFile(id)
if err != nil {
return "", err
}
util.ExtractCover(file.Path, id)
conf := config.LoadConfig()
return path.Join(conf.GetCachePath("cover"), strconv.Itoa(id)+".jpg"), nil
}