aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-04 09:49:51 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-04 09:49:51 +0200
commitcc37287b8c7280051a07d8f735e47e88bfe9fee6 (patch)
treef6081de54d47e7b4cde709ef77901ac6a6d93327
parent9d283fff3352b970a0dd0cb913e122b4d3c3d342 (diff)
downloadjellything-cc37287b8c7280051a07d8f735e47e88bfe9fee6.tar
jellything-cc37287b8c7280051a07d8f735e47e88bfe9fee6.tar.bz2
jellything-cc37287b8c7280051a07d8f735e47e88bfe9fee6.tar.zst
import video description
-rw-r--r--common/src/lib.rs1
-rw-r--r--import/src/main.rs89
-rw-r--r--remuxer/src/import/mod.rs56
-rw-r--r--server/src/routes/ui/node.rs2
4 files changed, 93 insertions, 55 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index a0695ee..1da312f 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -59,6 +59,7 @@ pub enum AssetLocation {
#[serde(rename_all = "snake_case")]
pub enum NodeKind {
Movie,
+ Video,
Collection,
Show,
Series,
diff --git a/import/src/main.rs b/import/src/main.rs
index 645bca0..806ebfb 100644
--- a/import/src/main.rs
+++ b/import/src/main.rs
@@ -39,6 +39,8 @@ enum Action {
copy: bool,
#[arg(long)]
r#move: bool,
+ #[arg(long)]
+ video: bool,
#[arg(short, long)]
input: Option<PathBuf>,
#[arg(short, long)]
@@ -61,6 +63,7 @@ fn main() -> anyhow::Result<()> {
input,
series,
copy,
+ video,
r#move,
} => {
let tmdb_kind = if series { "tv" } else { "movie" };
@@ -128,7 +131,11 @@ fn main() -> anyhow::Result<()> {
import_seek_index(&mut input)?
};
- kind = NodeKind::Movie;
+ kind = if video {
+ NodeKind::Video
+ } else {
+ NodeKind::Movie
+ };
}
let title = file_meta
@@ -143,37 +150,42 @@ fn main() -> anyhow::Result<()> {
let ident = make_ident(&title);
let path = path.join(&ident);
- let poster = tmdb_details
- .as_ref()
- .map(|d| {
- d.poster_path
- .as_ref()
- .map(|p| {
- let pu = path.join("poster.jpeg");
- let mut f = File::create(&pu)?;
- tmdb_image(&p, &mut f)?;
- Ok::<_, anyhow::Error>(pu)
- })
- .transpose()
- })
- .transpose()?
- .flatten();
+ let (mut poster, mut backdrop) = (None, None);
+ if !args.dry {
+ std::fs::create_dir_all(&path)?;
- let backdrop = tmdb_details
- .as_ref()
- .map(|d| {
- d.backdrop_path
- .as_ref()
- .map(|p| {
- let pu = path.join("backdrop.jpeg");
- let mut f = File::create(&pu)?;
- tmdb_image(&p, &mut f)?;
- Ok::<_, anyhow::Error>(pu)
- })
- .transpose()
- })
- .transpose()?
- .flatten();
+ poster = tmdb_details
+ .as_ref()
+ .map(|d| {
+ d.poster_path
+ .as_ref()
+ .map(|p| {
+ let pu = path.join("poster.jpeg");
+ let mut f = File::create(&pu)?;
+ tmdb_image(&p, &mut f)?;
+ Ok::<_, anyhow::Error>(pu)
+ })
+ .transpose()
+ })
+ .transpose()?
+ .flatten();
+
+ backdrop = tmdb_details
+ .as_ref()
+ .map(|d| {
+ d.backdrop_path
+ .as_ref()
+ .map(|p| {
+ let pu = path.join("backdrop.jpeg");
+ let mut f = File::create(&pu)?;
+ tmdb_image(&p, &mut f)?;
+ Ok::<_, anyhow::Error>(pu)
+ })
+ .transpose()
+ })
+ .transpose()?
+ .flatten();
+ }
let node = Node {
private: NodePrivate {
@@ -187,11 +199,17 @@ fn main() -> anyhow::Result<()> {
public: NodePublic {
parent: None,
federated: None,
- description: tmdb_details.as_ref().map(|d| d.overview.to_owned()),
- tagline: tmdb_details
+ description: file_meta
.as_ref()
- .map(|d| d.tagline.to_owned())
- .flatten(),
+ .map(|m| m.description.clone())
+ .flatten()
+ .or(tmdb_details.as_ref().map(|d| d.overview.to_owned())),
+ tagline: file_meta.as_ref().map(|m| m.tagline.clone()).flatten().or(
+ tmdb_details
+ .as_ref()
+ .map(|d| d.tagline.to_owned())
+ .flatten(),
+ ),
title,
index: None,
kind,
@@ -206,7 +224,6 @@ fn main() -> anyhow::Result<()> {
if args.dry {
println!("{}", serde_json::to_string_pretty(&node)?)
} else {
- std::fs::create_dir_all(&path)?;
if let Some(source_path) = source_path_e {
let input = input.clone().unwrap();
if r#move {
diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs
index f9f655a..8c89b4d 100644
--- a/remuxer/src/import/mod.rs
+++ b/remuxer/src/import/mod.rs
@@ -19,6 +19,7 @@ use std::path::PathBuf;
pub struct MatroskaMetadata {
pub title: Option<String>,
pub description: Option<String>,
+ pub tagline: Option<String>,
pub tracks: Vec<SourceTrack>,
pub track_sources: Vec<LocalTrack>,
pub image: Option<(String, Vec<u8>)>,
@@ -87,24 +88,43 @@ fn import_read_segment(segment: &mut Unflatten) -> Result<MatroskaMetadata> {
}
}
MatroskaTag::Tags(_) => {
- // let mut children = children.unwrap();
- // while let Some(Ok(Unflat {
- // children, item, ..
- // })) = children.n()
- // {
- // match item {
- // MatroskaTag::Tag(_) => {
- // let mut children = children.unwrap();
- // while let Some(Ok(Unflat {
- // children, item, ..
- // })) = children.n() {
-
- // }
-
- // },
- // _ => debug!("(rst) tag ignored: {item:?}"),
- // }
- // }
+ let mut children = children.unwrap();
+ while let Some(Ok(Unflat { children, item, .. })) = children.n() {
+ match item {
+ MatroskaTag::Tag(_) => {
+ let mut children = children.unwrap();
+ while let Some(Ok(Unflat { children, item, .. })) = children.n() {
+ match item {
+ MatroskaTag::SimpleTag(_) => {
+ let (mut key, mut value) = (None, None);
+ let mut children = children.unwrap();
+ while let Some(Ok(Unflat {
+ children: _, item, ..
+ })) = children.n()
+ {
+ match item {
+ MatroskaTag::TagName(k) => key = Some(k),
+ MatroskaTag::TagString(v) => value = Some(v),
+ _ => debug!("(rstts) tag ignored: {item:?}"),
+ }
+ }
+ match (key, value) {
+ (Some(key), Some(value)) => match key.as_str() {
+ "DESCRIPTION" => m.description = Some(value),
+ "COMMENT" => m.tagline = Some(value),
+ _ => debug!("simple tag ignored: {key:?}"),
+ },
+ (None, None) => (),
+ _ => warn!("simple tag with only one of name/string"),
+ }
+ }
+ _ => debug!("(rstt) tag ignored: {item:?}"),
+ }
+ }
+ }
+ _ => debug!("(rst) tag ignored: {item:?}"),
+ }
+ }
}
MatroskaTag::Cues(_) => {}
MatroskaTag::Chapters(_) => {}
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs
index 1d74b9e..2c335d3 100644
--- a/server/src/routes/ui/node.rs
+++ b/server/src/routes/ui/node.rs
@@ -69,7 +69,7 @@ markup::define! {
@match node.kind {
NodeKind::Collection | NodeKind::Show | NodeKind::Season => { @DirectoryPage { node, _id: id, children } }
NodeKind::Series => { @SeriesPage { node, children, id } }
- NodeKind::Movie | NodeKind::Episode => { @ItemPage { node, id } }
+ NodeKind::Movie | NodeKind::Episode | NodeKind::Video => { @ItemPage { node, id } }
}
}
NodeCard<'a>(id: &'a str, node: &'a NodePublic) {