mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 12:55:32 +00:00
add new debug events; change some levels to info
This commit is contained in:
parent
9f3b722a8f
commit
9b0f438932
1 changed files with 8 additions and 6 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -33,15 +33,17 @@ async fn main() {
|
|||
let update = config.update.map(Duration::from_secs);
|
||||
let sleep = config.sleep.map(Duration::from_secs);
|
||||
let mut database = Database::new(&config.database).unwrap();
|
||||
|
||||
let rp = RustyPipe::new();
|
||||
|
||||
loop {
|
||||
info!("begin {} channels update...", config.channel.len());
|
||||
for (c, channel) in &config.channel {
|
||||
debug!("handle channel `{c}` ({})...", channel.id);
|
||||
debug!("get `{c}` ({})...", channel.id);
|
||||
match rp.query().channel_videos(&channel.id).await {
|
||||
Ok(result) => {
|
||||
for item in result.content.items {
|
||||
let items = result.content.items;
|
||||
debug!("received {:?} items to handle...", items.len());
|
||||
for item in items {
|
||||
if database.is_processed(&item.id).is_ok_and(|r| r) {
|
||||
debug!(
|
||||
"item `{}` for channel `{c}` already processed; skip handle.",
|
||||
|
|
@ -79,7 +81,7 @@ async fn main() {
|
|||
String::from_utf8_lossy(&response.stdout).contains(s)
|
||||
}) {
|
||||
match database.process(&item.id) {
|
||||
Ok(()) => debug!(
|
||||
Ok(()) => info!(
|
||||
"exec `{cmd}` for channel `{c}` successful: `{:?}`",
|
||||
response
|
||||
),
|
||||
|
|
@ -117,14 +119,14 @@ async fn main() {
|
|||
}
|
||||
match update {
|
||||
Some(duration) => {
|
||||
debug!(
|
||||
info!(
|
||||
"queue completed; await {} seconds to continue...",
|
||||
duration.as_secs()
|
||||
);
|
||||
thread::sleep(duration)
|
||||
}
|
||||
None => {
|
||||
debug!("all tasks completed; exit.");
|
||||
info!("all tasks completed; exit.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue