update metadata tags when sorting

This commit is contained in:
2026-04-15 16:03:59 +02:00
parent b4e3f2f372
commit a92b632234
6 changed files with 149 additions and 43 deletions

View File

@@ -6,30 +6,25 @@ import (
"log/slog"
"os"
"path/filepath"
"git.kapelle.org/niklas/ripsort/internal/metadata"
)
func Scan(filePath string) {
info, err := ReadAudioTags(filePath)
info, err := metadata.ReadAudioTags(filePath)
if err != nil {
slog.Error("Reading metadata", "file", filePath, "err", err)
os.Exit(1)
}
fmt.Printf("Format: %v\n", info.Format)
fmt.Printf("File Type: %v\n", info.FileType)
fmt.Printf("Title: %s\n", info.Title)
fmt.Printf("Artist: %s\n", info.Artist)
fmt.Printf("Album: %s\n", info.Album)
fmt.Printf("Album Artist: %s\n", info.AlbumArtist)
fmt.Printf("Composer: %s\n", info.Composer)
fmt.Printf("Genre: %s\n", info.Genre)
fmt.Printf("Year: %d\n", info.Year)
fmt.Printf("Track: %d/%d\n", info.Track, info.TotalTracks)
fmt.Printf("Disc: %d/%d\n", info.Disc, info.TotalDiscs)
fmt.Printf("Lyrics: %s\n", info.Lyrics)
fmt.Printf("Comment: %s\n", info.Comment)
fmt.Printf("Has Picture: %v\n", info.HasPicture)
sortPath := pathForFile(filePath, *info)
fmt.Printf("Sort path: %s\n", sortPath)
@@ -48,7 +43,7 @@ func Sort(dst, path string) {
slog.Error("Unsupported file format", "file", path)
os.Exit(1)
}
if err := sortSong(path, dst); err != nil {
if err := sortSong(path, dst, true); err != nil {
slog.Error("Failed to sort single file", "file", path, "err", err)
os.Exit(1)
}
@@ -66,7 +61,7 @@ func Sort(dst, path string) {
if !fileSupported(p) {
return nil
}
if err := sortSong(p, dst); err != nil {
if err := sortSong(p, dst, true); err != nil {
slog.Error("Failed to sort file", "file", p, "err", err)
return err
}