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

@ -7,7 +7,10 @@ use std::{
use rustypipe::{
client::{ClientType, RustyPipe},
param::search_filter::{self, Entity, SearchFilter},
param::{
search_filter::{self, Entity, SearchFilter},
Country,
},
report::{Report, Reporter},
};
@ -830,11 +833,7 @@ async fn music_new_videos(testfiles: &Path) {
}
async fn music_charts(testfiles: &Path) {
for (name, id) in [
("default", None),
("US", Some("US")),
("unavailable", Some("MY")),
] {
for (name, country) in [("global", Some(Country::Zz)), ("US", Some(Country::Us))] {
let mut json_path = testfiles.to_path_buf();
json_path.push("music_charts");
json_path.push(&format!("charts_{}.json", name));
@ -843,6 +842,6 @@ async fn music_charts(testfiles: &Path) {
}
let rp = rp_testfile(&json_path);
rp.query().music_charts(id).await.unwrap();
rp.query().music_charts(country).await.unwrap();
}
}

View file

@ -235,22 +235,23 @@ pub enum Country {
.collect::<String>();
// Language enum
let _ = write!(code_langs, " /// {}\n ", n);
write!(code_langs, " /// {}\n ", n).unwrap();
if c.contains('-') {
let _ = write!(code_langs, "#[serde(rename = \"{}\")]\n ", c);
write!(code_langs, "#[serde(rename = \"{}\")]\n ", c).unwrap();
}
code_langs += &enum_name;
code_langs += ",\n";
// Language array
let _ = writeln!(code_lang_array, " Language::{},", enum_name);
writeln!(code_lang_array, " Language::{},", enum_name).unwrap();
// Language names
let _ = writeln!(
writeln!(
code_lang_names,
" Language::{} => \"{}\",",
enum_name, n
);
)
.unwrap();
});
code_langs += "}\n";
@ -258,19 +259,26 @@ pub enum Country {
let enum_name = c[0..1].to_owned().to_uppercase() + &c[1..].to_owned().to_lowercase();
// Country enum
let _ = writeln!(code_countries, " /// {}", n);
let _ = writeln!(code_countries, " {},", enum_name);
writeln!(code_countries, " /// {}", n).unwrap();
writeln!(code_countries, " {},", enum_name).unwrap();
// Country array
let _ = writeln!(code_country_array, " Country::{},", enum_name);
writeln!(code_country_array, " Country::{},", enum_name).unwrap();
// Country names
let _ = writeln!(
writeln!(
code_country_names,
" Country::{} => \"{}\",",
enum_name, n
);
)
.unwrap();
});
// Add Country::Zz / Global
code_countries += " /// Global (can only be used for music charts)\n";
code_countries += " Zz,\n";
code_country_names += " Country::Zz => \"Global\",\n";
code_countries += "}\n";
code_lang_array += "];\n";