mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 12:55:32 +00:00
rename channel.command to channel.item
This commit is contained in:
parent
7ca93042b7
commit
cc0bd6f798
4 changed files with 10 additions and 10 deletions
|
|
@ -21,16 +21,16 @@ sleep = 1
|
||||||
|
|
||||||
# Channel item commands to apply (in order)
|
# Channel item commands to apply (in order)
|
||||||
|
|
||||||
[[channel.test.command]]
|
[[channel.test.item]]
|
||||||
exec = "/usr/bin/echo {ID}" # Supported macro replacements:
|
exec = "/usr/bin/echo {ID}" # Supported macro replacements:
|
||||||
# * {ID} - parsed item URL
|
# * {ID} - parsed item URL
|
||||||
# See also: https://codeberg.org/YGGverse/pidpilne/src/branch/main/usr/local/bin/aacp.m4a
|
# 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
|
stdout_contains = "\n" # Check stdout for containing expected string, optional
|
||||||
|
|
||||||
# [[channel.test.command]]
|
# [[channel.test.item]]
|
||||||
# ..
|
# ..
|
||||||
|
|
||||||
# [[channel.test.command]]
|
# [[channel.test.item]]
|
||||||
# ..
|
# ..
|
||||||
|
|
||||||
# [channel.test2]
|
# [channel.test2]
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
mod command;
|
mod item;
|
||||||
|
|
||||||
use command::Command;
|
use item::Item;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Channel {
|
pub struct Channel {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub command: Vec<Command>,
|
pub item: Vec<Item>,
|
||||||
pub is_live: Option<bool>,
|
pub is_live: Option<bool>,
|
||||||
pub is_short: Option<bool>,
|
pub is_short: Option<bool>,
|
||||||
pub is_upcoming: Option<bool>,
|
pub is_upcoming: Option<bool>,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub struct Command {
|
pub struct Item {
|
||||||
pub exec: String,
|
pub exec: String,
|
||||||
pub stdout_contains: Option<String>,
|
pub stdout_contains: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -109,12 +109,12 @@ async fn main() {
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for command in &channel.command {
|
for channel_item in &channel.item {
|
||||||
let cmd = command.exec.replace("{ID}", &item.id);
|
let cmd = channel_item.exec.replace("{ID}", &item.id);
|
||||||
match Command::new("sh").arg("-c").arg(&cmd).output() {
|
match Command::new("sh").arg("-c").arg(&cmd).output() {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if response.status.success() {
|
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)
|
String::from_utf8_lossy(&response.stdout).contains(s)
|
||||||
}) {
|
}) {
|
||||||
match database.process(&item.id) {
|
match database.process(&item.id) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue