diff options
| -rw-r--r-- | common/src/lib.rs | 4 | ||||
| -rw-r--r-- | database/src/backends/memory.rs | 14 | ||||
| -rw-r--r-- | database/src/backends/mod.rs | 10 | ||||
| -rw-r--r-- | database/src/backends/redb.rs | 14 | ||||
| -rw-r--r-- | database/src/backends/rocksdb.rs | 12 | ||||
| -rw-r--r-- | database/src/filter/mod.rs | 1 | ||||
| -rw-r--r-- | database/src/query.rs | 7 | ||||
| -rw-r--r-- | database/src/sort/mod.rs | 2 | ||||
| -rw-r--r-- | database/src/sort/value.rs | 2 | ||||
| -rw-r--r-- | database/src/table.rs | 34 | ||||
| -rw-r--r-- | import/Cargo.toml | 1 | ||||
| -rw-r--r-- | import/src/lib.rs | 75 | ||||
| -rw-r--r-- | import/src/plugins/acoustid.rs | 4 | ||||
| -rw-r--r-- | import/src/plugins/infojson.rs | 8 | ||||
| -rw-r--r-- | import/src/plugins/media_info.rs | 1 | ||||
| -rw-r--r-- | import/src/plugins/misc.rs | 15 | ||||
| -rw-r--r-- | import/src/plugins/mod.rs | 19 | ||||
| -rw-r--r-- | import/src/plugins/tags.rs | 1 | ||||
| -rw-r--r-- | import/src/plugins/tmdb.rs | 4 | ||||
| -rw-r--r-- | import/src/plugins/trakt.rs | 1 | ||||
| -rw-r--r-- | import/src/plugins/vgmdb.rs | 1 | ||||
| -rw-r--r-- | import/src/plugins/wikimedia_commons.rs | 4 |
22 files changed, 165 insertions, 69 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs index 5641386..9949bcc 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -5,7 +5,7 @@ */ #![feature(array_try_map)] pub mod routes; -use jellyobject::{Object, Registry, Tag, enums, fields}; +use jellyobject::{Object, Registry, Tag, TypedTag, enums, fields}; pub use jellystream_types as stream; use std::sync::LazyLock; @@ -142,3 +142,5 @@ enums! { CRCAT_PRODUCER = 0x2012 "producer"; CRCAT_ENGINEER = 0x2013 "engineer"; } + +pub struct Identifier(pub TypedTag<&'static str>, pub String); diff --git a/database/src/backends/memory.rs b/database/src/backends/memory.rs index 0c1635f..e010a84 100644 --- a/database/src/backends/memory.rs +++ b/database/src/backends/memory.rs @@ -4,9 +4,7 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::backends::{ - Database, ReadTransaction, ReadTxnFunction, WriteTransaction, WriteTxnFunction, -}; +use crate::backends::{Database, ReadTransaction, WriteTransaction}; use anyhow::Result; use std::{ collections::BTreeMap, @@ -21,10 +19,16 @@ pub fn new() -> Memdb { } impl Database for Memdb { - fn write_transaction(&self, f: &mut WriteTxnFunction) -> Result<()> { + fn write_transaction( + &self, + f: &mut dyn FnMut(&mut dyn WriteTransaction) -> Result<()>, + ) -> Result<()> { f(&mut self.write().unwrap()) } - fn read_transaction(&self, f: &mut ReadTxnFunction) -> Result<()> { + fn read_transaction( + &self, + f: &mut dyn FnMut(&dyn ReadTransaction) -> Result<()>, + ) -> Result<()> { f(&self.read().unwrap()) } } diff --git a/database/src/backends/mod.rs b/database/src/backends/mod.rs index 4cbb4cf..ba30b46 100644 --- a/database/src/backends/mod.rs +++ b/database/src/backends/mod.rs @@ -14,9 +14,13 @@ use std::{path::Path, sync::Arc}; pub type WriteTxnFunction = dyn FnMut(&mut dyn WriteTransaction) -> Result<()>; pub type ReadTxnFunction = dyn FnMut(&dyn ReadTransaction) -> Result<()>; -pub trait Database { - fn write_transaction(&self, f: &mut WriteTxnFunction) -> Result<()>; - fn read_transaction(&self, f: &mut ReadTxnFunction) -> Result<()>; +pub trait Database: Send + Sync + 'static { + fn write_transaction( + &self, + f: &mut dyn FnMut(&mut dyn WriteTransaction) -> Result<()>, + ) -> Result<()>; + fn read_transaction(&self, f: &mut dyn FnMut(&dyn ReadTransaction) -> Result<()>) + -> Result<()>; } pub trait WriteTransaction: ReadTransaction { fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()>; diff --git a/database/src/backends/redb.rs b/database/src/backends/redb.rs index 70623b5..c0887c8 100644 --- a/database/src/backends/redb.rs +++ b/database/src/backends/redb.rs @@ -4,9 +4,7 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::backends::{ - Database, ReadTransaction, ReadTxnFunction, WriteTransaction, WriteTxnFunction, -}; +use crate::backends::{Database, ReadTransaction, WriteTransaction}; use anyhow::Result; use redb::{AccessGuard, ReadableDatabase, ReadableTable, StorageError, Table, TableDefinition}; use std::path::Path; @@ -18,7 +16,10 @@ pub fn new(path: &Path) -> Result<redb::Database> { } impl Database for redb::Database { - fn write_transaction(&self, f: &mut WriteTxnFunction) -> Result<()> { + fn write_transaction( + &self, + f: &mut dyn FnMut(&mut dyn WriteTransaction) -> Result<()>, + ) -> Result<()> { let txn = self.begin_write()?; let mut table = txn.open_table(TABLE)?; f(&mut table)?; @@ -26,7 +27,10 @@ impl Database for redb::Database { txn.commit()?; Ok(()) } - fn read_transaction(&self, f: &mut ReadTxnFunction) -> Result<()> { + fn read_transaction( + &self, + f: &mut dyn FnMut(&dyn ReadTransaction) -> Result<()>, + ) -> Result<()> { let mut txn = self.begin_read()?; f(&mut txn)?; Ok(()) diff --git a/database/src/backends/rocksdb.rs b/database/src/backends/rocksdb.rs index 1475dac..056af9e 100644 --- a/database/src/backends/rocksdb.rs +++ b/database/src/backends/rocksdb.rs @@ -4,7 +4,7 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::backends::{Database, ReadTransaction, WriteTransaction, WriteTxnFunction}; +use crate::backends::{Database, ReadTransaction, WriteTransaction}; use anyhow::Result; use rocksdb::{Direction, ErrorKind, IteratorMode, OptimisticTransactionDB}; use std::path::Path; @@ -14,7 +14,10 @@ pub fn new(path: &Path) -> Result<OptimisticTransactionDB> { } impl Database for OptimisticTransactionDB { - fn write_transaction(&self, f: &mut WriteTxnFunction) -> Result<()> { + fn write_transaction( + &self, + f: &mut dyn FnMut(&mut dyn WriteTransaction) -> Result<()>, + ) -> Result<()> { loop { let mut txn = self.transaction(); f(&mut txn)?; @@ -25,7 +28,10 @@ impl Database for OptimisticTransactionDB { } } } - fn read_transaction(&self, f: &mut super::ReadTxnFunction) -> Result<()> { + fn read_transaction( + &self, + f: &mut dyn FnMut(&dyn ReadTransaction) -> Result<()>, + ) -> Result<()> { loop { let txn = self.transaction(); f(&txn)?; diff --git a/database/src/filter/mod.rs b/database/src/filter/mod.rs index d142c0f..c40e4c0 100644 --- a/database/src/filter/mod.rs +++ b/database/src/filter/mod.rs @@ -14,6 +14,7 @@ impl Filter { pub fn get_bins(&self) -> Vec<Binning> { fn recurse(f: &Filter) -> Vec<Vec<BinningComponent>> { match f { + Filter::True => vec![vec![]], Filter::All(filters) => { let mut o = vec![vec![]]; for filter in filters { diff --git a/database/src/query.rs b/database/src/query.rs index 8513e22..3c3a07c 100644 --- a/database/src/query.rs +++ b/database/src/query.rs @@ -6,12 +6,15 @@ use jellyobject::Path; +#[derive(Default)] pub struct Query { pub filter: Filter, pub sort: Sort, } +#[derive(Default)] pub enum Sort { + #[default] None, Value(ValueSortComponent), TextSearch(Path, String), @@ -34,8 +37,10 @@ pub enum SortOrder { Descending, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub enum Filter { + #[default] + True, All(Vec<Filter>), Any(Vec<Filter>), Match(Path, Vec<u8>), diff --git a/database/src/sort/mod.rs b/database/src/sort/mod.rs index 9c2eb88..b058766 100644 --- a/database/src/sort/mod.rs +++ b/database/src/sort/mod.rs @@ -11,7 +11,7 @@ use jellyobject::Object; pub mod none; pub mod value; -pub trait Index { +pub trait Index: Send + Sync + 'static { fn add(&self, db: &mut dyn WriteTransaction, row: RowNum, val: Object) -> Result<()>; fn remove(&self, db: &mut dyn WriteTransaction, row: RowNum, val: Object) -> Result<()>; /// Might return true if objects are identical for this index; false if not or uncertain diff --git a/database/src/sort/value.rs b/database/src/sort/value.rs index 0381fe0..6eb638c 100644 --- a/database/src/sort/value.rs +++ b/database/src/sort/value.rs @@ -12,7 +12,7 @@ use crate::{ table::{RowNum, TableNum}, }; use anyhow::Result; -use jellycommon::jellyobject::Object; +use jellyobject::Object; pub struct ValueIndex { id: TableNum, diff --git a/database/src/table.rs b/database/src/table.rs index 1680016..27db06e 100644 --- a/database/src/table.rs +++ b/database/src/table.rs @@ -6,9 +6,10 @@ use crate::{ backends::{ReadTransaction, WriteTransaction}, + query::Query, sort::Index, }; -use anyhow::Result; +use anyhow::{Result, anyhow}; use jellyobject::ObjectBuffer; pub type TableNum = u64; @@ -68,4 +69,35 @@ impl Table { db.del(&self.key(row))?; Ok(true) } + pub fn update( + &self, + db: &mut dyn WriteTransaction, + row: RowNum, + entry: ObjectBuffer, + ) -> Result<()> { + let before = self.get(db, row)?.ok_or(anyhow!("row to update missing"))?; + let before = before.as_object(); + let after = entry.as_object(); + + db.set(&self.key(row), bytemuck::cast_slice(entry.0.as_slice()))?; + + for idx in &self.indices { + if !idx.compare(before, after) { + idx.remove(db, row, before)?; + idx.add(db, row, after)?; + } + } + + Ok(()) + } + pub fn query( + &self, + db: &dyn ReadTransaction, + query: Query, + ) -> Box<dyn Iterator<Item = RowNum>> { + todo!() + } + pub fn query_single(&self, db: &dyn ReadTransaction, query: Query) -> Option<RowNum> { + self.query(db, query).next() + } } diff --git a/import/Cargo.toml b/import/Cargo.toml index 42c1d43..c62ef9e 100644 --- a/import/Cargo.toml +++ b/import/Cargo.toml @@ -28,3 +28,4 @@ tokio = { workspace = true } regex = "1.12.2" base64 = "0.22.1" +chrono = "0.4.42" diff --git a/import/src/lib.rs b/import/src/lib.rs index aab0c70..ad929fa 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -14,8 +14,12 @@ use crate::{ }; use anyhow::{Context, Result, anyhow}; use jellycache::{HashKey, cache_memory, cache_store}; -use jellycommon::{NodeID, Visibility}; -use jellydb::Database; +use jellycommon::jellyobject::{self, Object, ObjectBuffer, Tag, TypedTag}; +use jellydb::{ + backends::Database, + query::{Filter, Query, Sort}, + table::{RowNum, Table}, +}; use jellyremuxer::{ demuxers::create_demuxer_autodetect, matroska::{self, AttachedFile, Segment}, @@ -29,6 +33,7 @@ use serde::{Deserialize, Serialize}; use std::{ collections::HashSet, fs::{File, read_to_string}, + marker::PhantomData, mem::swap, path::{Path, PathBuf}, sync::{Arc, LazyLock, Mutex}, @@ -76,7 +81,49 @@ pub fn is_importing() -> bool { IMPORT_SEM.available_permits() == 0 } -pub async fn import_wrap(db: Database, incremental: bool) -> Result<()> { +pub struct NodeID(pub String); + +const NODE_ID: TypedTag<&str> = TypedTag(Tag(0x8123), PhantomData); + +struct DatabaseTables { + db: Arc<dyn Database>, + nodes: Table, +} + +fn node_id_query(node: &NodeID) -> Query { + Query { + filter: Filter::Match( + jellyobject::Path(vec![NODE_ID.0]), + node.0.as_bytes().to_vec(), + ), + sort: Sort::None, + } +} + +impl DatabaseTables { + pub fn update_node_init( + &self, + node: NodeID, + mut update: impl FnMut(Object) -> Option<ObjectBuffer>, + ) -> Result<()> { + self.db.write_transaction(&mut |txn| { + let node = match self.nodes.query_single(txn, node_id_query(&node)) { + Some(r) => r, + None => self + .nodes + .insert(txn, ObjectBuffer::new(&mut [(NODE_ID.0, &node.0.as_str())]))?, + }; + let ob = self.nodes.get(txn, node)?.unwrap(); + if let Some(changed) = update(ob.as_object()) { + self.nodes.update(txn, node, changed)?; + } + Ok(()) + })?; + Ok(()) + } +} + +pub async fn import_wrap(db: DatabaseTables, incremental: bool) -> Result<()> { let _sem = IMPORT_SEM.try_acquire().context("already importing")?; let rt = Handle::current(); @@ -86,9 +133,9 @@ pub async fn import_wrap(db: Database, incremental: bool) -> Result<()> { .build()?; let jh = spawn_blocking(move || { - tp.install(|| { + tp.install(move || { reporting::start_import(); - reporting::catch(import(&db, &rt, incremental)); + reporting::catch(import(db, &rt, incremental)); reporting::end_import(); }) }); @@ -98,7 +145,7 @@ pub async fn import_wrap(db: Database, incremental: bool) -> Result<()> { Ok(()) } -fn import(db: &Database, rt: &Handle, incremental: bool) -> Result<()> { +fn import(db: DatabaseTables, rt: &Handle, incremental: bool) -> Result<()> { let plugins = init_plugins(&CONF.api); let files = Mutex::new(Vec::new()); import_traverse( @@ -165,11 +212,11 @@ impl Default for InheritedFlags { fn import_traverse( path: &Path, - db: &Database, + db: DatabaseTables, incremental: bool, - parent: NodeID, + parent: Option<RowNum>, mut iflags: InheritedFlags, - out: &Mutex<Vec<(PathBuf, NodeID, InheritedFlags)>>, + out: &Mutex<Vec<(PathBuf, RowNum, InheritedFlags)>>, ) -> Result<()> { if path.is_dir() { reporting::set_task(format!("indexing {path:?}")); @@ -244,7 +291,7 @@ fn import_file( db, rt, iflags, - nodes, + pending_nodes: nodes, }; let filename = path.file_name().unwrap().to_string_lossy(); if filename == "flags" { @@ -343,7 +390,7 @@ fn import_file( } fn process_node( - db: &Database, + dba: DatabaseTables, rt: &Handle, plugins: &[Box<dyn ImportPlugin>], nodes: &Mutex<HashSet<NodeID>>, @@ -369,10 +416,10 @@ fn process_node( reporting::catch( p.process( &ImportContext { - db, + dba, rt, iflags: InheritedFlags::default(), - nodes, + pending_nodes: nodes, }, node, &data, @@ -383,7 +430,7 @@ fn process_node( } } -fn update_mtime(db: &Database, path: &Path) -> Result<()> { +fn update_mtime(db: DatabaseTables, path: &Path) -> Result<()> { let meta = path.metadata()?; let mtime = meta.modified()?.duration_since(UNIX_EPOCH)?.as_secs(); db.set_import_file_mtime(path, mtime)?; diff --git a/import/src/plugins/acoustid.rs b/import/src/plugins/acoustid.rs index 55c2123..b93533a 100644 --- a/import/src/plugins/acoustid.rs +++ b/import/src/plugins/acoustid.rs @@ -9,7 +9,7 @@ use crate::{ }; use anyhow::{Context, Result}; use jellycache::{HashKey, cache_memory}; -use jellycommon::{IdentifierType, NodeID}; +use jellydb::table::RowNum; use jellyremuxer::matroska::Segment; use log::info; use reqwest::{ @@ -166,7 +166,7 @@ impl ImportPlugin for AcoustID { ..Default::default() } } - fn media(&self, ct: &ImportContext, node: NodeID, path: &Path, _seg: &Segment) -> Result<()> { + fn media(&self, ct: &ImportContext, node: RowNum, path: &Path, _seg: &Segment) -> Result<()> { if !ct.iflags.use_acoustid { return Ok(()); } diff --git a/import/src/plugins/infojson.rs b/import/src/plugins/infojson.rs index 3aac3ec..fd15e03 100644 --- a/import/src/plugins/infojson.rs +++ b/import/src/plugins/infojson.rs @@ -4,11 +4,9 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ use anyhow::{Context, Result, anyhow}; +use chrono::{Utc, format::Parsed}; use jellycache::cache_read; -use jellycommon::{ - IdentifierType, NodeID, NodeKind, RatingType, - chrono::{Utc, format::Parsed}, -}; +use jellydb::table::RowNum; use jellyremuxer::matroska::{AttachedFile, Segment}; use log::info; use serde::{Deserialize, Serialize}; @@ -168,7 +166,7 @@ impl ImportPlugin for Infojson { ..Default::default() } } - fn file(&self, ct: &ImportContext, parent: NodeID, path: &Path) -> Result<()> { + fn file(&self, ct: &ImportContext, parent: RowNum, path: &Path) -> Result<()> { let filename = path.file_name().unwrap().to_string_lossy(); if filename != "channel.info.json" { return Ok(()); diff --git a/import/src/plugins/media_info.rs b/import/src/plugins/media_info.rs index d2aa5af..da445a3 100644 --- a/import/src/plugins/media_info.rs +++ b/import/src/plugins/media_info.rs @@ -6,7 +6,6 @@ use crate::plugins::{ImportContext, ImportPlugin, PluginInfo}; use anyhow::{Result, anyhow}; -use jellycommon::{Chapter, NodeID, SourceTrack, SourceTrackKind, TrackSource}; use jellyremuxer::matroska::Segment; use std::path::Path; diff --git a/import/src/plugins/misc.rs b/import/src/plugins/misc.rs index 8a95b97..43bd118 100644 --- a/import/src/plugins/misc.rs +++ b/import/src/plugins/misc.rs @@ -6,7 +6,8 @@ use crate::plugins::{ImportContext, ImportPlugin, PluginInfo}; use anyhow::{Context, Result, bail}; use jellycache::{HashKey, cache_store}; -use jellycommon::{Asset, NodeID, NodeKind, PictureSlot, Visibility}; +use jellycommon::{PICT_BACKDROP, PICT_COVER}; +use jellydb::table::RowNum; use jellyremuxer::matroska::{AttachedFile, Segment}; use log::info; use regex::Regex; @@ -26,14 +27,14 @@ impl ImportPlugin for ImageFiles { ..Default::default() } } - fn file(&self, ct: &ImportContext, parent: NodeID, path: &Path) -> Result<()> { + fn file(&self, ct: &ImportContext, parent: RowNum, path: &Path) -> Result<()> { let filename = path.file_name().unwrap().to_string_lossy(); let slot = match filename.as_ref() { - "poster.jpeg" | "poster.webp" | "poster.png" => PictureSlot::Cover, - "backdrop.jpeg" | "backdrop.webp" | "backdrop.png" => PictureSlot::Backdrop, + "poster.jpeg" | "poster.webp" | "poster.png" => PICT_COVER, + "backdrop.jpeg" | "backdrop.webp" | "backdrop.png" => PICT_BACKDROP, _ => return Ok(()), }; - info!("import {slot} at {path:?}"); + info!("import {} at {path:?}", slot); let asset = Asset(cache_store( format!("media/literal/{}-{slot}.image", HashKey(path)), || { @@ -141,7 +142,7 @@ impl ImportPlugin for Children { ..Default::default() } } - fn file(&self, ct: &ImportContext, parent: NodeID, path: &Path) -> Result<()> { + fn file(&self, ct: &ImportContext, parent: RowNum, path: &Path) -> Result<()> { let filename = path.file_name().unwrap().to_string_lossy(); if filename.as_ref() == "children" { info!("import children at {path:?}"); @@ -172,7 +173,7 @@ impl ImportPlugin for EpisodeIndex { ..Default::default() } } - fn media(&self, ct: &ImportContext, node: NodeID, path: &Path, _seg: &Segment) -> Result<()> { + fn media(&self, ct: &ImportContext, node: RowNum, path: &Path, _seg: &Segment) -> Result<()> { let filename = path.file_name().unwrap().to_string_lossy(); if let Some(cap) = RE_EPISODE_FILENAME.captures(&filename) { if let Some(episode) = cap.name("episode").map(|m| m.as_str()) { diff --git a/import/src/plugins/mod.rs b/import/src/plugins/mod.rs index 3aeefdf..095fd39 100644 --- a/import/src/plugins/mod.rs +++ b/import/src/plugins/mod.rs @@ -15,19 +15,20 @@ pub mod vgmdb; pub mod wikidata; pub mod wikimedia_commons; -use crate::{ApiSecrets, InheritedFlags}; +use crate::{ApiSecrets, DatabaseTables, InheritedFlags}; use anyhow::Result; -use jellycommon::{Node, NodeID}; -use jellydb::Database; +use jellycommon::jellyobject::Object; +use jellydb::table::{RowNum, Table}; use jellyremuxer::matroska::Segment; use std::{collections::HashSet, path::Path, sync::Mutex}; use tokio::runtime::Handle; pub struct ImportContext<'a> { - pub db: &'a Database, + pub dba: DatabaseTables, + pub nodes: &'a Table, pub rt: &'a Handle, pub iflags: InheritedFlags, - pub nodes: &'a Mutex<HashSet<NodeID>>, + pub pending_nodes: &'a Mutex<HashSet<RowNum>>, } #[derive(Default, Clone, Copy)] @@ -41,19 +42,19 @@ pub struct PluginInfo { pub trait ImportPlugin: Send + Sync { fn info(&self) -> PluginInfo; - fn file(&self, ct: &ImportContext, parent: NodeID, path: &Path) -> Result<()> { + fn file(&self, ct: &ImportContext, parent: RowNum, path: &Path) -> Result<()> { let _ = (ct, parent, path); Ok(()) } - fn media(&self, ct: &ImportContext, node: NodeID, path: &Path, seg: &Segment) -> Result<()> { + fn media(&self, ct: &ImportContext, node: RowNum, path: &Path, seg: &Segment) -> Result<()> { let _ = (ct, node, path, seg); Ok(()) } - fn instruction(&self, ct: &ImportContext, node: NodeID, line: &str) -> Result<()> { + fn instruction(&self, ct: &ImportContext, node: RowNum, line: &str) -> Result<()> { let _ = (ct, node, line); Ok(()) } - fn process(&self, ct: &ImportContext, node: NodeID, data: &Node) -> Result<()> { + fn process(&self, ct: &ImportContext, node: RowNum, data: Object<'_>) -> Result<()> { let _ = (ct, node, data); Ok(()) } diff --git a/import/src/plugins/tags.rs b/import/src/plugins/tags.rs index 9fa5ea9..07e40cc 100644 --- a/import/src/plugins/tags.rs +++ b/import/src/plugins/tags.rs @@ -6,7 +6,6 @@ use crate::plugins::{ImportContext, ImportPlugin, PluginInfo}; use anyhow::Result; -use jellycommon::{IdentifierType, NodeID, NodeKind}; use jellyremuxer::matroska::Segment; use std::{collections::HashMap, path::Path}; diff --git a/import/src/plugins/tmdb.rs b/import/src/plugins/tmdb.rs index 5527b8b..ce9ae59 100644 --- a/import/src/plugins/tmdb.rs +++ b/import/src/plugins/tmdb.rs @@ -9,10 +9,6 @@ use crate::{ }; use anyhow::{Context, Result, anyhow, bail}; use jellycache::{EscapeKey, HashKey, cache_memory, cache_store}; -use jellycommon::{ - Asset, IdentifierType, Node, NodeID, PictureSlot, RatingType, - chrono::{Utc, format::Parsed}, -}; use log::info; use reqwest::{ Client, ClientBuilder, diff --git a/import/src/plugins/trakt.rs b/import/src/plugins/trakt.rs index c8ff52a..7981713 100644 --- a/import/src/plugins/trakt.rs +++ b/import/src/plugins/trakt.rs @@ -9,7 +9,6 @@ use crate::{ }; use anyhow::{Context, Result, anyhow, bail}; use jellycache::{HashKey, cache_memory}; -use jellycommon::{Appearance, CreditCategory, IdentifierType, Node, NodeID, NodeKind, RatingType}; use log::info; use reqwest::{ Client, ClientBuilder, diff --git a/import/src/plugins/vgmdb.rs b/import/src/plugins/vgmdb.rs index 83f677d..734c7af 100644 --- a/import/src/plugins/vgmdb.rs +++ b/import/src/plugins/vgmdb.rs @@ -10,7 +10,6 @@ use crate::{ }; use anyhow::{Context, Result}; use jellycache::{HashKey, cache, cache_store}; -use jellycommon::Asset; use log::info; use regex::Regex; use reqwest::{ diff --git a/import/src/plugins/wikimedia_commons.rs b/import/src/plugins/wikimedia_commons.rs index 58a28ae..c849b61 100644 --- a/import/src/plugins/wikimedia_commons.rs +++ b/import/src/plugins/wikimedia_commons.rs @@ -10,7 +10,6 @@ use crate::{ }; use anyhow::{Context, Result}; use jellycache::{EscapeKey, cache_store}; -use jellycommon::Asset; use reqwest::{ Client, ClientBuilder, header::{HeaderMap, HeaderName, HeaderValue}, @@ -40,7 +39,7 @@ impl WikimediaCommons { Self { client } } - pub fn image_by_filename(&self, filename: String, rt: &Handle) -> Result<Asset> { + pub fn image_by_filename(&self, filename: String, rt: &Handle) -> Result<String> { cache_store( format!("ext/wikimedia-commons/image/{}.image", EscapeKey(&filename)), move || { @@ -61,7 +60,6 @@ impl WikimediaCommons { }, ) .context("mediawiki image by filename") - .map(Asset) } } |