Add AlbumStatus to Album
This commit is contained in:
parent
dce402cee0
commit
6d1e8b88f4
@ -27,6 +27,7 @@ pub struct AlbumMeta {
|
|||||||
/// Album non-identifier metadata.
|
/// Album non-identifier metadata.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||||
pub struct AlbumInfo {
|
pub struct AlbumInfo {
|
||||||
|
pub status: Option<AlbumStatus>,
|
||||||
pub primary_type: Option<AlbumPrimaryType>,
|
pub primary_type: Option<AlbumPrimaryType>,
|
||||||
pub secondary_types: Vec<AlbumSecondaryType>,
|
pub secondary_types: Vec<AlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
@ -93,6 +94,23 @@ impl From<(u32, u8, u8)> for AlbumDate {
|
|||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||||
pub struct AlbumSeq(pub u8);
|
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).
|
/// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type).
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum AlbumPrimaryType {
|
pub enum AlbumPrimaryType {
|
||||||
@ -238,10 +256,12 @@ impl AlbumMeta {
|
|||||||
|
|
||||||
impl AlbumInfo {
|
impl AlbumInfo {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
status: Option<AlbumStatus>,
|
||||||
primary_type: Option<AlbumPrimaryType>,
|
primary_type: Option<AlbumPrimaryType>,
|
||||||
secondary_types: Vec<AlbumSecondaryType>,
|
secondary_types: Vec<AlbumSecondaryType>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
AlbumInfo {
|
AlbumInfo {
|
||||||
|
status,
|
||||||
primary_type,
|
primary_type,
|
||||||
secondary_types,
|
secondary_types,
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
collection::{
|
collection::{
|
||||||
album::{AlbumPrimaryType, AlbumSecondaryType},
|
album::{AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
||||||
musicbrainz::MbArtistRef,
|
musicbrainz::MbArtistRef,
|
||||||
},
|
},
|
||||||
core::{
|
core::{
|
||||||
@ -944,6 +944,7 @@ mod tests {
|
|||||||
assert_eq!(meta.info.secondary_types, Vec::new());
|
assert_eq!(meta.info.secondary_types, Vec::new());
|
||||||
|
|
||||||
let info = AlbumInfo::new(
|
let info = AlbumInfo::new(
|
||||||
|
Some(AlbumStatus::Official),
|
||||||
Some(AlbumPrimaryType::Album),
|
Some(AlbumPrimaryType::Album),
|
||||||
vec![AlbumSecondaryType::Live],
|
vec![AlbumSecondaryType::Live],
|
||||||
);
|
);
|
||||||
|
@ -4,6 +4,7 @@ use std::collections::HashMap;
|
|||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
album::{
|
album::{
|
||||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
||||||
|
AlbumStatus,
|
||||||
},
|
},
|
||||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||||
musicbrainz::{MbAlbumRef, MbArtistRef},
|
musicbrainz::{MbAlbumRef, MbArtistRef},
|
||||||
|
@ -138,6 +138,7 @@ impl From<DeserializeAlbum> for Album {
|
|||||||
date: album.date.into(),
|
date: album.date.into(),
|
||||||
seq: AlbumSeq(album.seq),
|
seq: AlbumSeq(album.seq),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: None,
|
||||||
primary_type: album.primary_type.map(Into::into),
|
primary_type: album.primary_type.map(Into::into),
|
||||||
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
|
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
|
||||||
},
|
},
|
||||||
|
@ -36,6 +36,7 @@ macro_rules! full_collection {
|
|||||||
date: 1998.into(),
|
date: 1998.into(),
|
||||||
seq: AlbumSeq(1),
|
seq: AlbumSeq(1),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -100,6 +101,7 @@ macro_rules! full_collection {
|
|||||||
date: (2015, 4).into(),
|
date: (2015, 4).into(),
|
||||||
seq: AlbumSeq(1),
|
seq: AlbumSeq(1),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -168,6 +170,7 @@ macro_rules! full_collection {
|
|||||||
date: (2003, 6, 6).into(),
|
date: (2003, 6, 6).into(),
|
||||||
seq: AlbumSeq(1),
|
seq: AlbumSeq(1),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -212,6 +215,7 @@ macro_rules! full_collection {
|
|||||||
date: 2008.into(),
|
date: 2008.into(),
|
||||||
seq: AlbumSeq(3),
|
seq: AlbumSeq(3),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -256,6 +260,7 @@ macro_rules! full_collection {
|
|||||||
date: 2009.into(),
|
date: 2009.into(),
|
||||||
seq: AlbumSeq(2),
|
seq: AlbumSeq(2),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -298,6 +303,7 @@ macro_rules! full_collection {
|
|||||||
date: 2015.into(),
|
date: 2015.into(),
|
||||||
seq: AlbumSeq(4),
|
seq: AlbumSeq(4),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -354,6 +360,7 @@ macro_rules! full_collection {
|
|||||||
date: 1985.into(),
|
date: 1985.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -396,6 +403,7 @@ macro_rules! full_collection {
|
|||||||
date: 2018.into(),
|
date: 2018.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -452,6 +460,7 @@ macro_rules! full_collection {
|
|||||||
date: 1995.into(),
|
date: 1995.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -494,6 +503,7 @@ macro_rules! full_collection {
|
|||||||
date: 2028.into(),
|
date: 2028.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
|
@ -282,7 +282,7 @@ mod tests {
|
|||||||
Sequence,
|
Sequence,
|
||||||
};
|
};
|
||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
|
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
||||||
artist::{ArtistId, ArtistMeta},
|
artist::{ArtistId, ArtistMeta},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -347,6 +347,7 @@ mod tests {
|
|||||||
AlbumMeta::new(id)
|
AlbumMeta::new(id)
|
||||||
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
||||||
.with_info(AlbumInfo::new(
|
.with_info(AlbumInfo::new(
|
||||||
|
Some(AlbumStatus::Official),
|
||||||
Some(AlbumPrimaryType::Album),
|
Some(AlbumPrimaryType::Album),
|
||||||
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
||||||
))
|
))
|
||||||
|
@ -138,6 +138,7 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta {
|
|||||||
date: meta.first_release_date,
|
date: meta.first_release_date,
|
||||||
seq: AlbumSeq::default(),
|
seq: AlbumSeq::default(),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: None,
|
||||||
primary_type: meta.primary_type,
|
primary_type: meta.primary_type,
|
||||||
secondary_types: meta.secondary_types.unwrap_or_default(),
|
secondary_types: meta.secondary_types.unwrap_or_default(),
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ use std::collections::HashMap;
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{
|
album::{
|
||||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
||||||
|
AlbumStatus,
|
||||||
},
|
},
|
||||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||||
musicbrainz::{MbAlbumRef, MbArtistRef},
|
musicbrainz::{MbAlbumRef, MbArtistRef},
|
||||||
|
@ -199,7 +199,7 @@ impl IUi for Ui {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
|
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
||||||
artist::{Artist, ArtistId, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistMeta},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -361,6 +361,7 @@ mod tests {
|
|||||||
AlbumMeta::new(id)
|
AlbumMeta::new(id)
|
||||||
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
||||||
.with_info(AlbumInfo::new(
|
.with_info(AlbumInfo::new(
|
||||||
|
Some(AlbumStatus::Official),
|
||||||
Some(AlbumPrimaryType::Album),
|
Some(AlbumPrimaryType::Album),
|
||||||
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
||||||
))
|
))
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{
|
album::{
|
||||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType,
|
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType,
|
||||||
AlbumSecondaryType, AlbumSeq,
|
AlbumSecondaryType, AlbumSeq, AlbumStatus,
|
||||||
},
|
},
|
||||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||||
musicbrainz::MbArtistRef,
|
musicbrainz::MbArtistRef,
|
||||||
@ -47,6 +47,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 2011.into(),
|
date: 2011.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -240,6 +241,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 2004.into(),
|
date: 2004.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Ep),
|
primary_type: Some(AlbumPrimaryType::Ep),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -323,6 +325,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 2008.into(),
|
date: 2008.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -494,6 +497,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 2001.into(),
|
date: 2001.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -677,6 +681,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 2011.into(),
|
date: 2011.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -793,6 +798,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 1984.into(),
|
date: 1984.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![],
|
secondary_types: vec![],
|
||||||
},
|
},
|
||||||
@ -898,6 +904,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
date: 1999.into(),
|
date: 1999.into(),
|
||||||
seq: AlbumSeq(0),
|
seq: AlbumSeq(0),
|
||||||
info: AlbumInfo {
|
info: AlbumInfo {
|
||||||
|
status: Some(AlbumStatus::Official),
|
||||||
primary_type: Some(AlbumPrimaryType::Album),
|
primary_type: Some(AlbumPrimaryType::Album),
|
||||||
secondary_types: vec![AlbumSecondaryType::Live],
|
secondary_types: vec![AlbumSecondaryType::Live],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user