first commit

This commit is contained in:
2026-04-09 01:42:37 +02:00
commit 75ae131e2a
7 changed files with 1055 additions and 0 deletions

34
scanner.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"os"
"path/filepath"
"strings"
)
func findFiles(config Config) ([]string, error) {
var musicFiles []string
walkFunc := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() && path != config.SourceDir && !config.Recursion {
return filepath.SkipDir
}
ext := strings.ToLower(filepath.Ext(path))
if ext == ".mp3" || ext == ".m4a" || ext == ".flac" || ext == ".wav" {
musicFiles = append(musicFiles, path)
}
return nil
}
if err := filepath.Walk(config.SourceDir, walkFunc); err != nil {
return nil, err
}
return musicFiles, nil
}