mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
connect: handle metadata correct
This commit is contained in:
parent
d2f1dee43c
commit
673ded3d57
2 changed files with 15 additions and 5 deletions
|
@ -202,6 +202,7 @@ impl ConnectState {
|
||||||
UpdateContext::Default => {
|
UpdateContext::Default => {
|
||||||
let mut new_context = self.state_context_from_page(
|
let mut new_context = self.state_context_from_page(
|
||||||
page,
|
page,
|
||||||
|
context.metadata,
|
||||||
context.restrictions.take(),
|
context.restrictions.take(),
|
||||||
Some(&context.uri),
|
Some(&context.uri),
|
||||||
None,
|
None,
|
||||||
|
@ -242,6 +243,7 @@ impl ConnectState {
|
||||||
UpdateContext::Autoplay => {
|
UpdateContext::Autoplay => {
|
||||||
self.autoplay_context = Some(self.state_context_from_page(
|
self.autoplay_context = Some(self.state_context_from_page(
|
||||||
page,
|
page,
|
||||||
|
context.metadata,
|
||||||
context.restrictions.take(),
|
context.restrictions.take(),
|
||||||
Some(&context.uri),
|
Some(&context.uri),
|
||||||
Some(Provider::Autoplay),
|
Some(Provider::Autoplay),
|
||||||
|
@ -275,6 +277,7 @@ impl ConnectState {
|
||||||
fn state_context_from_page(
|
fn state_context_from_page(
|
||||||
&mut self,
|
&mut self,
|
||||||
page: ContextPage,
|
page: ContextPage,
|
||||||
|
metadata: HashMap<String, String>,
|
||||||
restrictions: Option<Restrictions>,
|
restrictions: Option<Restrictions>,
|
||||||
new_context_uri: Option<&str>,
|
new_context_uri: Option<&str>,
|
||||||
provider: Option<Provider>,
|
provider: Option<Provider>,
|
||||||
|
@ -285,8 +288,12 @@ impl ConnectState {
|
||||||
.tracks
|
.tracks
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|track| {
|
.flat_map(|track| {
|
||||||
match self.context_to_provided_track(track, Some(new_context_uri), provider.clone())
|
match self.context_to_provided_track(
|
||||||
{
|
track,
|
||||||
|
Some(new_context_uri),
|
||||||
|
Some(&page.metadata),
|
||||||
|
provider.clone(),
|
||||||
|
) {
|
||||||
Ok(t) => Some(t),
|
Ok(t) => Some(t),
|
||||||
Err(why) => {
|
Err(why) => {
|
||||||
error!("couldn't convert {track:#?} into ProvidedTrack: {why}");
|
error!("couldn't convert {track:#?} into ProvidedTrack: {why}");
|
||||||
|
@ -299,7 +306,7 @@ impl ConnectState {
|
||||||
StateContext {
|
StateContext {
|
||||||
tracks,
|
tracks,
|
||||||
restrictions,
|
restrictions,
|
||||||
metadata: page.metadata,
|
metadata,
|
||||||
index: ContextIndex::new(),
|
index: ContextIndex::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,6 +365,7 @@ impl ConnectState {
|
||||||
&self,
|
&self,
|
||||||
ctx_track: &ContextTrack,
|
ctx_track: &ContextTrack,
|
||||||
context_uri: Option<&str>,
|
context_uri: Option<&str>,
|
||||||
|
page_metadata: Option<&HashMap<String, String>>,
|
||||||
provider: Option<Provider>,
|
provider: Option<Provider>,
|
||||||
) -> Result<ProvidedTrack, Error> {
|
) -> Result<ProvidedTrack, Error> {
|
||||||
let id = if !ctx_track.uri.is_empty() {
|
let id = if !ctx_track.uri.is_empty() {
|
||||||
|
@ -388,7 +396,7 @@ impl ConnectState {
|
||||||
ctx_track.uid.to_string()
|
ctx_track.uid.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut metadata = HashMap::new();
|
let mut metadata = page_metadata.cloned().unwrap_or_default();
|
||||||
for (k, v) in &ctx_track.metadata {
|
for (k, v) in &ctx_track.metadata {
|
||||||
metadata.insert(k.to_string(), v.to_string());
|
metadata.insert(k.to_string(), v.to_string());
|
||||||
}
|
}
|
||||||
|
@ -414,7 +422,7 @@ impl ConnectState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill_context_from_page(&mut self, page: ContextPage) -> Result<(), Error> {
|
pub fn fill_context_from_page(&mut self, page: ContextPage) -> Result<(), Error> {
|
||||||
let context = self.state_context_from_page(page, None, None, None);
|
let context = self.state_context_from_page(page, HashMap::new(), None, None, None);
|
||||||
let ctx = self
|
let ctx = self
|
||||||
.context
|
.context
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
|
|
@ -21,6 +21,7 @@ impl ConnectState {
|
||||||
self.context_to_provided_track(
|
self.context_to_provided_track(
|
||||||
track,
|
track,
|
||||||
Some(&transfer.current_session.context.uri),
|
Some(&transfer.current_session.context.uri),
|
||||||
|
None,
|
||||||
transfer.queue.is_playing_queue.then_some(Provider::Queue),
|
transfer.queue.is_playing_queue.then_some(Provider::Queue),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -125,6 +126,7 @@ impl ConnectState {
|
||||||
if let Ok(queued_track) = self.context_to_provided_track(
|
if let Ok(queued_track) = self.context_to_provided_track(
|
||||||
track,
|
track,
|
||||||
Some(self.context_uri()),
|
Some(self.context_uri()),
|
||||||
|
None,
|
||||||
Some(Provider::Queue),
|
Some(Provider::Queue),
|
||||||
) {
|
) {
|
||||||
self.add_to_queue(queued_track, false);
|
self.add_to_queue(queued_track, false);
|
||||||
|
|
Loading…
Reference in a new issue