This commit is contained in:
Tianyi Shi 2020-10-27 13:50:07 +00:00
parent 7eb57f1874
commit f233955413
2 changed files with 4 additions and 36 deletions

View file

@ -8,26 +8,10 @@ impl<'a> From<AnyTag<'a>> for FlacTag {
fn from(inp: AnyTag<'a>) -> Self { fn from(inp: AnyTag<'a>) -> Self {
let mut t = FlacTag::default(); let mut t = FlacTag::default();
inp.title().map(|v| t.set_title(v)); inp.title().map(|v| t.set_title(v));
inp.artists() inp.artists_as_string().map(|v| t.set_artist(&v));
.map(|i| {
i.iter().fold(String::new(), |mut v, a| {
v.push_str(&a);
v.push_str(inp.config.sep_artist);
v
})
})
.map(|v| t.set_artist(&v[..v.len() - 1]));
inp.year.map(|v| t.set_year(v)); inp.year.map(|v| t.set_year(v));
inp.album_title().map(|v| t.set_album_title(v)); inp.album_title().map(|v| t.set_album_title(v));
inp.album_artists() inp.album_artists_as_string().map(|v| t.set_artist(&v));
.map(|i| {
i.iter().fold(String::new(), |mut v, a| {
v.push_str(&a);
v.push_str(inp.config.sep_artist);
v
})
})
.map(|v| t.set_album_artist(&v[..v.len() - 1]));
inp.track_number().map(|v| t.set_track_number(v)); inp.track_number().map(|v| t.set_track_number(v));
inp.total_tracks().map(|v| t.set_total_tracks(v)); inp.total_tracks().map(|v| t.set_total_tracks(v));
inp.disc_number().map(|v| t.set_disc_number(v)); inp.disc_number().map(|v| t.set_disc_number(v));

View file

@ -31,26 +31,10 @@ impl<'a> From<AnyTag<'a>> for Id3v2Tag {
inner: { inner: {
let mut t = id3::Tag::new(); let mut t = id3::Tag::new();
inp.title().map(|v| t.set_title(v)); inp.title().map(|v| t.set_title(v));
inp.artists() inp.artists_as_string().map(|v| t.set_artist(&v));
.map(|i| {
i.iter().fold(String::new(), |mut v, a| {
v.push_str(&a);
v.push_str(inp.config.sep_artist);
v
})
})
.map(|v| t.set_artist(&v[..v.len() - 1]));
inp.year.map(|v| t.set_year(v)); inp.year.map(|v| t.set_year(v));
inp.album_title().map(|v| t.set_album(v)); inp.album_title().map(|v| t.set_album(v));
inp.album_artists() inp.album_artists_as_string().map(|v| t.set_artist(&v));
.map(|i| {
i.iter().fold(String::new(), |mut v, a| {
v.push_str(&a);
v.push_str(inp.config.sep_artist);
v
})
})
.map(|v| t.set_album_artist(&v[..v.len() - 1]));
inp.track_number().map(|v| t.set_track(v as u32)); inp.track_number().map(|v| t.set_track(v as u32));
inp.total_tracks().map(|v| t.set_total_tracks(v as u32)); inp.total_tracks().map(|v| t.set_total_tracks(v as u32));
inp.disc_number().map(|v| t.set_disc(v as u32)); inp.disc_number().map(|v| t.set_disc(v as u32));