Skip to content

Commit 195e93c

Browse files
committed
Add compatability with librespot PR #1622 (and related API changes)
- Update spotify_id_to_playable_id to use SpotifyUri enum - Update lyrics method to extract SpotifyId from SpotifyUri Related: librespot-org/librespot#1622
1 parent c526ae5 commit 195e93c

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

spotify_player/src/client/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,11 @@ impl AppClient {
638638
/// Get lyrics of a given track, return None if no lyrics is available
639639
pub async fn lyrics(&self, track_id: TrackId<'static>) -> Result<Option<Lyrics>> {
640640
let session = self.session().await;
641-
let id = librespot_core::spotify_id::SpotifyId::from_uri(&track_id.uri())?;
641+
let uri = librespot_core::SpotifyUri::from_uri(&track_id.uri())?;
642+
let id = match uri {
643+
librespot_core::SpotifyUri::Track { id } => id,
644+
_ => anyhow::bail!("Expected track URI, got {uri:?}"),
645+
};
642646
match librespot_metadata::Lyrics::get(&session, &id).await {
643647
Ok(lyrics) => Ok(Some(lyrics.into())),
644648
Err(err) => {

spotify_player/src/streaming.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::Context;
33
use librespot_connect::{ConnectConfig, Spirc};
44
use librespot_core::authentication::Credentials;
55
use librespot_core::Session;
6-
use librespot_core::{config::DeviceType, spotify_id};
6+
use librespot_core::{config::DeviceType, SpotifyUri};
77
use librespot_playback::mixer::MixerConfig;
88
use librespot_playback::{
99
audio_backend,
@@ -85,17 +85,17 @@ impl PlayerEvent {
8585
}
8686
}
8787

88-
fn spotify_id_to_playable_id(id: spotify_id::SpotifyId) -> anyhow::Result<PlayableId<'static>> {
89-
match id.item_type {
90-
spotify_id::SpotifyItemType::Track => {
91-
let uri = id.to_uri()?;
92-
Ok(TrackId::from_uri(&uri)?.into_static().into())
88+
fn spotify_id_to_playable_id(uri: SpotifyUri) -> anyhow::Result<PlayableId<'static>> {
89+
match uri {
90+
SpotifyUri::Track { .. } => {
91+
let uri_str = uri.to_uri()?;
92+
Ok(TrackId::from_uri(&uri_str)?.into_static().into())
9393
}
94-
spotify_id::SpotifyItemType::Episode => {
95-
let uri = id.to_uri()?;
96-
Ok(EpisodeId::from_uri(&uri)?.into_static().into())
94+
SpotifyUri::Episode { .. } => {
95+
let uri_str = uri.to_uri()?;
96+
Ok(EpisodeId::from_uri(&uri_str)?.into_static().into())
9797
}
98-
_ => anyhow::bail!("unexpected spotify_id {id:?}"),
98+
_ => anyhow::bail!("unexpected spotify_uri {uri:?}"),
9999
}
100100
}
101101

0 commit comments

Comments
 (0)