mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Added to_uri function to spotify_id
This commit is contained in:
parent
66f8a98ad2
commit
8939954bd7
1 changed files with 14 additions and 0 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue