Break down the musichoard files #165
@ -5,7 +5,7 @@ use std::{
|
|||||||
|
|
||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
merge::{Merge, MergeSorted, WithId},
|
merge::{Merge, MergeSorted, WithId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
track::{Track, TrackFormat},
|
track::{Track, TrackFormat},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ pub struct Album {
|
|||||||
pub id: AlbumId,
|
pub id: AlbumId,
|
||||||
pub date: AlbumDate,
|
pub date: AlbumDate,
|
||||||
pub seq: AlbumSeq,
|
pub seq: AlbumSeq,
|
||||||
pub musicbrainz: Option<MusicBrainz>,
|
pub musicbrainz: Option<MusicBrainzUrl>,
|
||||||
pub tracks: Vec<Track>,
|
pub tracks: Vec<Track>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
album::Album,
|
album::Album,
|
||||||
merge::{Merge, MergeCollections, WithId},
|
merge::{Merge, MergeCollections, WithId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An artist.
|
/// An artist.
|
||||||
@ -15,7 +15,7 @@ use crate::core::collection::{
|
|||||||
pub struct Artist {
|
pub struct Artist {
|
||||||
pub id: ArtistId,
|
pub id: ArtistId,
|
||||||
pub sort: Option<ArtistId>,
|
pub sort: Option<ArtistId>,
|
||||||
pub musicbrainz: Option<MusicBrainz>,
|
pub musicbrainz: Option<MusicBrainzUrl>,
|
||||||
pub properties: HashMap<String, Vec<String>>,
|
pub properties: HashMap<String, Vec<String>>,
|
||||||
pub albums: Vec<Album>,
|
pub albums: Vec<Album>,
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ impl Artist {
|
|||||||
_ = self.sort.take();
|
_ = self.sort.take();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_musicbrainz_url(&mut self, url: MusicBrainz) {
|
pub fn set_musicbrainz_url(&mut self, url: MusicBrainzUrl) {
|
||||||
_ = self.musicbrainz.insert(url);
|
_ = self.musicbrainz.insert(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,19 +216,19 @@ mod tests {
|
|||||||
fn set_clear_musicbrainz_url() {
|
fn set_clear_musicbrainz_url() {
|
||||||
let mut artist = Artist::new(ArtistId::new("an artist"));
|
let mut artist = Artist::new(ArtistId::new("an artist"));
|
||||||
|
|
||||||
let mut expected: Option<MusicBrainz> = None;
|
let mut expected: Option<MusicBrainzUrl> = None;
|
||||||
assert_eq!(artist.musicbrainz, expected);
|
assert_eq!(artist.musicbrainz, expected);
|
||||||
|
|
||||||
// Setting a URL on an artist.
|
// Setting a URL on an artist.
|
||||||
artist.set_musicbrainz_url(MusicBrainz::artist_from_str(MUSICBRAINZ).unwrap());
|
artist.set_musicbrainz_url(MusicBrainzUrl::artist_from_str(MUSICBRAINZ).unwrap());
|
||||||
_ = expected.insert(MusicBrainz::artist_from_str(MUSICBRAINZ).unwrap());
|
_ = expected.insert(MusicBrainzUrl::artist_from_str(MUSICBRAINZ).unwrap());
|
||||||
assert_eq!(artist.musicbrainz, expected);
|
assert_eq!(artist.musicbrainz, expected);
|
||||||
|
|
||||||
artist.set_musicbrainz_url(MusicBrainz::artist_from_str(MUSICBRAINZ).unwrap());
|
artist.set_musicbrainz_url(MusicBrainzUrl::artist_from_str(MUSICBRAINZ).unwrap());
|
||||||
assert_eq!(artist.musicbrainz, expected);
|
assert_eq!(artist.musicbrainz, expected);
|
||||||
|
|
||||||
artist.set_musicbrainz_url(MusicBrainz::artist_from_str(MUSICBRAINZ_2).unwrap());
|
artist.set_musicbrainz_url(MusicBrainzUrl::artist_from_str(MUSICBRAINZ_2).unwrap());
|
||||||
_ = expected.insert(MusicBrainz::artist_from_str(MUSICBRAINZ_2).unwrap());
|
_ = expected.insert(MusicBrainzUrl::artist_from_str(MUSICBRAINZ_2).unwrap());
|
||||||
assert_eq!(artist.musicbrainz, expected);
|
assert_eq!(artist.musicbrainz, expected);
|
||||||
|
|
||||||
// Clearing URLs.
|
// Clearing URLs.
|
||||||
|
@ -5,17 +5,16 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use crate::core::collection::Error;
|
use crate::core::collection::Error;
|
||||||
|
|
||||||
/// An object with the [`IMbid`] trait contains a [MusicBrainz
|
|
||||||
/// Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier) (MBID).
|
|
||||||
pub trait IMbid {
|
|
||||||
fn mbid(&self) -> &str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// MusicBrainz reference.
|
/// MusicBrainz reference.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct MusicBrainz(Url);
|
pub struct MusicBrainzUrl(Url);
|
||||||
|
|
||||||
|
impl MusicBrainzUrl {
|
||||||
|
pub fn mbid(&self) -> &str {
|
||||||
|
// The URL is assumed to have been validated.
|
||||||
|
self.0.path_segments().and_then(|mut ps| ps.nth(1)).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
impl MusicBrainz {
|
|
||||||
pub fn artist_from_str<S: AsRef<str>>(url: S) -> Result<Self, Error> {
|
pub fn artist_from_str<S: AsRef<str>>(url: S) -> Result<Self, Error> {
|
||||||
Self::artist_from_url(url.as_ref().try_into()?)
|
Self::artist_from_url(url.as_ref().try_into()?)
|
||||||
}
|
}
|
||||||
@ -52,7 +51,7 @@ impl MusicBrainz {
|
|||||||
None => return Err(Self::invalid_url_error(url, mb_type)),
|
None => return Err(Self::invalid_url_error(url, mb_type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(MusicBrainz(url))
|
Ok(MusicBrainzUrl(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invalid_url_error<U: Display>(url: U, mb_type: &str) -> Error {
|
fn invalid_url_error<U: Display>(url: U, mb_type: &str) -> Error {
|
||||||
@ -60,19 +59,12 @@ impl MusicBrainz {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for MusicBrainz {
|
impl AsRef<str> for MusicBrainzUrl {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
self.0.as_ref()
|
self.0.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IMbid for MusicBrainz {
|
|
||||||
fn mbid(&self) -> &str {
|
|
||||||
// The URL is assumed to have been validated.
|
|
||||||
self.0.path_segments().and_then(|mut ps| ps.nth(1)).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -82,12 +74,12 @@ mod tests {
|
|||||||
let uuid = "d368baa8-21ca-4759-9731-0b2753071ad8";
|
let uuid = "d368baa8-21ca-4759-9731-0b2753071ad8";
|
||||||
let url_str = format!("https://musicbrainz.org/artist/{uuid}");
|
let url_str = format!("https://musicbrainz.org/artist/{uuid}");
|
||||||
|
|
||||||
let mb = MusicBrainz::artist_from_str(&url_str).unwrap();
|
let mb = MusicBrainzUrl::artist_from_str(&url_str).unwrap();
|
||||||
assert_eq!(url_str, mb.as_ref());
|
assert_eq!(url_str, mb.as_ref());
|
||||||
assert_eq!(uuid, mb.mbid());
|
assert_eq!(uuid, mb.mbid());
|
||||||
|
|
||||||
let url: Url = url_str.as_str().try_into().unwrap();
|
let url: Url = url_str.as_str().try_into().unwrap();
|
||||||
let mb = MusicBrainz::artist_from_url(url).unwrap();
|
let mb = MusicBrainzUrl::artist_from_url(url).unwrap();
|
||||||
assert_eq!(url_str, mb.as_ref());
|
assert_eq!(url_str, mb.as_ref());
|
||||||
assert_eq!(uuid, mb.mbid());
|
assert_eq!(uuid, mb.mbid());
|
||||||
}
|
}
|
||||||
@ -97,12 +89,12 @@ mod tests {
|
|||||||
let uuid = "d368baa8-21ca-4759-9731-0b2753071ad8";
|
let uuid = "d368baa8-21ca-4759-9731-0b2753071ad8";
|
||||||
let url_str = format!("https://musicbrainz.org/release-group/{uuid}");
|
let url_str = format!("https://musicbrainz.org/release-group/{uuid}");
|
||||||
|
|
||||||
let mb = MusicBrainz::album_from_str(&url_str).unwrap();
|
let mb = MusicBrainzUrl::album_from_str(&url_str).unwrap();
|
||||||
assert_eq!(url_str, mb.as_ref());
|
assert_eq!(url_str, mb.as_ref());
|
||||||
assert_eq!(uuid, mb.mbid());
|
assert_eq!(uuid, mb.mbid());
|
||||||
|
|
||||||
let url: Url = url_str.as_str().try_into().unwrap();
|
let url: Url = url_str.as_str().try_into().unwrap();
|
||||||
let mb = MusicBrainz::album_from_url(url).unwrap();
|
let mb = MusicBrainzUrl::album_from_url(url).unwrap();
|
||||||
assert_eq!(url_str, mb.as_ref());
|
assert_eq!(url_str, mb.as_ref());
|
||||||
assert_eq!(uuid, mb.mbid());
|
assert_eq!(uuid, mb.mbid());
|
||||||
}
|
}
|
||||||
@ -111,7 +103,7 @@ mod tests {
|
|||||||
fn not_a_url() {
|
fn not_a_url() {
|
||||||
let url = "not a url at all";
|
let url = "not a url at all";
|
||||||
let expected_error: Error = url::ParseError::RelativeUrlWithoutBase.into();
|
let expected_error: Error = url::ParseError::RelativeUrlWithoutBase.into();
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -120,7 +112,7 @@ mod tests {
|
|||||||
fn invalid_url() {
|
fn invalid_url() {
|
||||||
let url = "https://www.musicbutler.io/artist-page/483340948";
|
let url = "https://www.musicbutler.io/artist-page/483340948";
|
||||||
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -129,7 +121,7 @@ mod tests {
|
|||||||
fn artist_invalid_type() {
|
fn artist_invalid_type() {
|
||||||
let url = "https://musicbrainz.org/release-group/i-am-not-a-uuid";
|
let url = "https://musicbrainz.org/release-group/i-am-not-a-uuid";
|
||||||
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -139,7 +131,7 @@ mod tests {
|
|||||||
let url = "https://musicbrainz.org/artist/i-am-not-a-uuid";
|
let url = "https://musicbrainz.org/artist/i-am-not-a-uuid";
|
||||||
let expected_error =
|
let expected_error =
|
||||||
Error::UrlError(format!("invalid release-group MusicBrainz URL: {url}"));
|
Error::UrlError(format!("invalid release-group MusicBrainz URL: {url}"));
|
||||||
let actual_error = MusicBrainz::album_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::album_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -148,7 +140,7 @@ mod tests {
|
|||||||
fn invalid_uuid() {
|
fn invalid_uuid() {
|
||||||
let url = "https://musicbrainz.org/artist/i-am-not-a-uuid";
|
let url = "https://musicbrainz.org/artist/i-am-not-a-uuid";
|
||||||
let expected_error: Error = Uuid::try_parse("i-am-not-a-uuid").unwrap_err().into();
|
let expected_error: Error = Uuid::try_parse("i-am-not-a-uuid").unwrap_err().into();
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -157,7 +149,7 @@ mod tests {
|
|||||||
fn missing_type() {
|
fn missing_type() {
|
||||||
let url = "https://musicbrainz.org";
|
let url = "https://musicbrainz.org";
|
||||||
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}/"));
|
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}/"));
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
@ -166,7 +158,7 @@ mod tests {
|
|||||||
fn missing_uuid() {
|
fn missing_uuid() {
|
||||||
let url = "https://musicbrainz.org/artist";
|
let url = "https://musicbrainz.org/artist";
|
||||||
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
let expected_error = Error::UrlError(format!("invalid artist MusicBrainz URL: {url}"));
|
||||||
let actual_error = MusicBrainz::artist_from_str(url).unwrap_err();
|
let actual_error = MusicBrainzUrl::artist_from_str(url).unwrap_err();
|
||||||
assert_eq!(actual_error, expected_error);
|
assert_eq!(actual_error, expected_error);
|
||||||
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
assert_eq!(actual_error.to_string(), expected_error.to_string());
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use crate::core::{
|
|||||||
collection::{
|
collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumSeq},
|
album::{Album, AlbumDate, AlbumId, AlbumSeq},
|
||||||
artist::{Artist, ArtistId},
|
artist::{Artist, ArtistId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
track::{Track, TrackId, TrackNum, TrackQuality},
|
track::{Track, TrackId, TrackNum, TrackQuality},
|
||||||
Collection, MergeCollections,
|
Collection, MergeCollections,
|
||||||
},
|
},
|
||||||
@ -360,7 +360,7 @@ impl<LIB, DB: IDatabase> MusicHoard<LIB, DB> {
|
|||||||
artist_id: Id,
|
artist_id: Id,
|
||||||
url: S,
|
url: S,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let mb = MusicBrainz::artist_from_str(url)?;
|
let mb = MusicBrainzUrl::artist_from_str(url)?;
|
||||||
self.update_artist(artist_id.as_ref(), |artist| artist.set_musicbrainz_url(mb))
|
self.update_artist(artist_id.as_ref(), |artist| artist.set_musicbrainz_url(mb))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ mod tests {
|
|||||||
use mockall::{predicate, Sequence};
|
use mockall::{predicate, Sequence};
|
||||||
|
|
||||||
use crate::core::{
|
use crate::core::{
|
||||||
collection::{artist::ArtistId, musicbrainz::MusicBrainz},
|
collection::{artist::ArtistId, musicbrainz::MusicBrainzUrl},
|
||||||
interface::{
|
interface::{
|
||||||
database::{self, MockIDatabase},
|
database::{self, MockIDatabase},
|
||||||
library::{self, testmod::LIBRARY_ITEMS, MockILibrary},
|
library::{self, testmod::LIBRARY_ITEMS, MockILibrary},
|
||||||
@ -614,7 +614,7 @@ mod tests {
|
|||||||
|
|
||||||
assert!(music_hoard.add_artist(artist_id.clone()).is_ok());
|
assert!(music_hoard.add_artist(artist_id.clone()).is_ok());
|
||||||
|
|
||||||
let mut expected: Option<MusicBrainz> = None;
|
let mut expected: Option<MusicBrainzUrl> = None;
|
||||||
assert_eq!(music_hoard.collection[0].musicbrainz, expected);
|
assert_eq!(music_hoard.collection[0].musicbrainz, expected);
|
||||||
|
|
||||||
// Setting a URL on an artist not in the collection is an error.
|
// Setting a URL on an artist not in the collection is an error.
|
||||||
@ -627,7 +627,7 @@ mod tests {
|
|||||||
assert!(music_hoard
|
assert!(music_hoard
|
||||||
.set_artist_musicbrainz(&artist_id, MUSICBRAINZ)
|
.set_artist_musicbrainz(&artist_id, MUSICBRAINZ)
|
||||||
.is_ok());
|
.is_ok());
|
||||||
_ = expected.insert(MusicBrainz::artist_from_str(MUSICBRAINZ).unwrap());
|
_ = expected.insert(MusicBrainzUrl::artist_from_str(MUSICBRAINZ).unwrap());
|
||||||
assert_eq!(music_hoard.collection[0].musicbrainz, expected);
|
assert_eq!(music_hoard.collection[0].musicbrainz, expected);
|
||||||
|
|
||||||
// Clearing URLs on an artist that does not exist is an error.
|
// Clearing URLs on an artist that does not exist is an error.
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||||||
use crate::core::collection::{
|
use crate::core::collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
||||||
artist::{Artist, ArtistId},
|
artist::{Artist, ArtistId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
||||||
};
|
};
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
|
@ -6,7 +6,7 @@ use crate::core::{
|
|||||||
collection::{
|
collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumSeq},
|
album::{Album, AlbumDate, AlbumId, AlbumSeq},
|
||||||
artist::{Artist, ArtistId},
|
artist::{Artist, ArtistId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
Collection,
|
Collection,
|
||||||
},
|
},
|
||||||
interface::database::LoadError,
|
interface::database::LoadError,
|
||||||
@ -55,7 +55,7 @@ impl TryFrom<DeserializeArtist> for Artist {
|
|||||||
sort: artist.sort.map(ArtistId::new),
|
sort: artist.sort.map(ArtistId::new),
|
||||||
musicbrainz: artist
|
musicbrainz: artist
|
||||||
.musicbrainz
|
.musicbrainz
|
||||||
.map(MusicBrainz::artist_from_str)
|
.map(MusicBrainzUrl::artist_from_str)
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
properties: artist.properties,
|
properties: artist.properties,
|
||||||
albums: artist
|
albums: artist
|
||||||
@ -77,7 +77,7 @@ impl TryFrom<DeserializeAlbum> for Album {
|
|||||||
seq: AlbumSeq(album.seq),
|
seq: AlbumSeq(album.seq),
|
||||||
musicbrainz: album
|
musicbrainz: album
|
||||||
.musicbrainz
|
.musicbrainz
|
||||||
.map(MusicBrainz::album_from_str)
|
.map(MusicBrainzUrl::album_from_str)
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
tracks: vec![],
|
tracks: vec![],
|
||||||
})
|
})
|
||||||
|
12
src/tests.rs
12
src/tests.rs
@ -464,7 +464,7 @@ macro_rules! full_collection {
|
|||||||
let artist_a = iter.next().unwrap();
|
let artist_a = iter.next().unwrap();
|
||||||
assert_eq!(artist_a.id.name, "Album_Artist ‘A’");
|
assert_eq!(artist_a.id.name, "Album_Artist ‘A’");
|
||||||
|
|
||||||
artist_a.musicbrainz = Some(MusicBrainz::artist_from_str(
|
artist_a.musicbrainz = Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/00000000-0000-0000-0000-000000000000",
|
"https://musicbrainz.org/artist/00000000-0000-0000-0000-000000000000",
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
@ -482,14 +482,14 @@ macro_rules! full_collection {
|
|||||||
artist_a.albums[0].seq = AlbumSeq(1);
|
artist_a.albums[0].seq = AlbumSeq(1);
|
||||||
artist_a.albums[1].seq = AlbumSeq(1);
|
artist_a.albums[1].seq = AlbumSeq(1);
|
||||||
|
|
||||||
artist_a.albums[0].musicbrainz = Some(MusicBrainz::album_from_str(
|
artist_a.albums[0].musicbrainz = Some(MusicBrainzUrl::album_from_str(
|
||||||
"https://musicbrainz.org/release-group/00000000-0000-0000-0000-000000000000"
|
"https://musicbrainz.org/release-group/00000000-0000-0000-0000-000000000000"
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
let artist_b = iter.next().unwrap();
|
let artist_b = iter.next().unwrap();
|
||||||
assert_eq!(artist_b.id.name, "Album_Artist ‘B’");
|
assert_eq!(artist_b.id.name, "Album_Artist ‘B’");
|
||||||
|
|
||||||
artist_b.musicbrainz = Some(MusicBrainz::artist_from_str(
|
artist_b.musicbrainz = Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
|
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
@ -511,18 +511,18 @@ macro_rules! full_collection {
|
|||||||
artist_b.albums[2].seq = AlbumSeq(2);
|
artist_b.albums[2].seq = AlbumSeq(2);
|
||||||
artist_b.albums[3].seq = AlbumSeq(4);
|
artist_b.albums[3].seq = AlbumSeq(4);
|
||||||
|
|
||||||
artist_b.albums[1].musicbrainz = Some(MusicBrainz::album_from_str(
|
artist_b.albums[1].musicbrainz = Some(MusicBrainzUrl::album_from_str(
|
||||||
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111111"
|
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111111"
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
artist_b.albums[2].musicbrainz = Some(MusicBrainz::album_from_str(
|
artist_b.albums[2].musicbrainz = Some(MusicBrainzUrl::album_from_str(
|
||||||
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111112"
|
"https://musicbrainz.org/release-group/11111111-1111-1111-1111-111111111112"
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
let artist_c = iter.next().unwrap();
|
let artist_c = iter.next().unwrap();
|
||||||
assert_eq!(artist_c.id.name, "The Album_Artist ‘C’");
|
assert_eq!(artist_c.id.name, "The Album_Artist ‘C’");
|
||||||
|
|
||||||
artist_c.musicbrainz = Some(MusicBrainz::artist_from_str(
|
artist_c.musicbrainz = Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
|
"https://musicbrainz.org/artist/11111111-1111-1111-1111-111111111111",
|
||||||
).unwrap());
|
).unwrap());
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
||||||
artist::{Artist, ArtistId},
|
artist::{Artist, ArtistId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
album::{Album, AlbumDate, AlbumId, AlbumMonth, AlbumSeq},
|
||||||
artist::{Artist, ArtistId},
|
artist::{Artist, ArtistId},
|
||||||
musicbrainz::MusicBrainz,
|
musicbrainz::MusicBrainzUrl,
|
||||||
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
track::{Track, TrackFormat, TrackId, TrackNum, TrackQuality},
|
||||||
Collection,
|
Collection,
|
||||||
};
|
};
|
||||||
@ -18,7 +18,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
sort: Some(ArtistId{
|
sort: Some(ArtistId{
|
||||||
name: String::from("Arkona")
|
name: String::from("Arkona")
|
||||||
}),
|
}),
|
||||||
musicbrainz: Some(MusicBrainz::artist_from_str(
|
musicbrainz: Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/baad262d-55ef-427a-83c7-f7530964f212"
|
"https://musicbrainz.org/artist/baad262d-55ef-427a-83c7-f7530964f212"
|
||||||
).unwrap()),
|
).unwrap()),
|
||||||
properties: HashMap::from([
|
properties: HashMap::from([
|
||||||
@ -206,7 +206,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
name: String::from("Eluveitie"),
|
name: String::from("Eluveitie"),
|
||||||
},
|
},
|
||||||
sort: None,
|
sort: None,
|
||||||
musicbrainz: Some(MusicBrainz::artist_from_str(
|
musicbrainz: Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/8000598a-5edb-401c-8e6d-36b167feaf38",
|
"https://musicbrainz.org/artist/8000598a-5edb-401c-8e6d-36b167feaf38",
|
||||||
).unwrap()),
|
).unwrap()),
|
||||||
properties: HashMap::from([
|
properties: HashMap::from([
|
||||||
@ -451,7 +451,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
name: String::from("Frontside"),
|
name: String::from("Frontside"),
|
||||||
},
|
},
|
||||||
sort: None,
|
sort: None,
|
||||||
musicbrainz: Some(MusicBrainz::artist_from_str(
|
musicbrainz: Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/3a901353-fccd-4afd-ad01-9c03f451b490",
|
"https://musicbrainz.org/artist/3a901353-fccd-4afd-ad01-9c03f451b490",
|
||||||
).unwrap()),
|
).unwrap()),
|
||||||
properties: HashMap::from([
|
properties: HashMap::from([
|
||||||
@ -605,7 +605,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
sort: Some(ArtistId {
|
sort: Some(ArtistId {
|
||||||
name: String::from("Heaven’s Basement"),
|
name: String::from("Heaven’s Basement"),
|
||||||
}),
|
}),
|
||||||
musicbrainz: Some(MusicBrainz::artist_from_str(
|
musicbrainz: Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/c2c4d56a-d599-4a18-bd2f-ae644e2198cc",
|
"https://musicbrainz.org/artist/c2c4d56a-d599-4a18-bd2f-ae644e2198cc",
|
||||||
).unwrap()),
|
).unwrap()),
|
||||||
properties: HashMap::from([
|
properties: HashMap::from([
|
||||||
@ -737,7 +737,7 @@ pub static COLLECTION: Lazy<Vec<Artist>> = Lazy::new(|| -> Collection {
|
|||||||
name: String::from("Metallica"),
|
name: String::from("Metallica"),
|
||||||
},
|
},
|
||||||
sort: None,
|
sort: None,
|
||||||
musicbrainz: Some(MusicBrainz::artist_from_str(
|
musicbrainz: Some(MusicBrainzUrl::artist_from_str(
|
||||||
"https://musicbrainz.org/artist/65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab",
|
"https://musicbrainz.org/artist/65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab",
|
||||||
).unwrap()),
|
).unwrap()),
|
||||||
properties: HashMap::from([
|
properties: HashMap::from([
|
||||||
|
Loading…
Reference in New Issue
Block a user