fix: prevent crash when song has no artist (#1720)
When loading this playlist (https://open.spotify.com/playlist/2onE4ObADgp1NuBzciYF0Q), ncspot would crash. The exact cause is not clear, but it seems to be caused by the songs not being available and therefore not having a valid artist. Therefore ensure we have a default value for artists in case one isn't available.
This commit is contained in:
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Playlist retrieval crashing when list contains podcast episodes
|
||||
- Crash when shifting a song by an amount greater than the queue's length
|
||||
- Crash when displaying songs that do not have an (available) artist
|
||||
|
||||
## [1.3.1]
|
||||
|
||||
|
||||
@@ -38,7 +38,9 @@ impl Playable {
|
||||
.replace(
|
||||
"%artist",
|
||||
if let Some(artists) = playable.artists() {
|
||||
artists.first().unwrap().clone().name
|
||||
artists
|
||||
.first()
|
||||
.map_or(String::from(""), |artist| artist.name.clone())
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user