This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"butterfliu/config"
|
||||
"butterfliu/internal/model"
|
||||
"butterfliu/internal/repository"
|
||||
"butterfliu/internal/scanner"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -23,7 +20,7 @@ type ScanReport struct {
|
||||
}
|
||||
|
||||
type LibraryService struct {
|
||||
libRepo *repository.LibraryRepository
|
||||
libRepo *repository.LibraryRepository
|
||||
artistRepo *repository.ArtistRepository
|
||||
albumRepo *repository.AlbumRepository
|
||||
songRepo *repository.SongRepository
|
||||
@@ -169,18 +166,6 @@ func (s *LibraryService) GetAlbum(id int) (model.AlbumDetail, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *LibraryService) GetAlbumCover(id int) (string, error) {
|
||||
songs, err := s.albumRepo.GetSongIDs(id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(songs) == 0 {
|
||||
return "", errors.New("no songs found for album")
|
||||
}
|
||||
conf := config.LoadConfig()
|
||||
return path.Join(conf.GetCachePath("cover"), strconv.Itoa(songs[0])+".jpg"), nil
|
||||
}
|
||||
|
||||
func (s *LibraryService) Scan(id int) (*ScanReport, error) {
|
||||
lib, err := s.libRepo.GetByID(id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user