diff --git a/Cargo.lock b/Cargo.lock index 2a2cbaef..e8f101f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1014,7 +1014,7 @@ dependencies = [ [[package]] name = "ffplayout" -version = "0.13.0" +version = "0.13.1" dependencies = [ "clap", "crossbeam-channel 0.5.6", @@ -1062,7 +1062,7 @@ dependencies = [ [[package]] name = "ffplayout-lib" -version = "0.13.0" +version = "0.13.1" dependencies = [ "chrono", "crossbeam-channel 0.5.6", diff --git a/ffplayout-engine/Cargo.toml b/ffplayout-engine/Cargo.toml index 05bf3db5..4163361e 100644 --- a/ffplayout-engine/Cargo.toml +++ b/ffplayout-engine/Cargo.toml @@ -4,7 +4,7 @@ description = "24/7 playout based on rust and ffmpeg" license = "GPL-3.0" authors = ["Jonathan Baecker jonbae77@gmail.com"] readme = "README.md" -version = "0.13.0" +version = "0.13.1" edition = "2021" [dependencies] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 63a43cae..2f890872 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -4,7 +4,7 @@ description = "Library for ffplayout" license = "GPL-3.0" authors = ["Jonathan Baecker jonbae77@gmail.com"] readme = "README.md" -version = "0.13.0" +version = "0.13.1" edition = "2021" [dependencies] diff --git a/lib/src/utils/json_serializer.rs b/lib/src/utils/json_serializer.rs index a9d90e39..22252867 100644 --- a/lib/src/utils/json_serializer.rs +++ b/lib/src/utils/json_serializer.rs @@ -197,8 +197,13 @@ pub fn read_json( .write(false) .open(¤t_file) .expect("Could not open json playlist file."); - let mut playlist: JsonPlaylist = - serde_json::from_reader(f).expect("Could't read json playlist file."); + let mut playlist: JsonPlaylist = match serde_json::from_reader(f) { + Ok(p) => p, + Err(e) => { + error!("Playlist file not readable! {e}"); + JsonPlaylist::new(date, start_sec) + } + }; playlist.modified = modified_time(¤t_file); let list_clone = playlist.clone(); diff --git a/lib/src/utils/json_validate.rs b/lib/src/utils/json_validate.rs index 94bf850b..2eb9930e 100644 --- a/lib/src/utils/json_validate.rs +++ b/lib/src/utils/json_validate.rs @@ -37,14 +37,14 @@ pub fn validate_playlist( if probe.format.is_none() { error!( - "No Metadata at {}, from file {}", + "No Metadata at {}, from file \"{}\"", sec_to_time(begin), item.source ); } } else { error!( - "Source on position {} not exists: {}", + "Source on position {} not exists: \"{}\"", sec_to_time(begin), item.source ); diff --git a/lib/src/utils/mod.rs b/lib/src/utils/mod.rs index 22f39106..fa1b478b 100644 --- a/lib/src/utils/mod.rs +++ b/lib/src/utils/mod.rs @@ -15,7 +15,7 @@ use jsonrpc_http_server::hyper::HeaderMap; use rand::prelude::*; use regex::Regex; use reqwest::header; -use serde::{Deserialize, Serialize}; +use serde::{de::Deserializer, Deserialize, Serialize}; use serde_json::json; use simplelog::*; @@ -49,8 +49,9 @@ pub struct Media { pub out: f64, pub duration: f64, - #[serde(default)] + #[serde(deserialize_with = "null_string")] pub category: String, + #[serde(deserialize_with = "null_string")] pub source: String, #[serde(skip_serializing, skip_deserializing)] @@ -144,6 +145,13 @@ impl PartialEq for Media { impl Eq for Media {} +fn null_string<'de, D>(d: D) -> Result +where + D: Deserializer<'de>, +{ + Deserialize::deserialize(d).map(|x: Option<_>| x.unwrap_or_default()) +} + /// We use the ffprobe crate, but we map the metadata to our needs. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct MediaProbe {