From 880fbb3f6efaac6c14e1e54ea0f389fd9a4e6b5c Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Mon, 16 Nov 2020 22:21:10 +0100 Subject: [PATCH] fix: don't try to play tracks without spotify id Can happen when a playlist is queued that contains tracks removed from the Spotify catalogue. fixes #321 --- src/spotify.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/spotify.rs b/src/spotify.rs index 419322b..39b8c39 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -4,7 +4,7 @@ use librespot_core::config::SessionConfig; use librespot_core::keymaster::Token; use librespot_core::mercury::MercuryError; use librespot_core::session::Session; -use librespot_core::spotify_id::SpotifyId; +use librespot_core::spotify_id::{SpotifyAudioType, SpotifyId}; use librespot_playback::config::PlayerConfig; use librespot_playback::audio_backend; @@ -162,8 +162,13 @@ impl futures::Future for Worker { match cmd { WorkerCommand::Load(playable) => match SpotifyId::from_uri(&playable.uri()) { Ok(id) => { - self.player.load(id, true, 0); - info!("player loading track: {:?}", playable); + info!("player loading track: {:?}", id); + if id.audio_type == SpotifyAudioType::NonPlayable { + warn!("track is not playable"); + self.events.send(Event::Player(PlayerEvent::FinishedTrack)); + } else { + self.player.load(id, true, 0); + } } Err(e) => { error!("error parsing uri: {:?}", e);