diff options
Diffstat (limited to 'import/src')
-rw-r--r-- | import/src/infojson.rs | 10 | ||||
-rw-r--r-- | import/src/main.rs | 23 |
2 files changed, 24 insertions, 9 deletions
diff --git a/import/src/infojson.rs b/import/src/infojson.rs index 2f5eeb7..ca02551 100644 --- a/import/src/infojson.rs +++ b/import/src/infojson.rs @@ -16,7 +16,7 @@ pub struct YVideo { pub thumbnail: String, pub description: String, pub channel_id: String, - pub duration: f64, + pub duration: Option<f64>, pub view_count: usize, pub average_rating: Option<String>, pub age_limit: usize, @@ -28,8 +28,8 @@ pub struct YVideo { pub comment_count: Option<usize>, pub chapters: Option<Vec<YChapter>>, pub heatmap: Option<Vec<YHeatmapSample>>, - pub like_count: usize, - pub channel: String, + pub like_count: Option<usize>, + pub channel: Option<String>, pub channel_follower_count: usize, pub channel_is_verified: Option<bool>, pub uploader: String, @@ -93,8 +93,8 @@ pub struct YFormat { #[derive(Debug, Serialize, Deserialize)] pub struct YFragment { - pub url: String, - pub duration: f64, + pub url: Option<String>, + pub duration: Option<f64>, } #[derive(Debug, Serialize, Deserialize)] 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)?; } |