Some more clean up
This commit is contained in:
parent
6dacdd3742
commit
84b05567de
@ -17,7 +17,8 @@ pub struct Track {
|
|||||||
pub artist: Vec<String>,
|
pub artist: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
|
/// The album identifier.
|
||||||
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Hash)]
|
||||||
pub struct AlbumId {
|
pub struct AlbumId {
|
||||||
pub artist: String,
|
pub artist: String,
|
||||||
pub year: u32,
|
pub year: u32,
|
||||||
|
@ -123,32 +123,26 @@ impl Beets {
|
|||||||
let track_title = split[4].to_string();
|
let track_title = split[4].to_string();
|
||||||
let track_artist = split[5].to_string();
|
let track_artist = split[5].to_string();
|
||||||
|
|
||||||
let track = Track {
|
|
||||||
number: track_number,
|
|
||||||
title: track_title,
|
|
||||||
artist: track_artist.split("; ").map(|s| s.to_owned()).collect(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let aid = AlbumId {
|
let aid = AlbumId {
|
||||||
artist: album_artist,
|
artist: album_artist,
|
||||||
year: album_year,
|
year: album_year,
|
||||||
title: album_title,
|
title: album_title,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let track = Track {
|
||||||
|
number: track_number,
|
||||||
|
title: track_title,
|
||||||
|
artist: track_artist.split("; ").map(|s| s.to_owned()).collect(),
|
||||||
|
};
|
||||||
|
|
||||||
if album_ids.contains(&aid) {
|
if album_ids.contains(&aid) {
|
||||||
// Beets returns results in order so we look from the back.
|
// Beets returns results in order so we look from the back.
|
||||||
let album = albums.iter_mut().rev().find(|a| a.id == aid).unwrap();
|
let album = albums.iter_mut().rev().find(|a| a.id == aid).unwrap();
|
||||||
album.tracks.push(track);
|
album.tracks.push(track);
|
||||||
} else {
|
} else {
|
||||||
let album_artist = aid.artist.to_string();
|
album_ids.insert(aid.clone());
|
||||||
let album_title = aid.title.to_string();
|
|
||||||
album_ids.insert(aid);
|
|
||||||
albums.push(Album {
|
albums.push(Album {
|
||||||
id: AlbumId {
|
id: aid,
|
||||||
artist: album_artist,
|
|
||||||
year: album_year,
|
|
||||||
title: album_title,
|
|
||||||
},
|
|
||||||
tracks: vec![track],
|
tracks: vec![track],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user