mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-17 23:51:48 +03:00
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,9 +59,22 @@ func (e *externalInfo) getArtist(ctx context.Context, id string) (artist *model.
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
err = model.ErrNotFound
|
err = model.ErrNotFound
|
||||||
}
|
|
||||||
return
|
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) {
|
func (e *externalInfo) SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error) {
|
||||||
if e.lfm == nil {
|
if e.lfm == nil {
|
||||||
@ -132,6 +145,7 @@ func (e *externalInfo) TopSongs(ctx context.Context, artistName string, count in
|
|||||||
log.Error(ctx, "Artist not found", "name", artistName, err)
|
log.Error(ctx, "Artist not found", "name", artistName, err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
artistName = clearName(artistName)
|
||||||
|
|
||||||
log.Debug(ctx, "Calling Last.FM ArtistGetTopTracks", "artist", artistName, "id", artist.ID)
|
log.Debug(ctx, "Calling Last.FM ArtistGetTopTracks", "artist", artistName, "id", artist.ID)
|
||||||
tracks, err := e.lfm.ArtistGetTopTracks(ctx, artistName, count)
|
tracks, err := e.lfm.ArtistGetTopTracks(ctx, artistName, count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user