diff options
-rw-r--r-- | import/src/infojson.rs | 4 | ||||
-rw-r--r-- | import/src/main.rs | 4 | ||||
-rw-r--r-- | remuxer/src/import/mod.rs | 1 | ||||
-rw-r--r-- | remuxer/src/import/seek_index.rs | 1 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 24 |
5 files changed, 28 insertions, 6 deletions
diff --git a/import/src/infojson.rs b/import/src/infojson.rs index 0ed496c..d9d60ed 100644 --- a/import/src/infojson.rs +++ b/import/src/infojson.rs @@ -26,8 +26,8 @@ pub struct YVideo { pub playable_in_embed: bool, pub automatic_captions: HashMap<String, Vec<YCaption>>, pub comment_count: usize, - pub chapters: Vec<YChapter>, - pub heatmap: Vec<YHeatmapSample>, + pub chapters: Option<Vec<YChapter>>, + pub heatmap: Option<Vec<YHeatmapSample>>, pub like_count: usize, pub channel: String, pub channel_follower_count: usize, diff --git a/import/src/main.rs b/import/src/main.rs index 71c3c1e..29d1e21 100644 --- a/import/src/main.rs +++ b/import/src/main.rs @@ -309,9 +309,9 @@ fn make_ident(s: &str) -> String { let mut out = String::new(); for s in s.chars() { match s { - 'a'..='z' => out.push(s), + 'a'..='z' | '0'..='9' => out.push(s), 'A'..='Z' => out.push(s.to_ascii_lowercase()), - '-' | ' ' | '_' => out.push('-'), + '-' | ' ' | '_' | ':' => out.push('-'), _ => (), } } diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs index ab3be3d..0a9aebf 100644 --- a/remuxer/src/import/mod.rs +++ b/remuxer/src/import/mod.rs @@ -88,6 +88,7 @@ fn import_read_segment(segment: &mut Unflatten) -> Result<MatroskaMetadata> { } } } + MatroskaTag::Void(_) => {} MatroskaTag::Tags(_) => { let mut children = children.unwrap(); while let Some(Ok(Unflat { children, item, .. })) = children.n() { diff --git a/remuxer/src/import/seek_index.rs b/remuxer/src/import/seek_index.rs index 0427287..3ab4a2c 100644 --- a/remuxer/src/import/seek_index.rs +++ b/remuxer/src/import/seek_index.rs @@ -61,6 +61,7 @@ fn import_seek_index_segment( MatroskaTag::Cues(_) => {} MatroskaTag::Chapters(_) => {} MatroskaTag::Tracks(_) => {} + MatroskaTag::Void(_) => {} MatroskaTag::Cluster(_) => { let mut children = children.unwrap(); let mut pts = 0; diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 2c335d3..83719d0 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -17,7 +17,7 @@ use crate::{ uri, }; use anyhow::{anyhow, Context}; -use jellycommon::{MediaInfo, NodeKind, NodePublic, SourceTrackKind}; +use jellycommon::{MediaInfo, NodeKind, NodePublic, Rating, SourceTrackKind}; use rocket::{get, serde::json::Json, Either, State}; #[get("/n/<id>")] @@ -74,7 +74,7 @@ markup::define! { } NodeCard<'a>(id: &'a str, node: &'a NodePublic) { @PosterCard { - wide: matches!(node.kind, NodeKind::Collection), + wide: matches!(node.kind, NodeKind::Collection | NodeKind::Video), dir: !matches!(node.kind, NodeKind::Movie | NodeKind::Episode), id, title: &node.title @@ -129,6 +129,13 @@ markup::define! { p { @format_duration(m.duration) } p { @m.resolution_name() } } + @for r in &node.ratings { + p { @match r { + Rating::YoutubeLikes(n) => { @format_count(*n) " Likes" } + Rating::YoutubeViews(n) => { @format_count(*n) " Views" } + _ => { "Unknown Rating" } + } } + } } h3 { @node.tagline } p { @node.description } @@ -187,6 +194,7 @@ impl MediaInfoExt for MediaInfo { match maxw { 7680.. => "8K", 3840.. => "4K", + 2560.. => "WQHD", 1920.. => "Full HD", 1280.. => "HD 720p", 640.. => "NTSC", @@ -194,3 +202,15 @@ impl MediaInfoExt for MediaInfo { } } } + +fn format_count(n: impl Into<usize>) -> String { + let n: usize = n.into(); + + if n >= 1_000_000 { + format!("{:.1}M", n as f32 / 1_000_000.) + } else if n >= 1_000 { + format!("{:.1}k", n as f32 / 1_000.) + } else { + format!("{n}") + } +} |