Provide a keyboard shortcut to sync all existing albums with MusicBrainz #167
11
src/external/musicbrainz/api/mod.rs
vendored
11
src/external/musicbrainz/api/mod.rs
vendored
@ -150,6 +150,7 @@ struct SearchReleaseGroup {
|
|||||||
title: String,
|
title: String,
|
||||||
first_release_date: String,
|
first_release_date: String,
|
||||||
primary_type: SerdeAlbumPrimaryType,
|
primary_type: SerdeAlbumPrimaryType,
|
||||||
|
secondary_types: Option<Vec<SerdeAlbumSecondaryType>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<SearchReleaseGroup> for Match<Album> {
|
impl TryFrom<SearchReleaseGroup> for Match<Album> {
|
||||||
@ -160,7 +161,10 @@ impl TryFrom<SearchReleaseGroup> for Match<Album> {
|
|||||||
entity.title,
|
entity.title,
|
||||||
AlbumDate::from_mb_date(&entity.first_release_date)?,
|
AlbumDate::from_mb_date(&entity.first_release_date)?,
|
||||||
Some(entity.primary_type.into()),
|
Some(entity.primary_type.into()),
|
||||||
vec![],
|
entity
|
||||||
|
.secondary_types
|
||||||
|
.map(|v| v.into_iter().map(|st| st.into()).collect())
|
||||||
|
.unwrap_or_default(),
|
||||||
);
|
);
|
||||||
let mbref = MbAlbumRef::from_uuid_str(entity.id)
|
let mbref = MbAlbumRef::from_uuid_str(entity.id)
|
||||||
.map_err(|err| Error::MbidParse(err.to_string()))?;
|
.map_err(|err| Error::MbidParse(err.to_string()))?;
|
||||||
@ -229,7 +233,7 @@ pub enum SerdeAlbumSecondaryTypeDef {
|
|||||||
FieldRecording,
|
FieldRecording,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
pub struct SerdeAlbumSecondaryType(
|
pub struct SerdeAlbumSecondaryType(
|
||||||
#[serde(with = "SerdeAlbumSecondaryTypeDef")] AlbumSecondaryType,
|
#[serde(with = "SerdeAlbumSecondaryTypeDef")] AlbumSecondaryType,
|
||||||
);
|
);
|
||||||
@ -320,6 +324,7 @@ mod tests {
|
|||||||
title: String::from("an album"),
|
title: String::from("an album"),
|
||||||
first_release_date: String::from("1986-04"),
|
first_release_date: String::from("1986-04"),
|
||||||
primary_type: SerdeAlbumPrimaryType(AlbumPrimaryType::Album),
|
primary_type: SerdeAlbumPrimaryType(AlbumPrimaryType::Album),
|
||||||
|
secondary_types: Some(vec![SerdeAlbumSecondaryType(AlbumSecondaryType::Live)]),
|
||||||
};
|
};
|
||||||
let response = ResponseSearchReleaseGroup {
|
let response = ResponseSearchReleaseGroup {
|
||||||
release_groups: vec![release_group],
|
release_groups: vec![release_group],
|
||||||
@ -350,7 +355,7 @@ mod tests {
|
|||||||
AlbumId::new("an album"),
|
AlbumId::new("an album"),
|
||||||
(1986, 4),
|
(1986, 4),
|
||||||
Some(AlbumPrimaryType::Album),
|
Some(AlbumPrimaryType::Album),
|
||||||
vec![],
|
vec![AlbumSecondaryType::Live],
|
||||||
);
|
);
|
||||||
album.set_musicbrainz_ref(
|
album.set_musicbrainz_ref(
|
||||||
MbAlbumRef::from_uuid_str("11111111-1111-1111-1111-111111111111").unwrap(),
|
MbAlbumRef::from_uuid_str("11111111-1111-1111-1111-111111111111").unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user