mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 21:05:30 +00:00
implement stdout_contains option as vector
This commit is contained in:
parent
cc0bd6f798
commit
1cbdcfbede
3 changed files with 7 additions and 4 deletions
|
|
@ -25,7 +25,7 @@ sleep = 1
|
||||||
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.item]]
|
# [[channel.test.item]]
|
||||||
# ..
|
# ..
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ use serde::Deserialize;
|
||||||
#[derive(Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
pub exec: String,
|
pub exec: String,
|
||||||
pub stdout_contains: Option<String>,
|
pub stdout_contains: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,11 @@ async fn main() {
|
||||||
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 channel_item.stdout_contains.as_ref().is_none_or(|s| {
|
if channel_item.stdout_contains.as_ref().is_none_or(|v| {
|
||||||
String::from_utf8_lossy(&response.stdout).contains(s)
|
v.iter().all(|s| {
|
||||||
|
String::from_utf8_lossy(&response.stdout)
|
||||||
|
.contains(s)
|
||||||
|
})
|
||||||
}) {
|
}) {
|
||||||
match database.process(&item.id) {
|
match database.process(&item.id) {
|
||||||
Ok(()) => info!(
|
Ok(()) => info!(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue