From f0ebfb710caa82ca4aa9bafb9e17c6669a3b94e7 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Sun, 10 Apr 2022 22:05:19 +0200 Subject: [PATCH] make category optional --- Cargo.toml | 2 ++ src/filter/mod.rs | 2 +- src/input/playlist.rs | 6 ++++-- src/main.rs | 6 +++--- src/utils/mod.rs | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c23d5a08..4ede8c10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,7 @@ [package] name = "ffplayout-rs" +description = "24/7 playout based on rust and ffmpeg" +license = "GPL-3.0" version = "0.9.1" edition = "2021" diff --git a/src/filter/mod.rs b/src/filter/mod.rs index 7ff433bf..03edeb9c 100644 --- a/src/filter/mod.rs +++ b/src/filter/mod.rs @@ -142,7 +142,7 @@ fn fade(node: &mut Media, chain: &mut Filters, codec_type: &str) { fn overlay(node: &mut Media, chain: &mut Filters, config: &GlobalConfig) { if config.processing.add_logo && Path::new(&config.processing.logo).is_file() - && node.category != "advertisement".to_string() + && &node.category.clone().unwrap_or(String::new()) != "advertisement" { let opacity = format!( "format=rgba,colorchannelmixer=aa={}", diff --git a/src/input/playlist.rs b/src/input/playlist.rs index a4b5cccf..b63fda94 100644 --- a/src/input/playlist.rs +++ b/src/input/playlist.rs @@ -179,13 +179,15 @@ impl CurrentProgram { let index = *self.index.lock().unwrap(); let current_list = self.nodes.lock().unwrap(); - if index + 1 < current_list.len() && ¤t_list[index + 1].category == "advertisement" { + if index + 1 < current_list.len() + && ¤t_list[index + 1].category.clone().unwrap_or(String::new()) == "advertisement" + { self.current_node.next_ad = Some(true); } if index > 0 && index < current_list.len() - && ¤t_list[index - 1].category == "advertisement" + && ¤t_list[index - 1].category.clone().unwrap_or(String::new()) == "advertisement" { self.current_node.last_ad = Some(true); } diff --git a/src/main.rs b/src/main.rs index 1fe5ee48..e57d5147 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ +extern crate log; +extern crate simplelog; + use std::{ path::PathBuf, {fs, fs::File}, }; -extern crate log; -extern crate simplelog; - use serde::{Deserialize, Serialize}; use serde_json::json; use simplelog::*; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index c0532312..5608602d 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -147,7 +147,7 @@ pub struct Media { pub seek: f64, pub out: f64, pub duration: f64, - pub category: String, + pub category: Option, pub source: String, pub cmd: Option>, pub filter: Option>, @@ -177,7 +177,7 @@ impl Media { seek: 0.0, out: duration, duration: duration, - category: String::new(), + category: None, source: src.clone(), cmd: Some(vec!["-i".to_string(), src]), filter: Some(vec![]),