formatting + clippy cleanups

This commit is contained in:
Henrik Friedrichsen
2019-10-31 12:29:01 +01:00
parent 3efa335b36
commit dc427e3ba2
2 changed files with 13 additions and 8 deletions

View File

@@ -32,15 +32,20 @@ fn get_metadata(track: Option<Track>) -> Metadata {
"mpris:trackid".to_string(), "mpris:trackid".to_string(),
Variant(Box::new( Variant(Box::new(
track track
.map(|t| format!("spotify:track:{}", t.id.clone().unwrap_or("0".to_string()))) .map(|t| {
format!(
"spotify:track:{}",
t.id.clone().unwrap_or_else(|| "0".to_string())
)
})
.unwrap_or_default(), .unwrap_or_default(),
)), )),
); );
hm.insert( hm.insert(
"mpris:length".to_string(), "mpris:length".to_string(),
Variant(Box::new( Variant(Box::new(i64::from(
track.map(|t| t.duration * 1_000).unwrap_or(0) as i64 track.map(|t| t.duration * 1_000).unwrap_or(0),
)), ))),
); );
hm.insert( hm.insert(
"mpris:artUrl".to_string(), "mpris:artUrl".to_string(),

View File

@@ -430,7 +430,9 @@ impl Spotify {
None None
}; };
if let Some(()) = self.api_with_retry(|api| api.user_playlist_replace_tracks(&self.user, id, &tracks)) { if let Some(()) =
self.api_with_retry(|api| api.user_playlist_replace_tracks(&self.user, id, &tracks))
{
debug!("saved {} tracks to playlist {}", tracks.len(), id); debug!("saved {} tracks to playlist {}", tracks.len(), id);
while let Some(ref mut tracks) = remainder.clone() { while let Some(ref mut tracks) = remainder.clone() {
// grab the next set of 100 tracks // grab the next set of 100 tracks
@@ -445,7 +447,6 @@ impl Spotify {
api.user_playlist_add_tracks(&self.user, id, &tracks, None) api.user_playlist_add_tracks(&self.user, id, &tracks, None)
}); });
if result.is_some() { if result.is_some() {
debug!("{} tracks successfully added", tracks.len()); debug!("{} tracks successfully added", tracks.len());
} else { } else {
@@ -453,8 +454,7 @@ impl Spotify {
return; return;
} }
} }
} } else {
else {
error!("error saving tracks to playlist {}", id); error!("error saving tracks to playlist {}", id);
} }
} }