make is_live, is_short, is_upcoming optional

This commit is contained in:
yggverse 2026-04-07 12:36:27 +03:00
parent d8a0c31889
commit 7ca93042b7
3 changed files with 18 additions and 9 deletions

View file

@ -13,9 +13,9 @@ sleep = 1
[channel.test]
id = "UCl2mFZoRqjw_ELax4Yisf6w" # channel ID
is_live = false
is_short = false
is_upcoming = false
# is_live = false
# is_short = false
# is_upcoming = false
# items_limit = 1
# item_name_regex = ".*"

View file

@ -8,9 +8,9 @@ use serde::Deserialize;
pub struct Channel {
pub id: String,
pub command: Vec<Command>,
pub is_live: bool,
pub is_short: bool,
pub is_upcoming: bool,
pub is_live: Option<bool>,
pub is_short: Option<bool>,
pub is_upcoming: Option<bool>,
pub items_limit: Option<usize>,
#[serde(default)]
#[serde(with = "serde_regex")]

View file

@ -79,21 +79,30 @@ async fn main() {
item.id
),
}
if item.is_live != channel.is_live {
if channel
.is_live
.is_some_and(|is_live| item.is_live != is_live)
{
debug!(
"skip item `{}` for channel `{c}` by `is_live` filter (item: {:?}/config:{:?})",
item.id, item.is_live, channel.is_live
);
continue;
}
if item.is_short != channel.is_short {
if channel
.is_short
.is_some_and(|is_short| item.is_short != is_short)
{
debug!(
"skip item `{}` for channel `{c}` by `is_short` filter (item: {:?}/config:{:?})",
item.id, item.is_short, channel.is_short
);
continue;
}
if item.is_upcoming != channel.is_upcoming {
if channel
.is_upcoming
.is_some_and(|is_upcoming| item.is_upcoming != is_upcoming)
{
debug!(
"skip item `{}` for channel `{c}` by `is_upcoming` filter (item: {:?}/config:{:?})",
item.id, item.is_upcoming, channel.is_upcoming