feat: add timezone query option

This commit is contained in:
ThetaDev 2025-01-18 07:03:36 +01:00
parent ccb1178b95
commit 3a2370b97c
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6
14 changed files with 132 additions and 25 deletions

View file

@ -55,6 +55,10 @@ struct Cli {
/// YouTube content country
#[clap(long, global = true)]
country: Option<String>,
/// UTC offset in minutes
#[cfg(feature = "timezone")]
#[clap(long, global = true)]
timezone: Option<String>,
/// Use authentication
#[clap(long, global = true)]
auth: bool,
@ -913,6 +917,20 @@ async fn run() -> anyhow::Result<()> {
if let Some(botguard_bin) = cli.botguard_bin {
rp = rp.botguard_bin(botguard_bin);
}
#[cfg(feature = "timezone")]
if let Some(timezone) = cli.timezone {
use time::OffsetDateTime;
use time_tz::{Offset, TimeZone};
let tz = time_tz::timezones::get_by_name(&timezone).expect("invalid timezone");
let offset = tz
.get_offset_utc(&OffsetDateTime::now_utc())
.to_utc()
.whole_minutes();
rp = rp.timezone(tz.name(), offset);
}
if cli.no_botguard {
rp = rp.no_botguard();
}