From cc37287b8c7280051a07d8f735e47e88bfe9fee6 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 4 Aug 2023 09:49:51 +0200 Subject: import video description --- remuxer/src/import/mod.rs | 56 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'remuxer/src') 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, pub description: Option, + pub tagline: Option, pub tracks: Vec, pub track_sources: Vec, pub image: Option<(String, Vec)>, @@ -87,24 +88,43 @@ fn import_read_segment(segment: &mut Unflatten) -> Result { } } 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(_) => {} -- cgit v1.2.3-70-g09d2