mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-07 02:43:17 +03:00
Move LoadAllAudioFiles function to the right file
This commit is contained in:
parent
25f68b6c89
commit
e7f6ba8f35
@ -7,7 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -15,7 +14,6 @@ import (
|
|||||||
|
|
||||||
"github.com/deluan/navidrome/conf"
|
"github.com/deluan/navidrome/conf"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
"github.com/deluan/navidrome/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Metadata struct {
|
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) Suffix() string { return m.suffix }
|
||||||
func (m *Metadata) Size() int64 { return m.fileInfo.Size() }
|
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) {
|
func ExtractAllMetadata(inputs []string) (map[string]*Metadata, error) {
|
||||||
args := createProbeCommand(inputs)
|
args := createProbeCommand(inputs)
|
||||||
|
|
||||||
|
@ -442,3 +442,32 @@ func (s *TagScanner) artistID(md *Metadata) string {
|
|||||||
func (s *TagScanner) albumArtistID(md *Metadata) string {
|
func (s *TagScanner) albumArtistID(md *Metadata) string {
|
||||||
return fmt.Sprintf("%x", md5.Sum([]byte(strings.ToLower(s.mapAlbumArtistName(md)))))
|
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…
x
Reference in New Issue
Block a user