remove album type suffix from album name

This commit is contained in:
thezomo
2025-10-27 21:12:22 -05:00
parent 370132380d
commit 6ab9a1ee99
2 changed files with 22 additions and 0 deletions

Binary file not shown.

View File

@@ -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))