diff --git a/Cargo.toml b/Cargo.toml index df8d0b1..0659823 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ scraper = "0.24.0" once_cell = "1.21.3" rustc-hash = "2.1.1" async-trait = "0.1" +regex = "1.12.2" [lints.rust] unexpected_cfgs = "allow" diff --git a/src/providers/xxdbx.rs b/src/providers/xxdbx.rs index 8cc7ce6..5237567 100644 --- a/src/providers/xxdbx.rs +++ b/src/providers/xxdbx.rs @@ -10,6 +10,7 @@ use error_chain::error_chain; use htmlentity::entity::{ICodedDataTrait, decode}; use std::sync::{Arc, RwLock}; use std::vec; +use regex::Regex; error_chain! { foreign_links { @@ -18,6 +19,12 @@ error_chain! { } } +fn is_valid_date(s: &str) -> bool { + // Regex: strict yyyy-mm-dd (no validation of real calendar dates, just format) + let re = Regex::new(r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$").unwrap(); + re.is_match(s) +} + #[derive(Debug, Clone)] pub struct XxdbxProvider { url: String, @@ -124,6 +131,8 @@ impl XxdbxProvider { search_type = "channels"; } else if self.stars.read().unwrap().iter().map(|s|s.to_ascii_lowercase()).collect::>().contains(&search_string.to_ascii_lowercase()) { search_type = "stars"; + } else if is_valid_date(&search_string){ + search_type = "dates"; } let video_url = format!(