From 8939954bd77f94833e024aef15310bba59e1b806 Mon Sep 17 00:00:00 2001 From: Michael Pivonka Date: Mon, 2 Mar 2020 06:29:13 -0500 Subject: [PATCH 1/2] Added to_uri function to spotify_id --- core/src/spotify_id.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/spotify_id.rs b/core/src/spotify_id.rs index 1a5fcd2e..614d5f60 100644 --- a/core/src/spotify_id.rs +++ b/core/src/spotify_id.rs @@ -104,6 +104,20 @@ impl SpotifyId { std::str::from_utf8(&data).unwrap().to_owned() } + pub fn to_uri(&self) -> String { + match self.audio_type { + SpotifyAudioType::Track => { + format!("spotify:track:{}", self.to_base62()) + } + SpotifyAudioType::Podcast => { + format!("spotify:episode:{}", self.to_base62()) + } + SpotifyAudioType::NonPlayable => { + format!("spotify:unknown:{}", self.to_base62()) + } + } + } + pub fn to_raw(&self) -> [u8; 16] { self.id.to_be_bytes() } From d47cc75dc6ad9b33a5b9e37371f79fedf4258598 Mon Sep 17 00:00:00 2001 From: Michael Pivonka Date: Mon, 2 Mar 2020 06:36:27 -0500 Subject: [PATCH 2/2] Fixed formatting --- core/src/spotify_id.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/core/src/spotify_id.rs b/core/src/spotify_id.rs index 614d5f60..0982f9cb 100644 --- a/core/src/spotify_id.rs +++ b/core/src/spotify_id.rs @@ -106,15 +106,9 @@ impl SpotifyId { pub fn to_uri(&self) -> String { match self.audio_type { - SpotifyAudioType::Track => { - format!("spotify:track:{}", self.to_base62()) - } - SpotifyAudioType::Podcast => { - format!("spotify:episode:{}", self.to_base62()) - } - SpotifyAudioType::NonPlayable => { - format!("spotify:unknown:{}", self.to_base62()) - } + SpotifyAudioType::Track => format!("spotify:track:{}", self.to_base62()), + SpotifyAudioType::Podcast => format!("spotify:episode:{}", self.to_base62()), + SpotifyAudioType::NonPlayable => format!("spotify:unknown:{}", self.to_base62()), } }