mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 04:55:26 +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:
|
||||
# * {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
|
||||
stdout_contains = ["\n"] # Check stdout for containing expected string, optional
|
||||
|
||||
# [[channel.test.item]]
|
||||
# ..
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ use serde::Deserialize;
|
|||
#[derive(Deserialize, PartialEq, Eq, Hash)]
|
||||
pub struct Item {
|
||||
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() {
|
||||
Ok(response) => {
|
||||
if response.status.success() {
|
||||
if channel_item.stdout_contains.as_ref().is_none_or(|s| {
|
||||
String::from_utf8_lossy(&response.stdout).contains(s)
|
||||
if channel_item.stdout_contains.as_ref().is_none_or(|v| {
|
||||
v.iter().all(|s| {
|
||||
String::from_utf8_lossy(&response.stdout)
|
||||
.contains(s)
|
||||
})
|
||||
}) {
|
||||
match database.process(&item.id) {
|
||||
Ok(()) => info!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue