diff --git a/example/config.toml b/example/config.toml index e34f663..df2e152 100644 --- a/example/config.toml +++ b/example/config.toml @@ -21,16 +21,16 @@ sleep = 1 # Channel item commands to apply (in order) - [[channel.test.command]] + [[channel.test.item]] exec = "/usr/bin/echo {ID}" # Supported macro replacements: # * {ID} - parsed item URL # See also: https://codeberg.org/YGGverse/pidpilne/src/branch/main/usr/local/bin/aacp.m4a stdout_contains = "\n" # Check stdout for containing expected string, optional - # [[channel.test.command]] + # [[channel.test.item]] # .. - # [[channel.test.command]] + # [[channel.test.item]] # .. # [channel.test2] diff --git a/src/config/channel.rs b/src/config/channel.rs index 027edf6..49b9035 100644 --- a/src/config/channel.rs +++ b/src/config/channel.rs @@ -1,13 +1,13 @@ -mod command; +mod item; -use command::Command; +use item::Item; use regex::Regex; use serde::Deserialize; #[derive(Deserialize)] pub struct Channel { pub id: String, - pub command: Vec, + pub item: Vec, pub is_live: Option, pub is_short: Option, pub is_upcoming: Option, diff --git a/src/config/channel/command.rs b/src/config/channel/item.rs similarity index 86% rename from src/config/channel/command.rs rename to src/config/channel/item.rs index a20079e..f83b40b 100644 --- a/src/config/channel/command.rs +++ b/src/config/channel/item.rs @@ -1,7 +1,7 @@ use serde::Deserialize; #[derive(Deserialize, PartialEq, Eq, Hash)] -pub struct Command { +pub struct Item { pub exec: String, pub stdout_contains: Option, } diff --git a/src/main.rs b/src/main.rs index ff64d55..04ff9b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,12 +109,12 @@ async fn main() { ); continue; } - for command in &channel.command { - let cmd = command.exec.replace("{ID}", &item.id); + for channel_item in &channel.item { + let cmd = channel_item.exec.replace("{ID}", &item.id); match Command::new("sh").arg("-c").arg(&cmd).output() { Ok(response) => { if response.status.success() { - if command.stdout_contains.as_ref().is_none_or(|s| { + if channel_item.stdout_contains.as_ref().is_none_or(|s| { String::from_utf8_lossy(&response.stdout).contains(s) }) { match database.process(&item.id) {