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:
Thomas Frans
2025-10-12 22:10:07 +02:00
committed by GitHub
parent 6dcdd8dba8
commit 79d45b96f3
2 changed files with 4 additions and 1 deletions

View File

@@ -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]

View File

@@ -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()
}