diff options
Diffstat (limited to 'tool/src/main.rs')
-rw-r--r-- | tool/src/main.rs | 106 |
1 files changed, 47 insertions, 59 deletions
diff --git a/tool/src/main.rs b/tool/src/main.rs index 31e63b7..6384822 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -5,12 +5,10 @@ */ #![feature(file_create_new)] -pub mod import; pub mod migrate; use base64::Engine; use clap::{Parser, Subcommand, ValueEnum}; -use import::import; use jellyclient::{Instance, LoginDetails}; use jellycommon::{config::GlobalConfig, Node, NodeKind, NodePrivate, NodePublic}; use log::{info, warn}; @@ -37,47 +35,47 @@ enum Action { #[arg(short, long)] hostname: String, }, - /// Imports a movie, video or series given media and metadata sources - New { - /// Relative path to the node's parent(!). - path: PathBuf, - /// Search the node by title on TMDB - #[arg(short = 't', long)] - tmdb_search: Option<String>, - /// Search the node by id on TMDB - #[arg(short = 'T', long)] - tmdb_id: Option<String>, - #[arg(long)] - /// Prefix the inferred id with something to avoid collisions - ident_prefix: Option<String>, - /// Copies media into the library - #[arg(long)] - copy: bool, - /// Moves media into the library (potentially destructive operation) - #[arg(long)] - r#move: bool, - /// Marks node as a video - #[arg(long)] - video: bool, - /// Marks node as a series - #[arg(short, long)] - series: bool, - /// Path to the media of the node, required for non-series - #[arg(short, long)] - input: Option<PathBuf>, - /// Ignore attachments (dont use them as cover) - #[arg(long)] - ignore_attachments: bool, - /// Ignore metadate (no title, description and tagline from input) - #[arg(long)] - ignore_metadata: bool, - /// Skip any action that appears to be run already. - #[arg(long)] - skip_existing: bool, - /// Sets the title - #[arg(long)] - title: Option<String>, - }, + // /// Imports a movie, video or series given media and metadata sources + // New { + // /// Relative path to the node's parent(!). + // path: PathBuf, + // /// Search the node by title on TMDB + // #[arg(short = 't', long)] + // tmdb_search: Option<String>, + // /// Search the node by id on TMDB + // #[arg(short = 'T', long)] + // tmdb_id: Option<String>, + // #[arg(long)] + // /// Prefix the inferred id with something to avoid collisions + // ident_prefix: Option<String>, + // /// Copies media into the library + // #[arg(long)] + // copy: bool, + // /// Moves media into the library (potentially destructive operation) + // #[arg(long)] + // r#move: bool, + // /// Marks node as a video + // #[arg(long)] + // video: bool, + // /// Marks node as a series + // #[arg(short, long)] + // series: bool, + // /// Path to the media of the node, required for non-series + // #[arg(short, long)] + // input: Option<PathBuf>, + // /// Ignore attachments (dont use them as cover) + // #[arg(long)] + // ignore_attachments: bool, + // /// Ignore metadate (no title, description and tagline from input) + // #[arg(long)] + // ignore_metadata: bool, + // /// Skip any action that appears to be run already. + // #[arg(long)] + // skip_existing: bool, + // /// Sets the title + // #[arg(long)] + // title: Option<String>, + // }, Migrate { database: PathBuf, mode: MigrateMode, @@ -118,8 +116,11 @@ fn main() -> anyhow::Result<()> { std::fs::create_dir_all(path.join("library"))?; std::fs::create_dir_all(path.join("cache"))?; std::fs::create_dir_all(path.join("assets"))?; + std::fs::create_dir_all(path.join("media"))?; File::create_new(path.join("assets/front.htm"))? .write_fmt(format_args!("<h1>My very own jellything instance</h1>"))?; + + // TODO: dont fill that serde_yaml::to_writer( File::create_new(path.join("config.yaml"))?, &GlobalConfig { @@ -149,8 +150,8 @@ fn main() -> anyhow::Result<()> { File::create_new(path.join("library/directory.json"))?, &Node { public: NodePublic { - kind: NodeKind::Collection, - title: "My Library".to_string(), + kind: Some(NodeKind::Collection), + title: Some("My Library".to_string()), ..Default::default() }, private: NodePrivate { @@ -162,7 +163,7 @@ fn main() -> anyhow::Result<()> { warn!("please change the admin password."); Ok(()) } - a @ Action::New { .. } => import(a, args.dry), + // a @ Action::New { .. } => import(a, args.dry), a @ Action::Migrate { .. } => migrate(a), Action::Reimport { config, @@ -192,19 +193,6 @@ fn main() -> anyhow::Result<()> { } } -fn make_ident(s: &str) -> String { - let mut out = String::new(); - for s in s.chars() { - match s { - 'a'..='z' | '0'..='9' => out.push(s), - 'A'..='Z' => out.push(s.to_ascii_lowercase()), - '-' | ' ' | '_' | ':' => out.push('-'), - _ => (), - } - } - out -} - fn ok_or_warn<T, E: Debug>(r: Result<T, E>) -> Option<T> { match r { Ok(t) => Some(t), |