Worked on safer fetching

This commit is contained in:
Lukas Wölfer
2025-07-24 01:56:23 +02:00
parent 637ff144c3
commit 29e85397a7
8 changed files with 163 additions and 96 deletions

View File

@@ -1,6 +1,9 @@
use std::time::SystemTime;
use mwbot::{
Bot, Page,
generators::{Generator, querypage::QueryPage, search::Search},
parsoid::{Wikicode, WikinodeIterator},
};
pub async fn wanted_ids(bot: Bot) -> Vec<(u32, Page)> {
@@ -42,8 +45,19 @@ fn parse_wsdc_page_name(name: &str) -> Result<u32, TitleParseError> {
}
}
// fn get_wsdc_page_date(page: &Wikicode) -> Option<SystemTime> {
// let prefix = "Updated-On: ";
// page.filter_comments()
// .iter()
// .filter_map(|x| {
// let c = x.text_contents();
// if c.starts_with(prefix) { Some(c) } else { None }
// })
// .map(|x| x.trim_start_matches(prefix).parse::<u64>());
// }
#[allow(dead_code)]
pub async fn index_wsdc_ids(bot: &Bot) -> Vec<u32> {
pub async fn index_wsdc_ids(bot: &Bot) -> Vec<(u32, Page)> {
let mut gene = Search::new("WSDC/").generate(bot);
let mut result = vec![];
while let Some(x) = gene.recv().await {
@@ -55,7 +69,7 @@ pub async fn index_wsdc_ids(bot: &Bot) -> Vec<u32> {
}
};
if let Ok(n) = parse_wsdc_page_name(p.title()) {
result.push(n);
result.push((n, p));
}
}
result