aboutsummaryrefslogtreecommitdiff
path: root/import/src/plugins/acoustid.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-16 04:21:10 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-16 04:21:10 +0100
commit30e13399fa9f815cd1884fe87914cdb22d1985af (patch)
treeea5b22431b73264c120fcb06560ff158c08ed8a4 /import/src/plugins/acoustid.rs
parent9b5d11a2a39e0030ce4eeab8905972f9472c7d27 (diff)
downloadjellything-30e13399fa9f815cd1884fe87914cdb22d1985af.tar
jellything-30e13399fa9f815cd1884fe87914cdb22d1985af.tar.bz2
jellything-30e13399fa9f815cd1884fe87914cdb22d1985af.tar.zst
begin refactor import
Diffstat (limited to 'import/src/plugins/acoustid.rs')
-rw-r--r--import/src/plugins/acoustid.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/import/src/plugins/acoustid.rs b/import/src/plugins/acoustid.rs
index b93533a..9edcb63 100644
--- a/import/src/plugins/acoustid.rs
+++ b/import/src/plugins/acoustid.rs
@@ -9,6 +9,9 @@ use crate::{
};
use anyhow::{Context, Result};
use jellycache::{HashKey, cache_memory};
+use jellycommon::{
+ IDENT_ACOUST_ID_TRACK, IDENT_MUSICBRAINZ_RECORDING, NO_IDENTIFIERS, jellyobject::Object,
+};
use jellydb::table::RowNum;
use jellyremuxer::matroska::Segment;
use log::info;
@@ -171,12 +174,23 @@ impl ImportPlugin for AcoustID {
return Ok(());
}
let fp = acoustid_fingerprint(path)?;
+
if let Some((atid, mbid)) = self.get_atid_mbid(&fp, &ct.rt)? {
- ct.db.update_node_init(node, |n| {
- n.identifiers.insert(IdentifierType::AcoustIdTrack, atid);
- n.identifiers
- .insert(IdentifierType::MusicbrainzRecording, mbid);
- })?;
+ ct.dba.db.write_transaction(&mut |txn| {
+ let ob = ct.dba.nodes.get(txn, node)?.unwrap();
+ let ob = ob.as_object();
+ let ob = ob.insert(
+ NO_IDENTIFIERS,
+ ob.get(NO_IDENTIFIERS)
+ .unwrap_or(Object::EMPTY)
+ .insert(IDENT_ACOUST_ID_TRACK, &atid)
+ .as_object()
+ .insert(IDENT_MUSICBRAINZ_RECORDING, &mbid)
+ .as_object(),
+ );
+ ct.dba.nodes.update(txn, node, ob)?;
+ Ok(())
+ });
};
Ok(())
}