Move LoadAllAudioFiles function to the right file
This commit is contained in:
parent
25f68b6c89
commit
e7f6ba8f35
|
@ -7,7 +7,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -15,7 +14,6 @@ import (
|
|||
|
||||
"github.com/deluan/navidrome/conf"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/utils"
|
||||
)
|
||||
|
||||
type Metadata struct {
|
||||
|
@ -51,35 +49,6 @@ func (m *Metadata) FilePath() string { return m.filePath }
|
|||
func (m *Metadata) Suffix() string { return m.suffix }
|
||||
func (m *Metadata) Size() int64 { return m.fileInfo.Size() }
|
||||
|
||||
func LoadAllAudioFiles(dirPath string) (map[string]os.FileInfo, error) {
|
||||
dir, err := os.Open(dirPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
files, err := dir.Readdir(-1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
audioFiles := make(map[string]os.FileInfo)
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(dirPath, f.Name())
|
||||
if !utils.IsAudioFile(filePath) {
|
||||
continue
|
||||
}
|
||||
fi, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
log.Error("Could not stat file", "filePath", filePath, err)
|
||||
} else {
|
||||
audioFiles[filePath] = fi
|
||||
}
|
||||
}
|
||||
|
||||
return audioFiles, nil
|
||||
}
|
||||
|
||||
func ExtractAllMetadata(inputs []string) (map[string]*Metadata, error) {
|
||||
args := createProbeCommand(inputs)
|
||||
|
||||
|
|
|
@ -442,3 +442,32 @@ func (s *TagScanner) artistID(md *Metadata) string {
|
|||
func (s *TagScanner) albumArtistID(md *Metadata) string {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(strings.ToLower(s.mapAlbumArtistName(md)))))
|
||||
}
|
||||
|
||||
func LoadAllAudioFiles(dirPath string) (map[string]os.FileInfo, error) {
|
||||
dir, err := os.Open(dirPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
files, err := dir.Readdir(-1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
audioFiles := make(map[string]os.FileInfo)
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
filePath := filepath.Join(dirPath, f.Name())
|
||||
if !utils.IsAudioFile(filePath) {
|
||||
continue
|
||||
}
|
||||
fi, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
log.Error("Could not stat file", "filePath", filePath, err)
|
||||
} else {
|
||||
audioFiles[filePath] = fi
|
||||
}
|
||||
}
|
||||
|
||||
return audioFiles, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue