removed comment fix & moved comment fix to sort
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/dhowden/tag"
|
||||
@@ -62,6 +63,8 @@ func readGenericAudioTags(filePath string) (*Metadata, error) {
|
||||
Comment: &comment,
|
||||
}
|
||||
|
||||
commentToSpotifyid(info)
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
@@ -89,3 +92,21 @@ func UpdateMetadata(src, dst string, m Metadata) error {
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func commentToSpotifyid(m *Metadata) {
|
||||
var re = regexp.MustCompile(`(?m)(https:\/\/open\.spotify\.com\/track\/)(.*)`)
|
||||
|
||||
if m.Comment == nil {
|
||||
return
|
||||
}
|
||||
|
||||
matches := re.FindAllStringSubmatch(*m.Comment, -1)
|
||||
|
||||
if len(matches) != 1 {
|
||||
return
|
||||
}
|
||||
|
||||
id := matches[0][2]
|
||||
|
||||
m.SpotifyID = &id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user