Image transformation
This commit is contained in:
@@ -31,6 +31,9 @@ pub use group::*;
|
||||
mod text;
|
||||
pub use text::*;
|
||||
|
||||
mod image;
|
||||
pub use image::*;
|
||||
|
||||
use crate::{
|
||||
extract::{
|
||||
misc::MapExtractor,
|
||||
@@ -41,6 +44,7 @@ use crate::{
|
||||
|
||||
pub struct ItemExtractor {
|
||||
inner: MapExtractor,
|
||||
image: Arc<ImageExtractor>,
|
||||
}
|
||||
|
||||
impl ItemExtractor {
|
||||
@@ -91,7 +95,10 @@ impl ItemExtractor {
|
||||
]),
|
||||
};
|
||||
|
||||
Self { inner }
|
||||
Self {
|
||||
inner,
|
||||
image: Arc::new(ImageExtractor::new(item)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,22 +110,16 @@ impl ObjectExtractor for ItemExtractor {
|
||||
name: &pile_config::Label,
|
||||
args: Option<&str>,
|
||||
) -> Result<Option<PileValue>, std::io::Error> {
|
||||
self.inner.field(state, name, args).await
|
||||
if self.image.fields().await?.contains(name) {
|
||||
self.image.field(state, name, args).await
|
||||
} else {
|
||||
self.inner.field(state, name, args).await
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::unwrap_used)]
|
||||
async fn fields(&self) -> Result<Vec<Label>, std::io::Error> {
|
||||
return Ok(vec![
|
||||
Label::new("flac").unwrap(),
|
||||
Label::new("id3").unwrap(),
|
||||
Label::new("fs").unwrap(),
|
||||
Label::new("epub").unwrap(),
|
||||
Label::new("exif").unwrap(),
|
||||
Label::new("pdf").unwrap(),
|
||||
Label::new("json").unwrap(),
|
||||
Label::new("toml").unwrap(),
|
||||
Label::new("text").unwrap(),
|
||||
Label::new("groups").unwrap(),
|
||||
]);
|
||||
let mut fields = self.inner.fields().await?;
|
||||
fields.extend(self.image.fields().await?);
|
||||
Ok(fields)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user