Compare commits

..

2 Commits

Author SHA1 Message Date
d9590651b2 skip unsupported files 2026-04-07 20:53:18 +02:00
fcba178b26 added nix outputs to gitignore 2026-04-07 20:53:00 +02:00
3 changed files with 19 additions and 0 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
/result
/outputs

View File

@@ -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

View File

@@ -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 {