diff options
Diffstat (limited to 'import/src/main.rs')
-rw-r--r-- | import/src/main.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/import/src/main.rs b/import/src/main.rs index b55b645..2d66221 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -41,6 +41,8 @@ enum Action { #[arg(short = 'T', long)] tmdb_id: Option<String>, #[arg(long)] + ident_prefix: Option<String>, + #[arg(long)] copy: bool, #[arg(long)] r#move: bool, @@ -67,6 +69,7 @@ fn main() -> anyhow::Result<()> { tmdb_search, input, series, + ident_prefix, copy, video, r#move, @@ -151,7 +154,17 @@ fn main() -> anyhow::Result<()> { .map(|d| d.title.clone().or(d.name.clone())) .flatten()) .unwrap(); - let ident = make_ident(&title); + + let ident = format!( + "{}{}", + ident_prefix.unwrap_or(String::new()), + make_ident( + &infojson + .as_ref() + .map(|i| i.id.clone()) + .unwrap_or(title.clone()) + ), + ); let path = path.join(&ident); let source_path = input.as_ref().map(|_| path.join(format!("source.mkv"))); @@ -228,11 +241,13 @@ fn main() -> anyhow::Result<()> { ratings.extend( infojson .as_ref() - .map(|i| Rating::YoutubeLikes(i.like_count)), + .map(|i| i.like_count.map(Rating::YoutubeLikes)) + .flatten(), ); let node = Node { private: NodePrivate { + id: Some(ident.clone()), import: None, backdrop: backdrop.clone().map(AssetLocation::Library), poster: poster.clone().map(AssetLocation::Library), @@ -292,9 +307,9 @@ fn main() -> anyhow::Result<()> { seek_index::write_all(&source_path)?; } let f = File::create(path.join(if series { - "directory.json".to_string() + "directory.json" } else { - format!("{ident}.jelly") + "item.jelly" }))?; serde_json::to_writer_pretty(f, &node)?; } |