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)
|
||||
}
|
||||
|
||||
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
||||
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 == "" {
|
||||
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
|
||||
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
||||
wavFile := fileName + ".wav"
|
||||
sourcePath := filepath.Join(filepath.Dir(filePath), wavFile)
|
||||
newFilePath := filepath.Join(SONGS_DIR, wavFile)
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ func ProcessAndSaveSong(songFilePath, songTitle, songArtist, ytID string) error
|
|||
err = dbclient.StoreFingerprints(fingerprints)
|
||||
if err != nil {
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// WavHeader defines the structure of a WAV header
|
||||
|
|
@ -198,5 +199,13 @@ func GetMetadata(filePath string) (FFmpegMetadata, error) {
|
|||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue