Merge pull request #170 from jb-alvarado/master
fix playlist serializer, when source is null
This commit is contained in:
commit
d90661f4cf
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1014,7 +1014,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout"
|
name = "ffplayout"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"crossbeam-channel 0.5.6",
|
"crossbeam-channel 0.5.6",
|
||||||
@ -1062,7 +1062,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout-lib"
|
name = "ffplayout-lib"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"crossbeam-channel 0.5.6",
|
"crossbeam-channel 0.5.6",
|
||||||
|
@ -4,7 +4,7 @@ description = "24/7 playout based on rust and ffmpeg"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -4,7 +4,7 @@ description = "Library for ffplayout"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -197,8 +197,13 @@ pub fn read_json(
|
|||||||
.write(false)
|
.write(false)
|
||||||
.open(¤t_file)
|
.open(¤t_file)
|
||||||
.expect("Could not open json playlist file.");
|
.expect("Could not open json playlist file.");
|
||||||
let mut playlist: JsonPlaylist =
|
let mut playlist: JsonPlaylist = match serde_json::from_reader(f) {
|
||||||
serde_json::from_reader(f).expect("Could't read json playlist file.");
|
Ok(p) => p,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Playlist file not readable! {e}");
|
||||||
|
JsonPlaylist::new(date, start_sec)
|
||||||
|
}
|
||||||
|
};
|
||||||
playlist.modified = modified_time(¤t_file);
|
playlist.modified = modified_time(¤t_file);
|
||||||
|
|
||||||
let list_clone = playlist.clone();
|
let list_clone = playlist.clone();
|
||||||
|
@ -37,14 +37,14 @@ pub fn validate_playlist(
|
|||||||
|
|
||||||
if probe.format.is_none() {
|
if probe.format.is_none() {
|
||||||
error!(
|
error!(
|
||||||
"No Metadata at <yellow>{}</>, from file <b><magenta>{}</></b>",
|
"No Metadata at <yellow>{}</>, from file <b><magenta>\"{}\"</></b>",
|
||||||
sec_to_time(begin),
|
sec_to_time(begin),
|
||||||
item.source
|
item.source
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"Source on position <yellow>{}</> not exists: <b><magenta>{}</></b>",
|
"Source on position <yellow>{}</> not exists: <b><magenta>\"{}\"</></b>",
|
||||||
sec_to_time(begin),
|
sec_to_time(begin),
|
||||||
item.source
|
item.source
|
||||||
);
|
);
|
||||||
|
@ -15,7 +15,7 @@ use jsonrpc_http_server::hyper::HeaderMap;
|
|||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use reqwest::header;
|
use reqwest::header;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{de::Deserializer, Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
|
|
||||||
@ -49,8 +49,9 @@ pub struct Media {
|
|||||||
pub out: f64,
|
pub out: f64,
|
||||||
pub duration: f64,
|
pub duration: f64,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(deserialize_with = "null_string")]
|
||||||
pub category: String,
|
pub category: String,
|
||||||
|
#[serde(deserialize_with = "null_string")]
|
||||||
pub source: String,
|
pub source: String,
|
||||||
|
|
||||||
#[serde(skip_serializing, skip_deserializing)]
|
#[serde(skip_serializing, skip_deserializing)]
|
||||||
@ -144,6 +145,13 @@ impl PartialEq for Media {
|
|||||||
|
|
||||||
impl Eq 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.
|
/// We use the ffprobe crate, but we map the metadata to our needs.
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub struct MediaProbe {
|
pub struct MediaProbe {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user