Ignore bootleg release groups #247
@ -27,7 +27,6 @@ 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>,
|
||||||
}
|
}
|
||||||
@ -94,23 +93,6 @@ 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 {
|
||||||
@ -256,12 +238,10 @@ 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,
|
||||||
}
|
}
|
||||||
@ -294,7 +274,6 @@ impl Merge for AlbumMeta {
|
|||||||
|
|
||||||
impl Merge for AlbumInfo {
|
impl Merge for AlbumInfo {
|
||||||
fn merge_in_place(&mut self, other: Self) {
|
fn merge_in_place(&mut self, other: Self) {
|
||||||
self.status = self.status.take().or(other.status);
|
|
||||||
self.primary_type = self.primary_type.take().or(other.primary_type);
|
self.primary_type = self.primary_type.take().or(other.primary_type);
|
||||||
if self.secondary_types.is_empty() {
|
if self.secondary_types.is_empty() {
|
||||||
self.secondary_types = other.secondary_types;
|
self.secondary_types = other.secondary_types;
|
||||||
|
@ -453,7 +453,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
collection::{
|
collection::{
|
||||||
album::{AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
album::{AlbumPrimaryType, AlbumSecondaryType},
|
||||||
musicbrainz::MbArtistRef,
|
musicbrainz::MbArtistRef,
|
||||||
},
|
},
|
||||||
core::{
|
core::{
|
||||||
@ -944,7 +944,6 @@ 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,7 +4,6 @@ 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},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
album::{AlbumDate, AlbumLibId, AlbumPrimaryType, AlbumSecondaryType},
|
||||||
musicbrainz::MbRefOption,
|
musicbrainz::MbRefOption,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,32 +59,6 @@ pub enum MbRefOptionDef<T> {
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
#[serde(remote = "AlbumStatus")]
|
|
||||||
pub enum AlbumStatusDef {
|
|
||||||
Official,
|
|
||||||
Promotion,
|
|
||||||
Bootleg,
|
|
||||||
PseudoRelease,
|
|
||||||
Withdrawn,
|
|
||||||
Cancelled,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
pub struct SerdeAlbumStatus(#[serde(with = "AlbumStatusDef")] AlbumStatus);
|
|
||||||
|
|
||||||
impl From<SerdeAlbumStatus> for AlbumStatus {
|
|
||||||
fn from(value: SerdeAlbumStatus) -> Self {
|
|
||||||
value.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AlbumStatus> for SerdeAlbumStatus {
|
|
||||||
fn from(value: AlbumStatus) -> Self {
|
|
||||||
SerdeAlbumStatus(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(remote = "AlbumPrimaryType")]
|
#[serde(remote = "AlbumPrimaryType")]
|
||||||
pub enum AlbumPrimaryTypeDef {
|
pub enum AlbumPrimaryTypeDef {
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
||||||
SerdeAlbumSecondaryType, SerdeAlbumStatus,
|
SerdeAlbumSecondaryType,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ pub struct DeserializeAlbum {
|
|||||||
date: SerdeAlbumDate,
|
date: SerdeAlbumDate,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: DeserializeMbRefOption,
|
musicbrainz: DeserializeMbRefOption,
|
||||||
status: Option<SerdeAlbumStatus>,
|
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
@ -139,7 +138,6 @@ 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: album.status.map(Into::into),
|
|
||||||
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(),
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
core::collection::{album::Album, artist::Artist, musicbrainz::IMusicBrainzRef, Collection},
|
||||||
external::database::serde::common::{
|
external::database::serde::common::{
|
||||||
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
MbRefOptionDef, SerdeAlbumDate, SerdeAlbumLibId, SerdeAlbumPrimaryType,
|
||||||
SerdeAlbumSecondaryType, SerdeAlbumStatus,
|
SerdeAlbumSecondaryType,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ pub struct SerializeAlbum<'a> {
|
|||||||
date: SerdeAlbumDate,
|
date: SerdeAlbumDate,
|
||||||
seq: u8,
|
seq: u8,
|
||||||
musicbrainz: SerializeMbRefOption<'a>,
|
musicbrainz: SerializeMbRefOption<'a>,
|
||||||
status: Option<SerdeAlbumStatus>,
|
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
secondary_types: Vec<SerdeAlbumSecondaryType>,
|
||||||
}
|
}
|
||||||
@ -98,7 +97,6 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> {
|
|||||||
date: album.meta.date.into(),
|
date: album.meta.date.into(),
|
||||||
seq: album.meta.seq.0,
|
seq: album.meta.seq.0,
|
||||||
musicbrainz: (&album.meta.id.mb_ref).into(),
|
musicbrainz: (&album.meta.id.mb_ref).into(),
|
||||||
status: album.meta.info.status.map(Into::into),
|
|
||||||
primary_type: album.meta.info.primary_type.map(Into::into),
|
primary_type: album.meta.info.primary_type.map(Into::into),
|
||||||
secondary_types: album
|
secondary_types: album
|
||||||
.meta
|
.meta
|
||||||
|
@ -4,7 +4,7 @@ use serde::{de::Visitor, Deserialize, Deserializer};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
collection::{
|
collection::{
|
||||||
album::{AlbumDate, AlbumPrimaryType, AlbumSecondaryType, AlbumStatus},
|
album::{AlbumDate, AlbumPrimaryType, AlbumSecondaryType},
|
||||||
musicbrainz::Mbid,
|
musicbrainz::Mbid,
|
||||||
Error as CollectionError,
|
Error as CollectionError,
|
||||||
},
|
},
|
||||||
@ -131,7 +131,6 @@ pub struct MbReleaseGroupMeta {
|
|||||||
pub id: Mbid,
|
pub id: Mbid,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub first_release_date: AlbumDate,
|
pub first_release_date: AlbumDate,
|
||||||
pub status: Option<AlbumStatus>,
|
|
||||||
pub primary_type: Option<AlbumPrimaryType>,
|
pub primary_type: Option<AlbumPrimaryType>,
|
||||||
pub secondary_types: Option<Vec<AlbumSecondaryType>>,
|
pub secondary_types: Option<Vec<AlbumSecondaryType>>,
|
||||||
}
|
}
|
||||||
@ -142,7 +141,6 @@ pub struct SerdeMbReleaseGroupMeta {
|
|||||||
id: SerdeMbid,
|
id: SerdeMbid,
|
||||||
title: String,
|
title: String,
|
||||||
first_release_date: SerdeAlbumDate,
|
first_release_date: SerdeAlbumDate,
|
||||||
status: Option<SerdeAlbumStatus>,
|
|
||||||
primary_type: Option<SerdeAlbumPrimaryType>,
|
primary_type: Option<SerdeAlbumPrimaryType>,
|
||||||
secondary_types: Option<Vec<SerdeAlbumSecondaryType>>,
|
secondary_types: Option<Vec<SerdeAlbumSecondaryType>>,
|
||||||
}
|
}
|
||||||
@ -153,7 +151,6 @@ impl From<SerdeMbReleaseGroupMeta> for MbReleaseGroupMeta {
|
|||||||
id: value.id.into(),
|
id: value.id.into(),
|
||||||
title: value.title,
|
title: value.title,
|
||||||
first_release_date: value.first_release_date.into(),
|
first_release_date: value.first_release_date.into(),
|
||||||
status: value.status.map(Into::into),
|
|
||||||
primary_type: value.primary_type.map(Into::into),
|
primary_type: value.primary_type.map(Into::into),
|
||||||
secondary_types: value
|
secondary_types: value
|
||||||
.secondary_types
|
.secondary_types
|
||||||
@ -284,26 +281,6 @@ impl<'de> Deserialize<'de> for SerdeAlbumDate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
#[serde(remote = "AlbumStatus", rename_all(deserialize = "kebab-case"))]
|
|
||||||
pub enum AlbumStatusDef {
|
|
||||||
Official,
|
|
||||||
Promotion,
|
|
||||||
Bootleg,
|
|
||||||
PseudoRelease,
|
|
||||||
Withdrawn,
|
|
||||||
Cancelled,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
|
||||||
pub struct SerdeAlbumStatus(#[serde(with = "AlbumStatusDef")] AlbumStatus);
|
|
||||||
|
|
||||||
impl From<SerdeAlbumStatus> for AlbumStatus {
|
|
||||||
fn from(value: SerdeAlbumStatus) -> Self {
|
|
||||||
value.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(remote = "AlbumPrimaryType")]
|
#[serde(remote = "AlbumPrimaryType")]
|
||||||
pub enum AlbumPrimaryTypeDef {
|
pub enum AlbumPrimaryTypeDef {
|
||||||
|
@ -36,7 +36,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -101,7 +100,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -170,7 +168,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -215,7 +212,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -260,7 +256,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -303,7 +298,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -360,7 +354,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -403,7 +396,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -460,7 +452,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -503,7 +494,6 @@ 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, AlbumStatus},
|
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
|
||||||
artist::{ArtistId, ArtistMeta},
|
artist::{ArtistId, ArtistMeta},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -347,7 +347,6 @@ 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,7 +138,6 @@ 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: meta.status,
|
|
||||||
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,7 +3,6 @@ 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},
|
||||||
|
@ -163,7 +163,6 @@ 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
|
||||||
@ -175,9 +174,6 @@ impl<'a, 'b> AlbumState<'a, 'b> {
|
|||||||
&a.meta.info.secondary_types
|
&a.meta.info.secondary_types
|
||||||
))
|
))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
album
|
|
||||||
.map(|a| UiDisplay::display_album_status(&a.meta.info.status))
|
|
||||||
.unwrap_or(""),
|
|
||||||
album
|
album
|
||||||
.map(|a| UiDisplay::display_album_ownership(&a.get_ownership()))
|
.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, AlbumStatus,
|
AlbumSecondaryType, AlbumSeq,
|
||||||
},
|
},
|
||||||
artist::ArtistMeta,
|
artist::ArtistMeta,
|
||||||
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
||||||
@ -50,20 +50,6 @@ impl UiDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
pub fn display_album_type(
|
||||||
primary: &Option<AlbumPrimaryType>,
|
primary: &Option<AlbumPrimaryType>,
|
||||||
secondary: &Vec<AlbumSecondaryType>,
|
secondary: &Vec<AlbumSecondaryType>,
|
||||||
@ -237,35 +223,6 @@ mod tests {
|
|||||||
assert_eq!(UiDisplay::display_date(&date, &AlbumSeq(5)), "1990 (5)");
|
assert_eq!(UiDisplay::display_date(&date, &AlbumSeq(5)), "1990 (5)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn display_album_status() {
|
|
||||||
assert_eq!(
|
|
||||||
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]
|
#[test]
|
||||||
fn display_album_primary_type() {
|
fn display_album_primary_type() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -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, AlbumStatus},
|
album::{AlbumDate, AlbumId, AlbumInfo, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType},
|
||||||
artist::{Artist, ArtistId, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistMeta},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -361,7 +361,6 @@ 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, AlbumStatus,
|
AlbumSecondaryType, AlbumSeq,
|
||||||
},
|
},
|
||||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||||
musicbrainz::MbArtistRef,
|
musicbrainz::MbArtistRef,
|
||||||
@ -47,7 +47,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -241,7 +240,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -325,7 +323,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -497,7 +494,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -681,7 +677,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -798,7 +793,6 @@ 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![],
|
||||||
},
|
},
|
||||||
@ -904,7 +898,6 @@ 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