Merge pull request #170 from jb-alvarado/master

fix playlist serializer, when source is null
This commit is contained in:
jb-alvarado 2022-07-28 14:43:57 +02:00 committed by GitHub
commit d90661f4cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 10 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -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]

View File

@ -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]

View File

@ -197,8 +197,13 @@ pub fn read_json(
.write(false)
.open(&current_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(&current_file);
let list_clone = playlist.clone();

View File

@ -37,14 +37,14 @@ pub fn validate_playlist(
if probe.format.is_none() {
error!(
"No Metadata at <yellow>{}</>, from file <b><magenta>{}</></b>",
"No Metadata at <yellow>{}</>, from file <b><magenta>\"{}\"</></b>",
sec_to_time(begin),
item.source
);
}
} else {
error!(
"Source on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
"Source on position <yellow>{}</> not exists: <b><magenta>\"{}\"</></b>",
sec_to_time(begin),
item.source
);

View File

@ -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<String, D::Error>
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 {