diff options
Diffstat (limited to 'import/src/plugins/misc.rs')
| -rw-r--r-- | import/src/plugins/misc.rs | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/import/src/plugins/misc.rs b/import/src/plugins/misc.rs index 1699f6d..2c56dae 100644 --- a/import/src/plugins/misc.rs +++ b/import/src/plugins/misc.rs @@ -3,7 +3,10 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::plugins::{ImportPlugin, PluginContext, PluginInfo}; +use crate::{ + plugins::{ImportPlugin, PluginContext, PluginInfo}, + source_rank::ObjectImportSourceExt, +}; use anyhow::{Context, Result, bail}; use jellycache::HashKey; use jellycommon::*; @@ -23,6 +26,7 @@ impl ImportPlugin for ImageFiles { fn info(&self) -> PluginInfo { PluginInfo { name: "image-files", + tag: MSOURCE_EXPLICIT, handle_file: true, ..Default::default() } @@ -47,7 +51,7 @@ impl ImportPlugin for ImageFiles { let mut node = txn.get(row)?.unwrap(); node = node .as_object() - .update(NO_PICTURES, |picts| picts.insert(slot, &asset)); + .update(NO_PICTURES, |picts| picts.insert_s(ct.is, slot, &asset)); txn.update(row, node)?; Ok(()) })?; @@ -63,6 +67,7 @@ impl ImportPlugin for ImageAttachments { fn info(&self) -> PluginInfo { PluginInfo { name: "image-attachments", + tag: MSOURCE_IMAGE_ATT, handle_media: true, ..Default::default() } @@ -79,8 +84,9 @@ impl ImportPlugin for ImageAttachments { }; ct.ic.update_node(row, |node| { - node.as_object() - .update(NO_PICTURES, |picts| picts.insert(PICT_COVER, &cover)) + node.as_object().update(NO_PICTURES, |picts| { + picts.insert_s(ct.is, PICT_COVER, &cover) + }) })?; Ok(()) } @@ -91,6 +97,7 @@ impl ImportPlugin for General { fn info(&self) -> PluginInfo { PluginInfo { name: "general", + tag: MSOURCE_EXPLICIT, handle_instruction: true, ..Default::default() } @@ -98,12 +105,13 @@ impl ImportPlugin for General { fn instruction(&self, ct: &PluginContext, node: RowNum, line: &str) -> Result<()> { if line == "hidden" { ct.ic.update_node(node, |node| { - node.as_object().insert(NO_VISIBILITY, VISI_HIDDEN) + node.as_object().insert_s(ct.is, NO_VISIBILITY, VISI_HIDDEN) })?; } if line == "reduced" { ct.ic.update_node(node, |node| { - node.as_object().insert(NO_VISIBILITY, VISI_REDUCED) + node.as_object() + .insert_s(ct.is, NO_VISIBILITY, VISI_REDUCED) })?; } if let Some(kind) = line.strip_prefix("kind-").or(line.strip_prefix("kind=")) { @@ -121,16 +129,18 @@ impl ImportPlugin for General { _ => bail!("unknown node kind"), }; ct.ic - .update_node(node, |node| node.as_object().insert(NO_KIND, kind))?; + .update_node(node, |node| node.as_object().insert_s(ct.is, NO_KIND, kind))?; } if let Some(title) = line.strip_prefix("title=") { - ct.ic - .update_node(node, |node| node.as_object().insert(NO_TITLE, title))?; + ct.ic.update_node(node, |node| { + node.as_object().insert_s(ct.is, NO_TITLE, title) + })?; } if let Some(index) = line.strip_prefix("index=") { let index = index.parse().context("parse index")?; - ct.ic - .update_node(node, |node| node.as_object().insert(NO_INDEX, index))?; + ct.ic.update_node(node, |node| { + node.as_object().insert_s(ct.is, NO_INDEX, index) + })?; } Ok(()) } @@ -141,6 +151,7 @@ impl ImportPlugin for Children { fn info(&self) -> PluginInfo { PluginInfo { name: "children", + tag: MSOURCE_EXPLICIT, handle_file: true, ..Default::default() } @@ -155,7 +166,7 @@ impl ImportPlugin for Children { continue; } ct.ic - .update_node_slug(line, |n| n.as_object().insert(NO_PARENT, parent))?; + .update_node_slug(line, |n| n.as_object().extend(NO_PARENT, [parent]))?; } } Ok(()) @@ -170,6 +181,7 @@ impl ImportPlugin for EpisodeIndex { fn info(&self) -> PluginInfo { PluginInfo { name: "episode-info", + tag: MSOURCE_IMAGE_ATT, handle_media: true, ..Default::default() } @@ -186,9 +198,9 @@ impl ImportPlugin for EpisodeIndex { .context("parse season num")?; ct.ic.update_node(node, |mut node| { - node = node.as_object().insert(NO_SEASON_INDEX, season); - node = node.as_object().insert(NO_INDEX, episode); - node = node.as_object().insert(NO_KIND, KIND_EPISODE); + node = node.as_object().insert_s(ct.is, NO_SEASON_INDEX, season); + node = node.as_object().insert_s(ct.is, NO_INDEX, episode); + node = node.as_object().insert_s(ct.is, NO_KIND, KIND_EPISODE); node })?; } |