aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-24 15:38:22 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-24 15:38:22 +0200
commit7074308f9581934cd76c7cae9b69e51ef05a33ae (patch)
tree969811f5c6ae6227f28ba99bb9334e4de132c625
parent388ae00ce1d510143789e85732831280ec803da7 (diff)
downloadjellything-7074308f9581934cd76c7cae9b69e51ef05a33ae.tar
jellything-7074308f9581934cd76c7cae9b69e51ef05a33ae.tar.bz2
jellything-7074308f9581934cd76c7cae9b69e51ef05a33ae.tar.zst
musicbrainz types
-rw-r--r--common/src/impl.rs6
-rw-r--r--common/src/lib.rs8
-rw-r--r--import/src/acoustid.rs1
-rw-r--r--import/src/musicbrainz.rs101
4 files changed, 81 insertions, 35 deletions
diff --git a/common/src/impl.rs b/common/src/impl.rs
index 6415d53..3fa8d80 100644
--- a/common/src/impl.rs
+++ b/common/src/impl.rs
@@ -127,6 +127,12 @@ impl Display for PeopleGroup {
PeopleGroup::Vfx => "Visual Effects",
PeopleGroup::CostumeMakeup => "Costume & Makeup",
PeopleGroup::CreatedBy => "Created by:",
+ PeopleGroup::Performance => "Performance",
+ PeopleGroup::Instrument => "Instrument",
+ PeopleGroup::Vocal => "Vocal",
+ PeopleGroup::Arranger => "Arranger",
+ PeopleGroup::Producer => "Producer",
+ PeopleGroup::Engineer => "Engineer",
})
}
}
diff --git a/common/src/lib.rs b/common/src/lib.rs
index f413d97..eaf5900 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -105,6 +105,14 @@ pub enum PeopleGroup {
Vfx,
CostumeMakeup,
CreatedBy,
+ // https://musicbrainz.org/relationships/artist-recording
+ // modelling after this, but its too many categories
+ Performance,
+ Instrument,
+ Vocal,
+ Arranger,
+ Producer,
+ Engineer,
}
#[derive(
diff --git a/import/src/acoustid.rs b/import/src/acoustid.rs
index 5692674..e53bf13 100644
--- a/import/src/acoustid.rs
+++ b/import/src/acoustid.rs
@@ -101,7 +101,6 @@ impl AcoustID {
let resp = self
.client
.post(format!("https://api.acoustid.org/v2/lookup"))
- // .post(format!("http://127.0.0.1:1234/v2/lookup"))
.header("Content-Type", "application/x-www-form-urlencoded")
.body(body)
.send()
diff --git a/import/src/musicbrainz.rs b/import/src/musicbrainz.rs
index 7a58cec..2d3d532 100644
--- a/import/src/musicbrainz.rs
+++ b/import/src/musicbrainz.rs
@@ -26,7 +26,7 @@ pub struct MusicBrainz {
#[derive(Debug, Deserialize, Encode, Decode)]
#[serde(rename_all = "kebab-case")]
-pub struct MbRecording {
+pub struct MbRecordingRel {
pub id: String,
pub first_release_date: String,
pub title: String,
@@ -35,53 +35,85 @@ pub struct MbRecording {
pub disambiguation: String,
pub length: u32,
pub relations: Vec<MbRelation>,
+ pub artist_credit: Vec<MbArtistCredit>,
+}
+
+#[derive(Debug, Deserialize, Encode, Decode)]
+#[serde(rename_all = "kebab-case")]
+pub struct MbArtistCredit {
+ pub name: String,
+ pub artist: MbArtist,
}
#[derive(Debug, Deserialize, Encode, Decode)]
#[serde(rename_all = "kebab-case")]
pub struct MbRelation {
- direction: String,
- r#type: String,
- type_id: String,
- begin: Option<String>,
- end: Option<String>,
- ended: bool,
- target_type: String,
- target_credit: String,
- source_credit: String,
- attributes: Vec<String>,
- attribute_ids: BTreeMap<String, String>,
- attribute_values: BTreeMap<String, String>,
+ pub direction: String,
+ pub r#type: String,
+ pub type_id: String,
+ pub begin: Option<String>,
+ pub end: Option<String>,
+ pub ended: bool,
+ pub target_type: String,
+ pub target_credit: String,
+ pub source_credit: String,
+ pub attributes: Vec<String>,
+ pub attribute_ids: BTreeMap<String, String>,
+ pub attribute_values: BTreeMap<String, String>,
- work: Option<MbWork>,
- artist: Option<MbArtist>,
- url: Option<MbUrl>,
+ pub work: Option<MbWork>,
+ pub artist: Option<MbArtist>,
+ pub url: Option<MbUrl>,
+ pub recording: Option<MbRecording>,
+ pub series: Option<MbSeries>,
+}
+
+#[derive(Debug, Deserialize, Encode, Decode)]
+#[serde(rename_all = "kebab-case")]
+pub struct MbSeries {
+ pub id: String,
+ pub r#type: String,
+ pub type_id: String,
+ pub name: String,
+ pub disambiguation: String,
+}
+
+#[derive(Debug, Deserialize, Encode, Decode)]
+#[serde(rename_all = "kebab-case")]
+pub struct MbRecording {
+ pub id: String,
+ pub title: String,
+ pub isrcs: Vec<String>,
+ pub video: bool,
+ pub disambiguation: String,
+ pub length: u32,
+ pub artist_credit: Vec<MbArtistCredit>,
}
#[derive(Debug, Deserialize, Encode, Decode)]
#[serde(rename_all = "kebab-case")]
pub struct MbWork {
- id: String,
- r#type: String,
- type_id: String,
- languages: Vec<String>,
- iswcs: Vec<String>,
- language: Option<String>,
- title: String,
- attributes: Vec<String>,
- disambiguation: String,
+ pub id: String,
+ pub r#type: String,
+ pub type_id: String,
+ pub languages: Vec<String>,
+ pub iswcs: Vec<String>,
+ pub language: Option<String>,
+ pub title: String,
+ pub attributes: Vec<String>,
+ pub disambiguation: String,
}
#[derive(Debug, Deserialize, Encode, Decode)]
#[serde(rename_all = "kebab-case")]
pub struct MbArtist {
- id: String,
- r#type: String,
- type_id: String,
- name: String,
- disambiguation: String,
- country: String,
- sort_name: String,
+ pub id: String,
+ pub r#type: Option<String>,
+ pub type_id: Option<String>,
+ pub name: String,
+ pub disambiguation: String,
+ pub country: Option<String>,
+ pub sort_name: String,
}
#[derive(Debug, Deserialize, Encode, Decode)]
@@ -114,13 +146,14 @@ impl MusicBrainz {
}
}
- pub async fn lookup_recording(&self, id: String) -> Result<Arc<MbRecording>> {
+ pub async fn lookup_recording(&self, id: String) -> Result<Arc<MbRecordingRel>> {
async_cache_memory("api-musicbrainz-recording", id.clone(), || async move {
let _permit = self.rate_limit.clone().acquire_owned().await?;
let permit_drop_ts = Instant::now() + Duration::from_secs(10);
let inc = [
"isrcs",
+ "artists",
"area-rels",
"artist-rels",
"event-rels",
@@ -145,7 +178,7 @@ impl MusicBrainz {
.send()
.await?
.error_for_status()?
- .json::<MbRecording>()
+ .json::<MbRecordingRel>()
.await?;
tokio::task::spawn(async move {