Browse Source

Various changes following review

HEnquist 5 years ago
parent
commit
a4f0fe96f8
4 changed files with 15 additions and 6 deletions
  1. 1 0
      Cargo.lock
  2. 1 0
      metadata/Cargo.toml
  3. 9 2
      metadata/src/lib.rs
  4. 4 4
      protocol/src/lib.rs

+ 1 - 0
Cargo.lock

@@ -927,6 +927,7 @@ dependencies = [
  "librespot-core 0.1.0",
  "librespot-protocol 0.1.0",
  "linear-map 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 

+ 1 - 0
metadata/Cargo.toml

@@ -8,6 +8,7 @@ byteorder = "1.3"
 futures = "0.1"
 linear-map = "1.2"
 protobuf = "2.8.*"
+log = "0.4"
 
 [dependencies.librespot-core]
 path = "../core"

+ 9 - 2
metadata/src/lib.rs

@@ -1,3 +1,6 @@
+#[macro_use]
+extern crate log;
+
 extern crate byteorder;
 extern crate futures;
 extern crate linear_map;
@@ -95,8 +98,8 @@ pub struct Album {
 
 #[derive(Debug, Clone)]
 pub struct Playlist {
+    pub revision: Vec<u8>,
     pub user: String,
-    pub length: i32,
     pub name: String,
     pub tracks: Vec<SpotifyId>,
 }
@@ -218,9 +221,13 @@ impl Metadata for Playlist {
             })
             .collect::<Vec<_>>();
         
+        if tracks.len() != msg.get_length() as usize {
+            warn!("Got {} tracks, but the playlist should contain {} tracks.", tracks.len(), msg.get_length());
+        }
+
         Playlist {
+            revision: msg.get_revision().to_vec(),
             name: msg.get_attributes().get_name().to_owned(),
-            length: msg.get_length(),
             tracks: tracks,
             user: msg.get_owner_username().to_string(),
         }

+ 4 - 4
protocol/src/lib.rs

@@ -6,9 +6,9 @@ pub mod keyexchange;
 pub mod mercury;
 pub mod metadata;
 pub mod playlist4changes;
-pub mod playlist4content;
-pub mod playlist4issues;
-pub mod playlist4meta;
-pub mod playlist4ops;
+mod playlist4content;
+mod playlist4issues;
+mod playlist4meta;
+mod playlist4ops;
 pub mod pubsub;
 pub mod spirc;