rename channel.command to channel.item

This commit is contained in:
yggverse 2026-04-07 12:46:17 +03:00
parent 7ca93042b7
commit cc0bd6f798
4 changed files with 10 additions and 10 deletions

View file

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

View file

@ -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<Command>,
pub item: Vec<Item>,
pub is_live: Option<bool>,
pub is_short: Option<bool>,
pub is_upcoming: Option<bool>,

View file

@ -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<String>,
}

View file

@ -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) {