From 6c6ba88590db475c0194143acb2549176121cb79 Mon Sep 17 00:00:00 2001 From: ashthespy Date: Tue, 7 Jan 2020 12:13:49 +0100 Subject: [PATCH] Don't panic when no autoplay uri is obtained For example from Liked Songs (`spotify:user:xxx:collection`) --- connect/src/spirc.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 4fd4288e..9594082e 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -795,10 +795,14 @@ impl SpircTask { let query_uri = format!("hm://autoplay-enabled/query?uri={}", uri); let request = self.session.mercury().get(query_uri); Box::new(request.and_then(move |response| { - let data = response.payload.first().expect("Empty autoplay uri").to_vec(); - let autoplay_uri = String::from_utf8(data).unwrap(); - - Ok(autoplay_uri) + if response.status_code == 200 { + let data = response.payload.first().expect("Empty autoplay uri").to_vec(); + let autoplay_uri = String::from_utf8(data).unwrap(); + Ok(autoplay_uri) + } else { + warn!("No autoplay_uri found"); + Err(MercuryError) + } })) }