From 32e488a42294ce051420cfebce44bf8cab253887 Mon Sep 17 00:00:00 2001 From: Marekkon5 Date: Mon, 5 Feb 2024 21:56:12 +0100 Subject: [PATCH] Update dependencies, fix traxsource genre panic --- Cargo.lock | 30 ++++++++++++++++++-- crates/onetagger-platforms/src/traxsource.rs | 6 ++-- crates/onetagger-tag/Cargo.toml | 6 ++-- crates/onetagger-tag/src/vorbis.rs | 4 +-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a598be0..5db389b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4294,11 +4294,26 @@ dependencies = [ "flate2", "lofty_attr", "log", - "ogg_pager", + "ogg_pager 0.5.0", "once_cell", "paste", ] +[[package]] +name = "lofty" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75066eb1d25a7047fb2667edb410ae2592439ed81546f95c28b0a1c7d7d3818" +dependencies = [ + "byteorder", + "data-encoding", + "flate2", + "lofty_attr", + "log", + "ogg_pager 0.6.0", + "paste", +] + [[package]] name = "lofty_attr" version = "0.9.0" @@ -4981,6 +4996,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "ogg_pager" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c949d63b387b25c332f6e39d1762dd4b405008289dd7681f02c258b1294653ca" +dependencies = [ + "byteorder", +] + [[package]] name = "oid-registry" version = "0.6.1" @@ -5100,7 +5124,7 @@ dependencies = [ "alac", "anyhow", "hound", - "lofty", + "lofty 0.17.1", "log", "mp4parse 0.17.0", "onetagger-shared", @@ -5196,7 +5220,7 @@ dependencies = [ "base64 0.21.7", "chrono", "id3", - "lofty", + "lofty 0.18.2", "log", "metaflac", "mp4ameta", diff --git a/crates/onetagger-platforms/src/traxsource.rs b/crates/onetagger-platforms/src/traxsource.rs index c70950ac..d1da4f77 100644 --- a/crates/onetagger-platforms/src/traxsource.rs +++ b/crates/onetagger-platforms/src/traxsource.rs @@ -88,7 +88,7 @@ impl Traxsource { // Genre selector = Selector::parse("div.genre").unwrap(); - let genre = track_element.select(&selector).next().unwrap().text().collect::>().first().unwrap().to_owned(); + let genre = track_element.select(&selector).next().map(|e| e.text().collect::>().first().map(|v| v.to_string())).flatten(); // Release date selector = Selector::parse("div.r-date").unwrap(); @@ -103,9 +103,7 @@ impl Traxsource { album_artists: vec![], label: Some(label.to_string()), release_date: NaiveDate::parse_from_str(&release_date, "%Y-%m-%d").ok(), - genres: vec![genre.to_owned()], - styles: vec![], - other: vec![], + genres: genre.map(|g| vec![g]).unwrap_or_default(), track_id: Some(track_id), release_id: String::new(), duration: duration.into(), diff --git a/crates/onetagger-tag/Cargo.toml b/crates/onetagger-tag/Cargo.toml index 475f1f14..f4101831 100644 --- a/crates/onetagger-tag/Cargo.toml +++ b/crates/onetagger-tag/Cargo.toml @@ -10,13 +10,13 @@ chrono = "0.4" anyhow = "1.0" log = { version = "0.4", optional = true } -id3 = { version = "1.6.0", optional = true } +id3 = { version = "1.12.0", optional = true } riff = { version = "2.0.0", optional = true } -lofty = { version = "0.17.0", optional = true } +lofty = { version = "0.18.2", optional = true } base64 = { version = "0.21", optional = true } mp4ameta = { version = "0.11", optional = true } metaflac = { version = "0.2.5", optional = true } -once_cell = { version = "1.17", optional = true } +once_cell = { version = "1.19", optional = true } pyo3 = { version = "0.18", features = ["chrono", "serde"], optional = true } serde = { version = "1.0", features = ["derive"] } diff --git a/crates/onetagger-tag/src/vorbis.rs b/crates/onetagger-tag/src/vorbis.rs index bfe9368f..6ed7bf6c 100644 --- a/crates/onetagger-tag/src/vorbis.rs +++ b/crates/onetagger-tag/src/vorbis.rs @@ -167,7 +167,7 @@ impl TagImpl for VorbisTag { match self.tag.insert_picture( lofty::Picture::new_unchecked( self.picture_type(&kind), - MimeType::from_str(&mime.trim().to_lowercase()), + Some(MimeType::from_str(&mime.trim().to_lowercase())), description.map(String::from), data ), @@ -188,7 +188,7 @@ impl TagImpl for VorbisTag { kind: self.cover_type(&p.pic_type()), description: p.description().map(String::from).unwrap_or(String::new()), data: p.data().to_vec(), - mime: p.mime_type().to_string() + mime: p.mime_type().unwrap_or(&MimeType::Jpeg).to_string() } ).collect() }