diff --git a/go.mod b/go.mod index f377134..64736ae 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tphoney/plex-lookup -go 1.22 +go 1.22.1 require ( github.com/michiwend/gomusicbrainz v0.0.0-20181012083520-6c07e13dd396 diff --git a/plex/plex.go b/plex/plex.go index 2204ee6..5e04e62 100644 --- a/plex/plex.go +++ b/plex/plex.go @@ -1585,7 +1585,13 @@ func extractArtistsFromPlaylist(xmlString string) (playlistItems []types.PlexMus RatingKey: container.Track[i].GrandparentRatingKey, Albums: []types.PlexMusicAlbum{album}, } - } else if !slices.Contains(artists[container.Track[i].GrandparentTitle].Albums, album) { + } + // get the ratingKeys from the albums + albumkeys := []string{} + for j := range artists[container.Track[i].GrandparentTitle].Albums { + albumkeys = append(albumkeys, artists[container.Track[i].GrandparentTitle].Albums[j].RatingKey) + } + if !slices.Contains(albumkeys, album.RatingKey) { foundArtist.Albums = append(artists[container.Track[i].GrandparentTitle].Albums, album) //nolint:gocritic // replace the artist in the map with the updated artist artists[container.Track[i].GrandparentTitle] = foundArtist diff --git a/utils/utils.go b/utils/utils.go index a99c945..0cdb460 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -94,6 +94,11 @@ func CompareAlbumTitles(title1, title2 string) bool { r = regexp.MustCompile(`\{(.*?)\}`) title1 = r.ReplaceAllString(title1, "") title2 = r.ReplaceAllString(title2, "") + // remove plurals ' and ’ + r = regexp.MustCompile(`[',’]`) + title1 = r.ReplaceAllString(title1, "") + title2 = r.ReplaceAllString(title2, "") + title1 = r.ReplaceAllString(title1, "") // strip whitespace title1 = strings.TrimSpace(title1) title2 = strings.TrimSpace(title2) diff --git a/utils/utils_test.go b/utils/utils_test.go index a0c7c30..e69afb9 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -165,6 +165,11 @@ func Test_albumTitlesMatch(t *testing.T) { title2: "test album", want: true, }, + { + title1: "paula's", + title2: "paula’s", + want: true, + }, } for _, tt := range tests { t.Run(fmt.Sprintf("title1=%s, title2=%s", tt.title1, tt.title2), func(t *testing.T) {