Correct album id-info split
This commit is contained in:
parent
7934d7eccf
commit
fdd6d13146
@ -19,14 +19,14 @@ pub struct Album {
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct AlbumMeta {
|
||||
pub id: AlbumId,
|
||||
pub date: AlbumDate,
|
||||
pub seq: AlbumSeq,
|
||||
pub info: AlbumInfo,
|
||||
}
|
||||
|
||||
/// Album non-identifier metadata.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct AlbumInfo {
|
||||
pub date: AlbumDate,
|
||||
pub seq: AlbumSeq,
|
||||
pub primary_type: Option<AlbumPrimaryType>,
|
||||
pub secondary_types: Vec<AlbumSecondaryType>,
|
||||
}
|
||||
@ -93,6 +93,12 @@ impl From<(u32, u8, u8)> for AlbumDate {
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||
pub struct AlbumSeq(pub u8);
|
||||
|
||||
impl From<u8> for AlbumSeq {
|
||||
fn from(value: u8) -> Self {
|
||||
AlbumSeq(value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Based on [MusicBrainz types](https://musicbrainz.org/doc/Release_Group/Type).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum AlbumPrimaryType {
|
||||
@ -181,7 +187,7 @@ impl Album {
|
||||
}
|
||||
|
||||
pub fn with_date<Date: Into<AlbumDate>>(mut self, date: Date) -> Self {
|
||||
self.meta.date = date.into();
|
||||
self.meta.info.date = date.into();
|
||||
self
|
||||
}
|
||||
|
||||
@ -214,14 +220,12 @@ impl AlbumMeta {
|
||||
pub fn new<Id: Into<AlbumId>>(id: Id) -> Self {
|
||||
AlbumMeta {
|
||||
id: id.into(),
|
||||
date: AlbumDate::default(),
|
||||
seq: AlbumSeq::default(),
|
||||
info: AlbumInfo::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_date<Date: Into<AlbumDate>>(mut self, date: Date) -> Self {
|
||||
self.date = date.into();
|
||||
self.info.date = date.into();
|
||||
self
|
||||
}
|
||||
|
||||
@ -232,8 +236,8 @@ impl AlbumMeta {
|
||||
|
||||
pub fn get_sort_key(&self) -> (&AlbumDate, &AlbumSeq, &str, &Option<AlbumPrimaryType>) {
|
||||
(
|
||||
&self.date,
|
||||
&self.seq,
|
||||
&self.info.date,
|
||||
&self.info.seq,
|
||||
&self.id.title,
|
||||
&self.info.primary_type,
|
||||
)
|
||||
@ -247,6 +251,36 @@ impl AlbumMeta {
|
||||
self.id.clear_mb_ref();
|
||||
}
|
||||
|
||||
pub fn set_seq(&mut self, seq: AlbumSeq) {
|
||||
self.info.set_seq(seq);
|
||||
}
|
||||
|
||||
pub fn clear_seq(&mut self) {
|
||||
self.info.clear_seq();
|
||||
}
|
||||
}
|
||||
|
||||
impl AlbumInfo {
|
||||
pub fn with_date<Date: Into<AlbumDate>>(mut self, date: Date) -> Self {
|
||||
self.date = date.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_seq<Seq: Into<AlbumSeq>>(mut self, seq: Seq) -> Self {
|
||||
self.seq = seq.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_primary_type(mut self, primary_type: AlbumPrimaryType) -> Self {
|
||||
self.primary_type = Some(primary_type);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_secondary_types(mut self, secondary_types: Vec<AlbumSecondaryType>) -> Self {
|
||||
self.secondary_types = secondary_types;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_seq(&mut self, seq: AlbumSeq) {
|
||||
self.seq = seq;
|
||||
}
|
||||
@ -256,18 +290,6 @@ impl AlbumMeta {
|
||||
}
|
||||
}
|
||||
|
||||
impl AlbumInfo {
|
||||
pub fn new(
|
||||
primary_type: Option<AlbumPrimaryType>,
|
||||
secondary_types: Vec<AlbumSecondaryType>,
|
||||
) -> Self {
|
||||
AlbumInfo {
|
||||
primary_type,
|
||||
secondary_types,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for AlbumMeta {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
@ -284,16 +306,16 @@ impl Merge for AlbumMeta {
|
||||
fn merge_in_place(&mut self, other: Self) {
|
||||
assert!(self.id.compatible(&other.id));
|
||||
self.id.mb_ref = self.id.mb_ref.take().or(other.id.mb_ref);
|
||||
if self.date.year.is_none() && other.date.year.is_some() {
|
||||
self.date = other.date;
|
||||
}
|
||||
self.seq = std::cmp::max(self.seq, other.seq);
|
||||
self.info.merge_in_place(other.info);
|
||||
}
|
||||
}
|
||||
|
||||
impl Merge for AlbumInfo {
|
||||
fn merge_in_place(&mut self, other: Self) {
|
||||
if self.date.year.is_none() && other.date.year.is_some() {
|
||||
self.date = other.date;
|
||||
}
|
||||
self.seq = std::cmp::max(self.seq, other.seq);
|
||||
self.primary_type = self.primary_type.take().or(other.primary_type);
|
||||
if self.secondary_types.is_empty() {
|
||||
self.secondary_types = other.secondary_types;
|
||||
@ -385,21 +407,21 @@ mod tests {
|
||||
fn set_clear_seq() {
|
||||
let mut album = Album::new("An album");
|
||||
|
||||
assert_eq!(album.meta.seq, AlbumSeq(0));
|
||||
assert_eq!(album.meta.info.seq, AlbumSeq(0));
|
||||
|
||||
// Setting a seq on an album.
|
||||
album.meta.set_seq(AlbumSeq(6));
|
||||
assert_eq!(album.meta.seq, AlbumSeq(6));
|
||||
assert_eq!(album.meta.info.seq, AlbumSeq(6));
|
||||
|
||||
album.meta.set_seq(AlbumSeq(6));
|
||||
assert_eq!(album.meta.seq, AlbumSeq(6));
|
||||
assert_eq!(album.meta.info.seq, AlbumSeq(6));
|
||||
|
||||
album.meta.set_seq(AlbumSeq(8));
|
||||
assert_eq!(album.meta.seq, AlbumSeq(8));
|
||||
assert_eq!(album.meta.info.seq, AlbumSeq(8));
|
||||
|
||||
// Clearing seq.
|
||||
album.meta.clear_seq();
|
||||
assert_eq!(album.meta.seq, AlbumSeq(0));
|
||||
assert_eq!(album.meta.info.seq, AlbumSeq(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -439,7 +461,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn merge_album_dates() {
|
||||
let meta = AlbumMeta::new(AlbumId::new("An album"));
|
||||
let meta = AlbumInfo::default();
|
||||
|
||||
// No merge if years are different.
|
||||
let left = meta.clone().with_date((2000, 1, 6));
|
||||
|
@ -554,10 +554,9 @@ mod tests {
|
||||
assert_eq!(meta.info.primary_type, None);
|
||||
assert_eq!(meta.info.secondary_types, Vec::new());
|
||||
|
||||
let info = AlbumInfo::new(
|
||||
Some(AlbumPrimaryType::Album),
|
||||
vec![AlbumSecondaryType::Live],
|
||||
);
|
||||
let info = AlbumInfo::default()
|
||||
.with_primary_type(AlbumPrimaryType::Album)
|
||||
.with_secondary_types(vec![AlbumSecondaryType::Live]);
|
||||
|
||||
// Seting info on an album not belonging to the artist is an error.
|
||||
assert!(music_hoard
|
||||
|
@ -2,9 +2,7 @@ use once_cell::sync::Lazy;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::core::collection::{
|
||||
album::{
|
||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
||||
},
|
||||
album::{Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType},
|
||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||
musicbrainz::{MbAlbumRef, MbArtistRef},
|
||||
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
||||
|
@ -141,9 +141,9 @@ impl From<DeserializeAlbum> for Album {
|
||||
lib_id: album.lib_id.into(),
|
||||
mb_ref: album.mb_ref.into(),
|
||||
},
|
||||
info: AlbumInfo {
|
||||
date: album.date.into(),
|
||||
seq: AlbumSeq(album.seq),
|
||||
info: AlbumInfo {
|
||||
primary_type: album.primary_type.map(Into::into),
|
||||
secondary_types: album.secondary_types.into_iter().map(Into::into).collect(),
|
||||
},
|
||||
|
@ -89,8 +89,8 @@ impl<'a> From<&'a Album> for SerializeAlbum<'a> {
|
||||
title: &album.meta.id.title,
|
||||
lib_id: album.meta.id.lib_id.into(),
|
||||
mb_ref: (&album.meta.id.mb_ref).into(),
|
||||
date: album.meta.date.into(),
|
||||
seq: album.meta.seq.0,
|
||||
date: album.meta.info.date.into(),
|
||||
seq: album.meta.info.seq.0,
|
||||
primary_type: album.meta.info.primary_type.map(Into::into),
|
||||
secondary_types: album
|
||||
.meta
|
||||
|
@ -33,12 +33,10 @@ macro_rules! full_collection {
|
||||
"https://musicbrainz.org/release-group/00000000-0000-0000-0000-000000000000"
|
||||
).unwrap()),
|
||||
},
|
||||
date: 1998.into(),
|
||||
seq: AlbumSeq(1),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(1998)
|
||||
.with_seq(1)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -97,12 +95,10 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(2),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: (2015, 4).into(),
|
||||
seq: AlbumSeq(1),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date((2015, 4))
|
||||
.with_seq(1)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -165,12 +161,10 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(3),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: (2003, 6, 6).into(),
|
||||
seq: AlbumSeq(1),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date((2003, 6, 6))
|
||||
.with_seq(1)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -209,12 +203,10 @@ macro_rules! full_collection {
|
||||
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111111"
|
||||
).unwrap()),
|
||||
},
|
||||
date: 2008.into(),
|
||||
seq: AlbumSeq(3),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2008)
|
||||
.with_seq(3)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -253,12 +245,10 @@ macro_rules! full_collection {
|
||||
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111112"
|
||||
).unwrap()),
|
||||
},
|
||||
date: 2009.into(),
|
||||
seq: AlbumSeq(2),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2009)
|
||||
.with_seq(2)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -295,12 +285,10 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(6),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2015.into(),
|
||||
seq: AlbumSeq(4),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2015)
|
||||
.with_seq(4)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -351,12 +339,9 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(7),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1985.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(1985)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -393,12 +378,9 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(8),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2018.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2018)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -449,12 +431,9 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(9),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1995.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(1995)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -491,12 +470,9 @@ macro_rules! full_collection {
|
||||
lib_id: AlbumLibId::Value(10),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2028.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2028)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
|
@ -21,9 +21,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(1),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1998.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(1998),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -82,9 +80,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(2),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: (2015, 4).into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date((2015, 4)),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -132,9 +128,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(3),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: (2003, 6, 6).into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date((2003, 6, 6)),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -171,9 +165,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(4),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2008.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2008),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -210,9 +202,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(5),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2009.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2009),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -249,9 +239,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(6),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2015.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2015),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -302,9 +290,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(7),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1985.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(1985),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -341,9 +327,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(8),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2018.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2018),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -394,9 +378,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(9),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1995.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(1995),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -433,9 +415,7 @@ macro_rules! library_collection {
|
||||
lib_id: AlbumLibId::Value(10),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2028.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2028),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
|
@ -393,10 +393,14 @@ mod tests {
|
||||
fn album_meta(id: AlbumId) -> AlbumMeta {
|
||||
AlbumMeta::new(id)
|
||||
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
||||
.with_info(AlbumInfo::new(
|
||||
Some(AlbumPrimaryType::Album),
|
||||
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
||||
))
|
||||
.with_info(
|
||||
AlbumInfo::default()
|
||||
.with_primary_type(AlbumPrimaryType::Album)
|
||||
.with_secondary_types(vec![
|
||||
AlbumSecondaryType::Live,
|
||||
AlbumSecondaryType::Compilation,
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
fn album_match() -> EntityMatches {
|
||||
|
@ -75,7 +75,7 @@ impl<Http: IMusicBrainzHttp> IMusicBrainz for MusicBrainz<Http> {
|
||||
) -> Result<Vec<Entity<AlbumMeta>>, Error> {
|
||||
// Some release groups may have a promotional early release messing up the search. Searching
|
||||
// with just the year should be enough anyway.
|
||||
let date = AlbumDate::new(album.date.year, None, None);
|
||||
let date = AlbumDate::new(album.info.date.year, None, None);
|
||||
|
||||
let query = SearchReleaseGroupRequest::new()
|
||||
.arid(arid)
|
||||
@ -135,9 +135,9 @@ fn from_mb_release_group_meta(meta: MbReleaseGroupMeta) -> AlbumMeta {
|
||||
lib_id: AlbumLibId::None,
|
||||
mb_ref: AlbumMbRef::Some(meta.id.into()),
|
||||
},
|
||||
info: AlbumInfo {
|
||||
date: meta.first_release_date,
|
||||
seq: AlbumSeq::default(),
|
||||
info: AlbumInfo {
|
||||
primary_type: meta.primary_type,
|
||||
secondary_types: meta.secondary_types.unwrap_or_default(),
|
||||
},
|
||||
|
@ -1,9 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use musichoard::collection::{
|
||||
album::{
|
||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType, AlbumSeq,
|
||||
},
|
||||
album::{Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType},
|
||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||
musicbrainz::{MbAlbumRef, MbArtistRef},
|
||||
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
||||
|
@ -166,7 +166,7 @@ impl<'a, 'b> AlbumState<'a, 'b> {
|
||||
Ownership: {}",
|
||||
album.map(|a| a.meta.id.title.as_str()).unwrap_or(""),
|
||||
album
|
||||
.map(|a| UiDisplay::display_date(&a.meta.date, &a.meta.seq))
|
||||
.map(|a| UiDisplay::display_date(&a.meta.info.date, &a.meta.info.seq))
|
||||
.unwrap_or_default(),
|
||||
album
|
||||
.map(|a| UiDisplay::display_album_type(
|
||||
|
@ -171,7 +171,7 @@ impl UiDisplay {
|
||||
fn display_option_album(album: &AlbumMeta, _disambiguation: &Option<String>) -> String {
|
||||
format!(
|
||||
"{:010} | {} [{}]",
|
||||
UiDisplay::display_album_date(&album.date),
|
||||
UiDisplay::display_album_date(&album.info.date),
|
||||
album.id.title,
|
||||
UiDisplay::display_album_type(&album.info.primary_type, &album.info.secondary_types),
|
||||
)
|
||||
|
@ -360,10 +360,14 @@ mod tests {
|
||||
fn album_meta(id: AlbumId) -> AlbumMeta {
|
||||
AlbumMeta::new(id)
|
||||
.with_date(AlbumDate::new(Some(1990), Some(5), None))
|
||||
.with_info(AlbumInfo::new(
|
||||
Some(AlbumPrimaryType::Album),
|
||||
vec![AlbumSecondaryType::Live, AlbumSecondaryType::Compilation],
|
||||
))
|
||||
.with_info(
|
||||
AlbumInfo::default()
|
||||
.with_primary_type(AlbumPrimaryType::Album)
|
||||
.with_secondary_types(vec![
|
||||
AlbumSecondaryType::Live,
|
||||
AlbumSecondaryType::Compilation,
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
fn album_matches() -> EntityMatches {
|
||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
||||
use musichoard::collection::{
|
||||
album::{
|
||||
Album, AlbumId, AlbumInfo, AlbumLibId, AlbumMbRef, AlbumMeta, AlbumPrimaryType,
|
||||
AlbumSecondaryType, AlbumSeq,
|
||||
AlbumSecondaryType,
|
||||
},
|
||||
artist::{Artist, ArtistId, ArtistInfo, ArtistMbRef, ArtistMeta},
|
||||
musicbrainz::MbArtistRef,
|
||||
@ -44,12 +44,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(7),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2011.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2011)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -237,12 +234,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(1),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2004.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Ep),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2004)
|
||||
.with_primary_type(AlbumPrimaryType::Ep),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -320,12 +314,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(2),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2008.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2008)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -491,12 +482,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(3),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2001.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2001)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -650,9 +638,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Singleton,
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2011.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo::default(),
|
||||
info: AlbumInfo::default().with_date(2011),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -674,12 +660,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(4),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 2011.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(2011)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -790,12 +773,9 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(5),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1984.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(1984)
|
||||
.with_primary_type(AlbumPrimaryType::Album),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
@ -895,12 +875,10 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
||||
lib_id: AlbumLibId::Value(6),
|
||||
mb_ref: AlbumMbRef::None,
|
||||
},
|
||||
date: 1999.into(),
|
||||
seq: AlbumSeq(0),
|
||||
info: AlbumInfo {
|
||||
primary_type: Some(AlbumPrimaryType::Album),
|
||||
secondary_types: vec![AlbumSecondaryType::Live],
|
||||
},
|
||||
info: AlbumInfo::default()
|
||||
.with_date(1999)
|
||||
.with_primary_type(AlbumPrimaryType::Album)
|
||||
.with_secondary_types(vec![AlbumSecondaryType::Live]),
|
||||
},
|
||||
tracks: vec![
|
||||
Track {
|
||||
|
Loading…
x
Reference in New Issue
Block a user