Ignore files which don’t have an id.

Fixes #42
This commit is contained in:
Paul Lietar 2016-01-20 10:31:43 +00:00
parent 2a7c9c312b
commit ac0d597e75
4 changed files with 6 additions and 4 deletions

4
Cargo.lock generated
View file

@ -15,7 +15,7 @@ dependencies = [
"protobuf 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf_macros 0.1.2 (git+https://github.com/plietar/rust-protobuf-macros.git)", "protobuf_macros 0.1.2 (git+https://github.com/plietar/rust-protobuf-macros.git)",
"rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)", "shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)",
@ -316,7 +316,7 @@ dependencies = [
[[package]] [[package]]
name = "rpassword" name = "rpassword"
version = "0.1.0" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -1,6 +1,6 @@
#![crate_name = "librespot"] #![crate_name = "librespot"]
#![feature(plugin,zero_one,iter_arith,mpsc_select,clone_from_slice)] #![feature(plugin,zero_one,iter_arith,mpsc_select)]
#![plugin(protobuf_macros)] #![plugin(protobuf_macros)]
#![plugin(json_macros)] #![plugin(json_macros)]

View file

@ -73,6 +73,7 @@ impl MetadataTrait for Track {
album: SpotifyId::from_raw(msg.get_album().get_gid()), album: SpotifyId::from_raw(msg.get_album().get_gid()),
files: msg.get_file() files: msg.get_file()
.iter() .iter()
.filter(|file| file.has_file_id())
.map(|file| { .map(|file| {
let mut dst = [0u8; 20]; let mut dst = [0u8; 20];
dst.clone_from_slice(&file.get_file_id()); dst.clone_from_slice(&file.get_file_id());
@ -108,6 +109,7 @@ impl MetadataTrait for Album {
covers: msg.get_cover_group() covers: msg.get_cover_group()
.get_image() .get_image()
.iter() .iter()
.filter(|image| image.has_file_id())
.map(|image| { .map(|image| {
let mut dst = [0u8; 20]; let mut dst = [0u8; 20];
dst.clone_from_slice(&image.get_file_id()); dst.clone_from_slice(&image.get_file_id());

View file

@ -156,7 +156,7 @@ impl<D: SpircDelegate> SpircManager<D> {
self.tracks = frame.get_state() self.tracks = frame.get_state()
.get_track() .get_track()
.iter() .iter()
.filter(|track| track.get_gid().len()==16) .filter(|track| track.has_gid())
.map(|track| SpotifyId::from_raw(track.get_gid())) .map(|track| SpotifyId::from_raw(track.get_gid()))
.collect(); .collect();