mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Make standard metadata get handle also playlists
This commit is contained in:
parent
d72eb38d62
commit
eb9ab4885f
1 changed files with 14 additions and 22 deletions
|
@ -124,11 +124,16 @@ impl AudioFiles for Episode {
|
||||||
pub trait Metadata: Send + Sized + 'static {
|
pub trait Metadata: Send + Sized + 'static {
|
||||||
type Message: protobuf::Message;
|
type Message: protobuf::Message;
|
||||||
|
|
||||||
fn base_url() -> &'static str;
|
fn request_url(id: SpotifyId) -> String;
|
||||||
fn parse(msg: &Self::Message, session: &Session) -> Self;
|
fn parse(msg: &Self::Message, session: &Session) -> Self;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
fn get(session: &Session, id: SpotifyId) -> Box<dyn Future<Item = Self, Error = MercuryError>> {
|
fn get(session: &Session, id: SpotifyId) -> Box<dyn Future<Item = Self, Error = MercuryError>> {
|
||||||
let uri = format!("{}/{}", Self::base_url(), id.to_base16());
|
let uri = format!("{}/{}", Self::base_url(), id.to_base16());
|
||||||
|
=======
|
||||||
|
fn get(session: &Session, id: SpotifyId) -> Box<Future<Item = Self, Error = MercuryError>> {
|
||||||
|
let uri = Self::request_url(id);
|
||||||
|
>>>>>>> Make standard metadata get handle also playlists
|
||||||
let request = session.mercury().get(uri);
|
let request = session.mercury().get(uri);
|
||||||
|
|
||||||
let session = session.clone();
|
let session = session.clone();
|
||||||
|
@ -203,8 +208,8 @@ pub struct Artist {
|
||||||
impl Metadata for Track {
|
impl Metadata for Track {
|
||||||
type Message = protocol::metadata::Track;
|
type Message = protocol::metadata::Track;
|
||||||
|
|
||||||
fn base_url() -> &'static str {
|
fn request_url(id: SpotifyId) -> String {
|
||||||
"hm://metadata/3/track"
|
format!("hm://metadata/3/track/{}", id.to_base16())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(msg: &Self::Message, session: &Session) -> Self {
|
fn parse(msg: &Self::Message, session: &Session) -> Self {
|
||||||
|
@ -248,8 +253,8 @@ impl Metadata for Track {
|
||||||
impl Metadata for Album {
|
impl Metadata for Album {
|
||||||
type Message = protocol::metadata::Album;
|
type Message = protocol::metadata::Album;
|
||||||
|
|
||||||
fn base_url() -> &'static str {
|
fn request_url(id: SpotifyId) -> String {
|
||||||
"hm://metadata/3/album"
|
format!("hm://metadata/3/album/{}", id.to_base16())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(msg: &Self::Message, _: &Session) -> Self {
|
fn parse(msg: &Self::Message, _: &Session) -> Self {
|
||||||
|
@ -293,21 +298,8 @@ impl Metadata for Album {
|
||||||
impl Metadata for Playlist {
|
impl Metadata for Playlist {
|
||||||
type Message = protocol::playlist4changes::SelectedListContent;
|
type Message = protocol::playlist4changes::SelectedListContent;
|
||||||
|
|
||||||
fn base_url() -> &'static str {
|
fn request_url(id: SpotifyId) -> String {
|
||||||
"hm://playlist/v2/playlist"
|
format!("hm://playlist/v2/playlist/{}", id.to_base62())
|
||||||
}
|
|
||||||
|
|
||||||
fn get(session: &Session, id: SpotifyId) -> Box<Future<Item = Self, Error = MercuryError>> {
|
|
||||||
let uri = format!("{}/{}", Self::base_url(), id.to_base62());
|
|
||||||
let request = session.mercury().get(uri);
|
|
||||||
|
|
||||||
let session = session.clone();
|
|
||||||
Box::new(request.and_then(move |response| {
|
|
||||||
let data = response.payload.first().expect("Empty payload");
|
|
||||||
let msg: Self::Message = protobuf::parse_from_bytes(data).unwrap();
|
|
||||||
|
|
||||||
Ok(Self::parse(&msg, &session))
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(msg: &Self::Message, _: &Session) -> Self {
|
fn parse(msg: &Self::Message, _: &Session) -> Self {
|
||||||
|
@ -337,8 +329,8 @@ impl Metadata for Playlist {
|
||||||
impl Metadata for Artist {
|
impl Metadata for Artist {
|
||||||
type Message = protocol::metadata::Artist;
|
type Message = protocol::metadata::Artist;
|
||||||
|
|
||||||
fn base_url() -> &'static str {
|
fn request_url(id: SpotifyId) -> String {
|
||||||
"hm://metadata/3/artist"
|
format!("hm://metadata/3/artist/{}", id.to_base16())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(msg: &Self::Message, session: &Session) -> Self {
|
fn parse(msg: &Self::Message, session: &Session) -> Self {
|
||||||
|
|
Loading…
Reference in a new issue