From f52fe3a710a181d58980c13de0f02c04a67d0bdb Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 7 Apr 2026 11:52:19 +0300 Subject: [PATCH] implement channel limit option; increase minor version --- Cargo.lock | 2 +- Cargo.toml | 2 +- example/config.toml | 1 + src/config/channel.rs | 1 + src/main.rs | 6 +++++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddcbd9a..8d84fc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2448,7 +2448,7 @@ dependencies = [ [[package]] name = "ytd" -version = "0.2.1" +version = "0.3.0" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 766248c..08c1708 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ytd" -version = "0.2.1" +version = "0.3.0" edition = "2024" license = "MIT" readme = "README.md" diff --git a/example/config.toml b/example/config.toml index 043873b..0c4ed56 100644 --- a/example/config.toml +++ b/example/config.toml @@ -16,6 +16,7 @@ sleep = 1 is_live = false is_short = false is_upcoming = false + # limit = 1 # Channel item commands to apply (in order) diff --git a/src/config/channel.rs b/src/config/channel.rs index 7edcde2..19becf6 100644 --- a/src/config/channel.rs +++ b/src/config/channel.rs @@ -10,4 +10,5 @@ pub struct Channel { pub is_live: bool, pub is_short: bool, pub is_upcoming: bool, + pub limit: Option, } diff --git a/src/main.rs b/src/main.rs index 8c7ec71..ca6f11b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,11 @@ async fn main() { Ok(result) => { let items = result.content.items; debug!("received {:?} items to handle...", items.len()); - for item in items { + for (i, item) in items.into_iter().enumerate() { + if channel.limit.is_some_and(|l| i > l) { + debug!("items limit for channel `{c}` reached at {i}; break."); + break; + } match database.get(&item.id) { Ok(id) => { if id.is_some() {