feat: add Zz (global) country param

This commit is contained in:
ThetaDev 2022-12-01 13:31:36 +01:00
parent f20ea693a6
commit 88104753e0
11 changed files with 8678 additions and 53700 deletions

View file

@ -421,7 +421,7 @@ impl RustyPipeBuilder {
///
/// **Info**: you can set this option for individual queries, too
pub fn country(mut self, country: Country) -> Self {
self.default_opts.country = country;
self.default_opts.country = validate_country(country);
self
}
@ -759,7 +759,7 @@ impl RustyPipeQuery {
/// Set the country parameter used when accessing the YouTube API.
/// This will change trends and recommended content.
pub fn country(mut self, country: Country) -> Self {
self.opts.country = country;
self.opts.country = validate_country(country);
self
}
@ -1194,6 +1194,15 @@ trait MapResponse<T> {
) -> Result<MapResult<T>, ExtractionError>;
}
fn validate_country(country: Country) -> Country {
if country == Country::Zz {
warn!("Country:Zz (Global) can only be used for fetching music charts, falling back to Country:Us");
Country::Us
} else {
country
}
}
#[cfg(test)]
mod tests {
use super::*;