Replace unicode quotes and dash with simple ascii chars
External services do not use these unicode chars. Ex: - “Weird Al” Yankovic - Bachman–Turner Overdrive - The Go‐Go’s are not found in Last.FM and Spotify
This commit is contained in:
parent
b6a6422fac
commit
c1fb32cedb
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue