Ignore bootleg release groups #247
@ -163,19 +163,23 @@ impl<'a, 'b> AlbumState<'a, 'b> {
|
|||||||
"Title: {}\n\
|
"Title: {}\n\
|
||||||
Date: {}\n\
|
Date: {}\n\
|
||||||
Type: {}\n\
|
Type: {}\n\
|
||||||
|
Status: {}\n\
|
||||||
Ownership: {}",
|
Ownership: {}",
|
||||||
album.map(|a| a.meta.id.title.as_str()).unwrap_or(""),
|
album.map(|a| a.meta.id.title.as_str()).unwrap_or(""),
|
||||||
album
|
album
|
||||||
.map(|a| UiDisplay::display_date(&a.meta.date, &a.meta.seq))
|
.map(|a| UiDisplay::display_date(&a.meta.date, &a.meta.seq))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
album
|
album
|
||||||
.map(|a| UiDisplay::display_type(
|
.map(|a| UiDisplay::display_album_type(
|
||||||
&a.meta.info.primary_type,
|
&a.meta.info.primary_type,
|
||||||
&a.meta.info.secondary_types
|
&a.meta.info.secondary_types
|
||||||
))
|
))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
album
|
album
|
||||||
.map(|a| UiDisplay::display_album_status(&a.get_ownership()))
|
.map(|a| UiDisplay::display_album_status(&a.meta.info.status))
|
||||||
|
.unwrap_or(""),
|
||||||
|
album
|
||||||
|
.map(|a| UiDisplay::display_album_ownership(&a.get_ownership()))
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{
|
album::{
|
||||||
AlbumDate, AlbumId, AlbumLibId, AlbumMeta, AlbumOwnership, AlbumPrimaryType,
|
AlbumDate, AlbumId, AlbumLibId, AlbumMeta, AlbumOwnership, AlbumPrimaryType,
|
||||||
AlbumSecondaryType, AlbumSeq,
|
AlbumSecondaryType, AlbumSeq, AlbumStatus,
|
||||||
},
|
},
|
||||||
artist::ArtistMeta,
|
artist::ArtistMeta,
|
||||||
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
||||||
@ -50,19 +50,33 @@ impl UiDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_type(
|
pub fn display_album_status(value: &Option<AlbumStatus>) -> &'static str {
|
||||||
|
match value {
|
||||||
|
Some(status) => match status {
|
||||||
|
AlbumStatus::Official => "Official",
|
||||||
|
AlbumStatus::Promotion => "Promotion",
|
||||||
|
AlbumStatus::Bootleg => "Bootleg",
|
||||||
|
AlbumStatus::PseudoRelease => "Pseudo-Release",
|
||||||
|
AlbumStatus::Withdrawn => "Withdrawn",
|
||||||
|
AlbumStatus::Cancelled => "Cancelled",
|
||||||
|
},
|
||||||
|
None => "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn display_album_type(
|
||||||
primary: &Option<AlbumPrimaryType>,
|
primary: &Option<AlbumPrimaryType>,
|
||||||
secondary: &Vec<AlbumSecondaryType>,
|
secondary: &Vec<AlbumSecondaryType>,
|
||||||
) -> String {
|
) -> String {
|
||||||
match primary {
|
match primary {
|
||||||
Some(ref primary) => {
|
Some(ref primary) => {
|
||||||
if secondary.is_empty() {
|
if secondary.is_empty() {
|
||||||
Self::display_primary_type(primary).to_string()
|
Self::display_album_primary_type(primary).to_string()
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"{} ({})",
|
"{} ({})",
|
||||||
Self::display_primary_type(primary),
|
Self::display_album_primary_type(primary),
|
||||||
Self::display_secondary_types(secondary)
|
Self::display_album_secondary_types(secondary)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +84,7 @@ impl UiDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_primary_type(value: &AlbumPrimaryType) -> &'static str {
|
pub fn display_album_primary_type(value: &AlbumPrimaryType) -> &'static str {
|
||||||
match value {
|
match value {
|
||||||
AlbumPrimaryType::Album => "Album",
|
AlbumPrimaryType::Album => "Album",
|
||||||
AlbumPrimaryType::Single => "Single",
|
AlbumPrimaryType::Single => "Single",
|
||||||
@ -80,7 +94,7 @@ impl UiDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_secondary_types(values: &Vec<AlbumSecondaryType>) -> String {
|
pub fn display_album_secondary_types(values: &Vec<AlbumSecondaryType>) -> String {
|
||||||
let mut types: Vec<&'static str> = vec![];
|
let mut types: Vec<&'static str> = vec![];
|
||||||
for value in values {
|
for value in values {
|
||||||
match value {
|
match value {
|
||||||
@ -101,7 +115,7 @@ impl UiDisplay {
|
|||||||
types.join(", ")
|
types.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_album_status(status: &AlbumOwnership) -> &'static str {
|
pub fn display_album_ownership(status: &AlbumOwnership) -> &'static str {
|
||||||
match status {
|
match status {
|
||||||
AlbumOwnership::None => "None",
|
AlbumOwnership::None => "None",
|
||||||
AlbumOwnership::Owned(format) => match format {
|
AlbumOwnership::Owned(format) => match format {
|
||||||
@ -173,7 +187,7 @@ impl UiDisplay {
|
|||||||
"{:010} | {} [{}]",
|
"{:010} | {} [{}]",
|
||||||
UiDisplay::display_album_date(&album.date),
|
UiDisplay::display_album_date(&album.date),
|
||||||
album.id.title,
|
album.id.title,
|
||||||
UiDisplay::display_type(&album.info.primary_type, &album.info.secondary_types),
|
UiDisplay::display_album_type(&album.info.primary_type, &album.info.secondary_types),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,30 +238,62 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_primary_type() {
|
fn display_album_status() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_primary_type(&AlbumPrimaryType::Album),
|
UiDisplay::display_album_status(&Some(AlbumStatus::Official)),
|
||||||
|
"Official"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&Some(AlbumStatus::Promotion)),
|
||||||
|
"Promotion"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&Some(AlbumStatus::Bootleg)),
|
||||||
|
"Bootleg"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&Some(AlbumStatus::PseudoRelease)),
|
||||||
|
"Pseudo-Release"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&Some(AlbumStatus::Withdrawn)),
|
||||||
|
"Withdrawn"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&Some(AlbumStatus::Cancelled)),
|
||||||
|
"Cancelled"
|
||||||
|
);
|
||||||
|
assert_eq!(UiDisplay::display_album_status(&None), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn display_album_primary_type() {
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_primary_type(&AlbumPrimaryType::Album),
|
||||||
"Album"
|
"Album"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_primary_type(&AlbumPrimaryType::Single),
|
UiDisplay::display_album_primary_type(&AlbumPrimaryType::Single),
|
||||||
"Single"
|
"Single"
|
||||||
);
|
);
|
||||||
assert_eq!(UiDisplay::display_primary_type(&AlbumPrimaryType::Ep), "EP");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_primary_type(&AlbumPrimaryType::Broadcast),
|
UiDisplay::display_album_primary_type(&AlbumPrimaryType::Ep),
|
||||||
|
"EP"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_primary_type(&AlbumPrimaryType::Broadcast),
|
||||||
"Broadcast"
|
"Broadcast"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_primary_type(&AlbumPrimaryType::Other),
|
UiDisplay::display_album_primary_type(&AlbumPrimaryType::Other),
|
||||||
"Other"
|
"Other"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_secondary_types() {
|
fn display_album_secondary_types() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_secondary_types(&vec![
|
UiDisplay::display_album_secondary_types(&vec![
|
||||||
AlbumSecondaryType::Compilation,
|
AlbumSecondaryType::Compilation,
|
||||||
AlbumSecondaryType::Soundtrack,
|
AlbumSecondaryType::Soundtrack,
|
||||||
AlbumSecondaryType::Spokenword,
|
AlbumSecondaryType::Spokenword,
|
||||||
@ -267,14 +313,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_type() {
|
fn display_album_type() {
|
||||||
assert_eq!(UiDisplay::display_type(&None, &vec![]), "");
|
assert_eq!(UiDisplay::display_album_type(&None, &vec![]), "");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_type(&Some(AlbumPrimaryType::Album), &vec![]),
|
UiDisplay::display_album_type(&Some(AlbumPrimaryType::Album), &vec![]),
|
||||||
"Album"
|
"Album"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_type(
|
UiDisplay::display_album_type(
|
||||||
&Some(AlbumPrimaryType::Album),
|
&Some(AlbumPrimaryType::Album),
|
||||||
&vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation]
|
&vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation]
|
||||||
),
|
),
|
||||||
@ -283,17 +329,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_album_status() {
|
fn display_album_ownership() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_album_status(&AlbumOwnership::None),
|
UiDisplay::display_album_ownership(&AlbumOwnership::None),
|
||||||
"None"
|
"None"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_album_status(&AlbumOwnership::Owned(TrackFormat::Mp3)),
|
UiDisplay::display_album_ownership(&AlbumOwnership::Owned(TrackFormat::Mp3)),
|
||||||
"MP3"
|
"MP3"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_album_status(&AlbumOwnership::Owned(TrackFormat::Flac)),
|
UiDisplay::display_album_ownership(&AlbumOwnership::Owned(TrackFormat::Flac)),
|
||||||
"FLAC"
|
"FLAC"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user