mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-17 08:54:19 +00:00
fix: convert tags keys to lowercase
This commit is contained in:
parent
900c8152d2
commit
91c9e4c15a
3 changed files with 14 additions and 3 deletions
|
|
@ -296,9 +296,12 @@ func saveSong(filePath string, force bool) error {
|
||||||
return fmt.Errorf("failed to get YouTube ID for song: %v", err)
|
return fmt.Errorf("failed to get YouTube ID for song: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
||||||
if track.Title == "" {
|
if track.Title == "" {
|
||||||
return fmt.Errorf("no title found in metadata")
|
// If title is empty, use the file name
|
||||||
|
track.Title = fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
if track.Artist == "" {
|
if track.Artist == "" {
|
||||||
return fmt.Errorf("no artist found in metadata")
|
return fmt.Errorf("no artist found in metadata")
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +312,6 @@ func saveSong(filePath string, force bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move song in wav format to songs directory
|
// Move song in wav format to songs directory
|
||||||
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
|
||||||
wavFile := fileName + ".wav"
|
wavFile := fileName + ".wav"
|
||||||
sourcePath := filepath.Join(filepath.Dir(filePath), wavFile)
|
sourcePath := filepath.Join(filepath.Dir(filePath), wavFile)
|
||||||
newFilePath := filepath.Join(SONGS_DIR, wavFile)
|
newFilePath := filepath.Join(SONGS_DIR, wavFile)
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ func ProcessAndSaveSong(songFilePath, songTitle, songArtist, ytID string) error
|
||||||
err = dbclient.StoreFingerprints(fingerprints)
|
err = dbclient.StoreFingerprints(fingerprints)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dbclient.DeleteSongByID(songID)
|
dbclient.DeleteSongByID(songID)
|
||||||
return fmt.Errorf("error to storing fingerpring: %v", err)
|
return fmt.Errorf("error to storing fingerprint: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Fingerprint for %v by %v saved in DB successfully\n", songTitle, songArtist)
|
fmt.Printf("Fingerprint for %v by %v saved in DB successfully\n", songTitle, songArtist)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WavHeader defines the structure of a WAV header
|
// WavHeader defines the structure of a WAV header
|
||||||
|
|
@ -198,5 +199,13 @@ func GetMetadata(filePath string) (FFmpegMetadata, error) {
|
||||||
return metadata, err
|
return metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert all keys of the Tags map to lowercase
|
||||||
|
for k, v := range metadata.Format.Tags {
|
||||||
|
metadata.Format.Tags[strings.ToLower(k)] = v
|
||||||
|
}
|
||||||
|
for k, v := range metadata.Streams[0].Tags {
|
||||||
|
metadata.Streams[0].Tags[strings.ToLower(k)] = v
|
||||||
|
}
|
||||||
|
|
||||||
return metadata, nil
|
return metadata, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue