aboutsummaryrefslogtreecommitdiff
path: root/import/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-05 12:32:35 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-05 12:32:35 +0200
commitba3dedfaa6fee280761282f50fdee92b65cf0bfd (patch)
tree2798c163a2ff3fd9c11ca68dab9e6ca2f9a73cf9 /import/src/main.rs
parentabb8e4a10f0ac0a8c0a652efe8b0efc0da59c46e (diff)
downloadjellything-ba3dedfaa6fee280761282f50fdee92b65cf0bfd.tar
jellything-ba3dedfaa6fee280761282f50fdee92b65cf0bfd.tar.bz2
jellything-ba3dedfaa6fee280761282f50fdee92b65cf0bfd.tar.zst
ability to override id from json and import
Diffstat (limited to 'import/src/main.rs')
-rw-r--r--import/src/main.rs23
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)?;
}