diff --git a/src/core/collection/album.rs b/src/core/collection/album.rs index 308e901..a0088cd 100644 --- a/src/core/collection/album.rs +++ b/src/core/collection/album.rs @@ -27,6 +27,7 @@ pub struct AlbumMeta { /// Album non-identifier metadata. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct AlbumInfo { + pub status: Option, pub primary_type: Option, pub secondary_types: Vec, } @@ -93,6 +94,23 @@ impl From<(u32, u8, u8)> for AlbumDate { #[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct AlbumSeq(pub u8); +/// Based on [MusicBrainz status](https://musicbrainz.org/doc/Release#Status). +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum AlbumStatus { + /// Official + Official, + /// Promotion + Promotion, + /// Bootleg + Bootleg, + /// Pseudo-release + PseudoRelease, + /// Withdrawn + Withdrawn, + /// Cancelled + Cancelled, +} + /// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type). #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum AlbumPrimaryType { @@ -238,10 +256,12 @@ impl AlbumMeta { impl AlbumInfo { pub fn new( + status: Option, primary_type: Option, secondary_types: Vec, ) -> Self { AlbumInfo { + status, primary_type, secondary_types, } diff --git a/src/core/musichoard/database.rs b/src/core/musichoard/database.rs index 0d387aa..8de11a5 100644 --- a/src/core/musichoard/database.rs +++ b/src/core/musichoard/database.rs @@ -453,7 +453,7 @@ mod tests { use crate::{ collection::{ - album::{AlbumPrimaryType, AlbumSecondaryType}, + album::{AlbumPrimaryType, AlbumSecondaryType, AlbumStatus}, musicbrainz::MbArtistRef, }, core::{ @@ -944,6 +944,7 @@ mod tests { assert_eq!(meta.info.secondary_types, Vec::new()); let info = AlbumInfo::new( + Some(AlbumStatus::Official), Some(AlbumPrimaryType::Album), vec![AlbumSecondaryType::Live], ); diff --git a/src/core/testmod.rs b/src/core/testmod.rs index a812f67..929723a 100644 --- a/src/core/testmod.rs +++ b/src/core/testmod.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use crate::core::collection::{ album::{ Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq, + AlbumStatus, }, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::{MbAlbumRef, MbArtistRef}, diff --git a/src/external/database/serde/deserialize.rs b/src/external/database/serde/deserialize.rs index 182c9c6..889ca84 100644 --- a/src/external/database/serde/deserialize.rs +++ b/src/external/database/serde/deserialize.rs @@ -138,6 +138,7 @@ impl From for Album { date: album.date.into(), seq: AlbumSeq(album.seq), info: AlbumInfo { + status: None, primary_type: album.primary_type.map(Into::into), secondary_types: album.secondary_types.into_iter().map(Into::into).collect(), }, diff --git a/src/testmod/full.rs b/src/testmod/full.rs index 4e5c1d2..a07a5d0 100644 --- a/src/testmod/full.rs +++ b/src/testmod/full.rs @@ -36,6 +36,7 @@ macro_rules! full_collection { date: 1998.into(), seq: AlbumSeq(1), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -100,6 +101,7 @@ macro_rules! full_collection { date: (2015, 4).into(), seq: AlbumSeq(1), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -168,6 +170,7 @@ macro_rules! full_collection { date: (2003, 6, 6).into(), seq: AlbumSeq(1), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -212,6 +215,7 @@ macro_rules! full_collection { date: 2008.into(), seq: AlbumSeq(3), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -256,6 +260,7 @@ macro_rules! full_collection { date: 2009.into(), seq: AlbumSeq(2), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -298,6 +303,7 @@ macro_rules! full_collection { date: 2015.into(), seq: AlbumSeq(4), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -354,6 +360,7 @@ macro_rules! full_collection { date: 1985.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -396,6 +403,7 @@ macro_rules! full_collection { date: 2018.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -452,6 +460,7 @@ macro_rules! full_collection { date: 1995.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -494,6 +503,7 @@ macro_rules! full_collection { date: 2028.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, diff --git a/src/tui/app/machine/match_state.rs b/src/tui/app/machine/match_state.rs index b25e669..241679c 100644 --- a/src/tui/app/machine/match_state.rs +++ b/src/tui/app/machine/match_state.rs @@ -282,7 +282,7 @@ mod tests { Sequence, }; use musichoard::collection::{ - album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType}, + album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus}, artist::{ArtistId, ArtistMeta}, }; @@ -347,6 +347,7 @@ mod tests { AlbumMeta::new(id) .with_date(AlbumDate::new(Some(1990), Some(5), None)) .with_info(AlbumInfo::new( + Some(AlbumStatus::Official), Some(AlbumPrimaryType::Album), vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation], )) diff --git a/src/tui/lib/external/musicbrainz/api/mod.rs b/src/tui/lib/external/musicbrainz/api/mod.rs index f7e893c..3a73660 100644 --- a/src/tui/lib/external/musicbrainz/api/mod.rs +++ b/src/tui/lib/external/musicbrainz/api/mod.rs @@ -138,6 +138,7 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta { date: meta.first_release_date, seq: AlbumSeq::default(), info: AlbumInfo { + status: None, primary_type: meta.primary_type, secondary_types: meta.secondary_types.unwrap_or_default(), }, diff --git a/src/tui/testmod.rs b/src/tui/testmod.rs index 6346109..f5cb5cf 100644 --- a/src/tui/testmod.rs +++ b/src/tui/testmod.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use musichoard::collection::{ album::{ Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq, + AlbumStatus, }, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::{MbAlbumRef, MbArtistRef}, diff --git a/src/tui/ui/mod.rs b/src/tui/ui/mod.rs index c3e3ee3..5297b03 100644 --- a/src/tui/ui/mod.rs +++ b/src/tui/ui/mod.rs @@ -199,7 +199,7 @@ impl IUi for Ui { #[cfg(test)] mod tests { use musichoard::collection::{ - album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType}, + album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus}, artist::{Artist, ArtistId, ArtistMeta}, }; @@ -361,6 +361,7 @@ mod tests { AlbumMeta::new(id) .with_date(AlbumDate::new(Some(1990), Some(5), None)) .with_info(AlbumInfo::new( + Some(AlbumStatus::Official), Some(AlbumPrimaryType::Album), vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation], )) diff --git a/tests/testlib.rs b/tests/testlib.rs index 119042a..90138c0 100644 --- a/tests/testlib.rs +++ b/tests/testlib.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use musichoard::collection::{ album::{ Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, - AlbumSecondaryType, AlbumSeq, + AlbumSecondaryType, AlbumSeq, AlbumStatus, }, artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta}, musicbrainz::MbArtistRef, @@ -47,6 +47,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 2011.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -240,6 +241,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 2004.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Ep), secondary_types: vec![], }, @@ -323,6 +325,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 2008.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -494,6 +497,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 2001.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -677,6 +681,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 2011.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -793,6 +798,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 1984.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![], }, @@ -898,6 +904,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { date: 1999.into(), seq: AlbumSeq(0), info: AlbumInfo { + status: Some(AlbumStatus::Official), primary_type: Some(AlbumPrimaryType::Album), secondary_types: vec![AlbumSecondaryType::Live], },