diff options
Diffstat (limited to 'import/src')
| -rw-r--r-- | import/src/acoustid.rs | 4 | ||||
| -rw-r--r-- | import/src/lib.rs | 7 | ||||
| -rw-r--r-- | import/src/musicbrainz.rs | 6 | ||||
| -rw-r--r-- | import/src/vgmdb.rs | 10 | ||||
| -rw-r--r-- | import/src/wikidata.rs | 8 | ||||
| -rw-r--r-- | import/src/wikimedia_commons.rs | 6 |
6 files changed, 32 insertions, 9 deletions
diff --git a/import/src/acoustid.rs b/import/src/acoustid.rs index cbdfc7a..a328146 100644 --- a/import/src/acoustid.rs +++ b/import/src/acoustid.rs @@ -83,7 +83,7 @@ impl AcoustID { pub async fn get_atid_mbid(&self, fp: &Fingerprint) -> Result<Option<(String, String)>> { let res = self.lookup(fp.to_owned()).await?; for r in &res.results { - if let Some(k) = r.recordings.get(0) { + if let Some(k) = r.recordings.first() { return Ok(Some((r.id.clone(), k.id.clone()))); } } @@ -103,7 +103,7 @@ impl AcoustID { let resp = self .client - .post(format!("https://api.acoustid.org/v2/lookup")) + .post("https://api.acoustid.org/v2/lookup".to_string()) .header("Content-Type", "application/x-www-form-urlencoded") .body(body) .send() diff --git a/import/src/lib.rs b/import/src/lib.rs index 4a6d87b..1fd8bc7 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -82,7 +82,7 @@ static CONF: LazyLock<Config> = LazyLock::new(|| { .expect("import config not preloaded. logic error") }); -pub const USER_AGENT: &'static str = concat!( +pub const USER_AGENT: &str = concat!( "jellything/", env!("CARGO_PKG_VERSION"), " +https://codeberg.org/metamuffin/jellything" @@ -401,8 +401,7 @@ fn import_media_file( .transpose()?; let mut tags = m - .tags - .get(0) + .tags.first() .map(|tags| { tags.tags .iter() @@ -773,7 +772,7 @@ fn apply_musicbrainz_recording( node.title = Some(rec.title.clone()); node.external_ids .insert("musicbrainz.recording".to_string(), rec.id.to_string()); - if let Some(a) = rec.artist_credit.get(0) { + if let Some(a) = rec.artist_credit.first() { node.subtitle = Some(a.artist.name.clone()); node.external_ids .insert("musicbrainz.artist".to_string(), a.artist.id.to_string()); diff --git a/import/src/musicbrainz.rs b/import/src/musicbrainz.rs index e4f38da..934a9e8 100644 --- a/import/src/musicbrainz.rs +++ b/import/src/musicbrainz.rs @@ -191,6 +191,12 @@ pub struct MbUrl { pub resource: String, } +impl Default for MusicBrainz { + fn default() -> Self { + Self::new() + } +} + impl MusicBrainz { const MAX_PAR_REQ: usize = 4; pub fn new() -> Self { diff --git a/import/src/vgmdb.rs b/import/src/vgmdb.rs index 6278aaa..20a0038 100644 --- a/import/src/vgmdb.rs +++ b/import/src/vgmdb.rs @@ -32,6 +32,12 @@ static RE_IMAGE_URL_FROM_HTML: LazyLock<Regex> = LazyLock::new(|| { Regex::new(r#"href='(?<url>https://media.vgm.io/artists/[-/\w\.]+)'"#).unwrap() }); +impl Default for Vgmdb { + fn default() -> Self { + Self::new() + } +} + impl Vgmdb { pub fn new() -> Self { let client = ClientBuilder::new() @@ -79,11 +85,11 @@ impl Vgmdb { return Ok(Some(url.to_string())); } } - return Ok(None); + Ok(None) } pub async fn scrape_artist_page(&self, id: u64) -> Result<Arc<String>> { - async_cache_memory("api-vgmdb-artist", id.clone(), || async move { + async_cache_memory("api-vgmdb-artist", id, || async move { let _permit = self.rate_limit.clone().acquire_owned().await?; let permit_drop_ts = Instant::now() + Duration::from_secs(1); info!("scrape artist: {id}"); diff --git a/import/src/wikidata.rs b/import/src/wikidata.rs index 1b7f06e..71eef9a 100644 --- a/import/src/wikidata.rs +++ b/import/src/wikidata.rs @@ -63,6 +63,12 @@ pub mod properties { pub static IMAGE: &str = "P18"; } +impl Default for Wikidata { + fn default() -> Self { + Self::new() + } +} + impl Wikidata { pub fn new() -> Self { let client = ClientBuilder::new() @@ -118,6 +124,6 @@ impl Wikidata { .await .context("wikidata entity")?; - Ok(serde_json::from_str(&json).context("parse wikidata entity")?) + serde_json::from_str(&json).context("parse wikidata entity") } } diff --git a/import/src/wikimedia_commons.rs b/import/src/wikimedia_commons.rs index a5889fb..f8d8f53 100644 --- a/import/src/wikimedia_commons.rs +++ b/import/src/wikimedia_commons.rs @@ -17,6 +17,12 @@ use tokio::io::AsyncWriteExt; pub struct WikimediaCommons { client: Client, } +impl Default for WikimediaCommons { + fn default() -> Self { + Self::new() + } +} + impl WikimediaCommons { pub fn new() -> Self { let client = ClientBuilder::new() |