Skip to content

🎧 Your Personal Streaming Service

Replace unicode quotes and dash with simple ascii chars

Deluanc1fb32cedb74
diff --git a/core/external_info.go b/core/external_info.go
index 2bf3b1c9d..87c93c141 100644
--- a/core/external_info.go
+++ b/core/external_info.go
@@ -59,10 +59,23 @@ func (e *externalInfo) getArtist(ctx context.Context, id string) (artist *model.
}
default:
err = model.ErrNotFound
+ return
}
+ artist.Name = clearName(artist.Name)
return
}
+// Replace some Unicode chars with their equivalent ASCII
+func clearName(name string) string {
+ name = strings.ReplaceAll(name, "–", "-")
+ name = strings.ReplaceAll(name, "‐", "-")
+ name = strings.ReplaceAll(name, "β€œ", `"`)
+ name = strings.ReplaceAll(name, "”", `"`)
+ name = strings.ReplaceAll(name, "β€˜", `'`)
+ name = strings.ReplaceAll(name, "’", `'`)
+ return name
+}
+
func (e *externalInfo) SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error) {
if e.lfm == nil {
log.Warn(ctx, "Last.FM client not configured")
@@ -132,6 +145,7 @@ func (e *externalInfo) TopSongs(ctx context.Context, artistName string, count in
log.Error(ctx, "Artist not found", "name", artistName, err)
return nil, nil
}
+ artistName = clearName(artistName)
log.Debug(ctx, "Calling Last.FM ArtistGetTopTracks", "artist", artistName, "id", artist.ID)
tracks, err := e.lfm.ArtistGetTopTracks(ctx, artistName, count)