remove album type suffix from album name
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user