diff options
author | metamuffin <metamuffin@disroot.org> | 2024-03-23 01:04:06 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-03-23 01:04:06 +0100 |
commit | 1d38bd821351324b51a15a9400630c49d9838f80 (patch) | |
tree | 3c0c29e4967d2b298f80c87b8825961a86d8a319 | |
parent | a5b49a157d6b4cb52c8421fec4d65835b310f767 (diff) | |
download | jellything-1d38bd821351324b51a15a9400630c49d9838f80.tar jellything-1d38bd821351324b51a15a9400630c49d9838f80.tar.bz2 jellything-1d38bd821351324b51a15a9400630c49d9838f80.tar.zst |
new track kind for short form video
-rw-r--r-- | common/src/lib.rs | 1 | ||||
-rw-r--r-- | import/src/infojson.rs | 3 | ||||
-rw-r--r-- | import/src/lib.rs | 9 | ||||
-rw-r--r-- | server/src/routes/ui/sort.rs | 3 |
4 files changed, 15 insertions, 1 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs index 2973a54..cf33032 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -153,6 +153,7 @@ pub enum ImportSource { pub enum NodeKind { #[cfg_attr(feature = "rocket", field(value = "movie"))] #[default] Movie, #[cfg_attr(feature = "rocket", field(value = "video"))] Video, + #[cfg_attr(feature = "rocket", field(value = "shortformvideo"))] ShortFormVideo, #[cfg_attr(feature = "rocket", field(value = "collection"))] Collection, #[cfg_attr(feature = "rocket", field(value = "channel"))] Channel, #[cfg_attr(feature = "rocket", field(value = "show"))] Show, diff --git a/import/src/infojson.rs b/import/src/infojson.rs index c83c91c..8704fef 100644 --- a/import/src/infojson.rs +++ b/import/src/infojson.rs @@ -26,6 +26,9 @@ pub struct YVideo { pub categories: Vec<String>, pub tags: Vec<String>, pub playable_in_embed: bool, + pub aspect_ratio: Option<f32>, + pub width: Option<i32>, + pub height: Option<i32>, pub automatic_captions: HashMap<String, Vec<YCaption>>, pub comment_count: Option<usize>, pub chapters: Option<Vec<YChapter>>, diff --git a/import/src/lib.rs b/import/src/lib.rs index e8c9708..7369f7a 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -516,7 +516,14 @@ async fn process_source( let infojson: infojson::YVideo = serde_json::from_str(&infojson).context("parsing infojson")?; - node.public.kind = Some(NodeKind::Video); + node.public.kind = Some( + if infojson.duration.unwrap_or(0.) < 120. && infojson.aspect_ratio.unwrap_or(2.) < 1. + { + NodeKind::ShortFormVideo + } else { + NodeKind::Video + }, + ); node.public.title = Some(infojson.title); node.public.description = Some(infojson.description); node.public.tagline = Some(infojson.webpage_url); diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs index 542b7af..4f62639 100644 --- a/server/src/routes/ui/sort.rs +++ b/server/src/routes/ui/sort.rs @@ -33,6 +33,7 @@ form_enum!( WatchProgress = "watch_progress", KindMovie = "kind_movie", KindVideo = "kind_video", + KindShortFormVideo = "kind_short_form_video", KindCollection = "kind_collection", KindChannel = "kind_channel", KindShow = "kind_show", @@ -90,6 +91,7 @@ impl FilterProperty { &[ (KindMovie, "Movie"), (KindVideo, "Video"), + (KindShortFormVideo, "Short Form Video"), (KindCollection, "Collection"), (KindChannel, "Channel"), (KindShow, "Show"), @@ -145,6 +147,7 @@ pub fn filter_and_sort_nodes( FilterProperty::FederationRemote => node.federated.is_some(), FilterProperty::KindMovie => node.kind == Some(NodeKind::Movie), FilterProperty::KindVideo => node.kind == Some(NodeKind::Video), + FilterProperty::KindShortFormVideo => node.kind == Some(NodeKind::ShortFormVideo), FilterProperty::KindCollection => node.kind == Some(NodeKind::Collection), FilterProperty::KindChannel => node.kind == Some(NodeKind::Channel), FilterProperty::KindShow => node.kind == Some(NodeKind::Show), |