diff options
-rw-r--r-- | import/src/lib.rs | 24 | ||||
-rw-r--r-- | server/src/routes/ui/admin/mod.rs | 1 | ||||
-rw-r--r-- | server/src/routes/ui/sort.rs | 8 |
3 files changed, 31 insertions, 2 deletions
diff --git a/import/src/lib.rs b/import/src/lib.rs index 36014ea..125b20b 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -213,6 +213,20 @@ fn import_file( Ok(()) })?; } + "children" => { + info!("import children at {path:?}"); + for line in read_to_string(path)?.lines() { + let line = line.trim(); + if line.starts_with("#") || line.is_empty() { + continue; + } + db.update_node_init(NodeID::from_slug(line), |n| { + n.slug = line.to_owned(); + n.parents.insert(parent); + Ok(()) + })?; + } + } "channel.info.json" => { info!("import channel info.json at {path:?}"); let data = serde_json::from_reader::<_, YVideo>(BufReader::new(File::open(path)?))?; @@ -355,10 +369,18 @@ fn import_media_file( node.visibility = visibility; node.poster = m.cover.clone().or(poster); node.backdrop = backdrop; - node.description = tags.remove("DESCRIPTION"); + node.description = tags.remove("DESCRIPTION").or(tags.remove("SYNOPSIS")); node.tagline = tags.remove("COMMENT"); node.parents.insert(parent); + if let Some(ct) = tags.get("CONTENT_TYPE") { + node.kind = match ct.to_lowercase().trim() { + "movie" | "documentary" | "film" => NodeKind::Movie, + "music" | "recording" => NodeKind::Music, + _ => NodeKind::Unknown, + } + } + if let Some(data) = tmdb_data { node.title = data.title.clone(); node.tagline = data.tagline.clone(); diff --git a/server/src/routes/ui/admin/mod.rs b/server/src/routes/ui/admin/mod.rs index edbdb03..10c7365 100644 --- a/server/src/routes/ui/admin/mod.rs +++ b/server/src/routes/ui/admin/mod.rs @@ -151,7 +151,6 @@ pub async fn r_admin_import( ) -> MyResult<DynLayoutPage<'static>> { drop(session); let t = Instant::now(); - database.clear_nodes()?; if !incremental { database.clear_nodes()?; } diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs index af874f8..36250a9 100644 --- a/server/src/routes/ui/sort.rs +++ b/server/src/routes/ui/sort.rs @@ -54,6 +54,7 @@ form_enum!( RatingYoutubeLikes = "rating_yt_likes", RatingYoutubeFollowers = "rating_yt_followers", RatingUser = "rating_user", + RatingLikesDivViews = "rating_loved", } ); @@ -77,6 +78,7 @@ impl SortProperty { (RatingYoutubeLikes, "Youtube Likes"), (RatingYoutubeViews, "Youtube Views"), (RatingUser, "Your Rating"), + (RatingLikesDivViews, "Likes per view"), ], ), ] @@ -197,6 +199,12 @@ pub fn filter_and_sort_nodes( SortProperty::RatingYoutubeFollowers => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::YoutubeFollowers).unwrap_or(&0.)) }), + SortProperty::RatingLikesDivViews => nodes.sort_by_cached_key(|(n, _)| { + SortAnyway( + *n.ratings.get(&Rating::YoutubeLikes).unwrap_or(&0.) + / (1. + *n.ratings.get(&Rating::YoutubeViews).unwrap_or(&0.)), + ) + }), SortProperty::RatingUser => nodes.sort_by_cached_key(|(_, u)| u.rating), } |