Compare commits
2 Commits
187546b750
...
d9590651b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
d9590651b2
|
|||
|
fcba178b26
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/result
|
||||
/outputs
|
||||
|
||||
@@ -42,7 +42,12 @@ func Sort(dst, path string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Handle single file
|
||||
if !info.IsDir() {
|
||||
if !fileSupported(path) {
|
||||
slog.Error("Unsupported file format", "file", path)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := sortSong(path, dst); err != nil {
|
||||
slog.Error("Failed to sort single file", "file", path, "err", err)
|
||||
os.Exit(1)
|
||||
@@ -50,6 +55,7 @@ func Sort(dst, path string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Handle directory
|
||||
err = filepath.WalkDir(path, func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
slog.Error("Failed to walk path", "path", path, "file", p, "err", err)
|
||||
@@ -57,6 +63,9 @@ func Sort(dst, path string) {
|
||||
}
|
||||
|
||||
if !d.IsDir() {
|
||||
if !fileSupported(p) {
|
||||
return nil
|
||||
}
|
||||
if err := sortSong(p, dst); err != nil {
|
||||
slog.Error("Failed to sort file", "file", p, "err", err)
|
||||
return err
|
||||
|
||||
@@ -9,6 +9,15 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func fileSupported(file string) bool {
|
||||
supported := map[string]bool{
|
||||
".mp3": true, ".flac": true,
|
||||
".m4a": true, ".ogg": true, ".dsf": true,
|
||||
}
|
||||
|
||||
return supported[strings.ToLower(filepath.Ext(file))]
|
||||
}
|
||||
|
||||
func sortSong(src, dst string) error {
|
||||
m, err := ReadAudioTags(src)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user