diff --git a/scripts/clean-id3.exe b/scripts/clean-id3.exe index 03620ce..0f972c1 100644 Binary files a/scripts/clean-id3.exe and b/scripts/clean-id3.exe differ diff --git a/scripts/clean-id3/main.go b/scripts/clean-id3/main.go index e7ea3f5..7a809d9 100644 --- a/scripts/clean-id3/main.go +++ b/scripts/clean-id3/main.go @@ -149,6 +149,8 @@ func loadSongFile(fileName string) (string, error) { DiscCount: discCount, } + loadedTags.Album = removeAlbumTypeSuffix(loadedTags.Album) + err = loadedTags.Validate() if err != nil { return "", err @@ -157,6 +159,26 @@ func loadSongFile(fileName string) (string, error) { return id3Template(loadedTags) } +// remove " - Single" and etc +func removeAlbumTypeSuffix(albumName string) string { + if str, ok := removeSuffix(albumName, " - LP"); ok { + albumName = str + } else if str, ok := removeSuffix(albumName, " - EP"); ok { + albumName = str + } else if str, ok := removeSuffix(albumName, " - Single"); ok { + albumName = str + } + return albumName +} + +func removeSuffix(str, suff string) (string, bool) { + if strings.HasSuffix(str, suff) { + suffIndex := len(str) - len(suff) + return str[:suffIndex], true + } + return str, false +} + // converts an id3 tag into a string func id3Template(tags Tags) (string, error) { tmpl := template.Must(template.New("id3template").Parse(ID3_TEMPLATE))