fix: a/b test 10: channel about modal
This commit is contained in:
parent
cced125390
commit
ba06e2c8c8
17 changed files with 1686 additions and 2932 deletions
|
|
@ -26,6 +26,7 @@ pub enum ABTest {
|
|||
ShortDateFormat = 7,
|
||||
TrackViewcount = 8,
|
||||
PlaylistsForShorts = 9,
|
||||
ChannelAboutModal = 10,
|
||||
}
|
||||
|
||||
const TESTS_TO_RUN: [ABTest; 3] = [
|
||||
|
|
@ -98,6 +99,7 @@ pub async fn run_test(
|
|||
ABTest::ShortDateFormat => short_date_format(&query).await,
|
||||
ABTest::PlaylistsForShorts => playlists_for_shorts(&query).await,
|
||||
ABTest::TrackViewcount => track_viewcount(&query).await,
|
||||
ABTest::ChannelAboutModal => channel_about_modal(&query).await,
|
||||
}
|
||||
.unwrap();
|
||||
pb.inc(1);
|
||||
|
|
@ -259,6 +261,16 @@ pub async fn short_date_format(rp: &RustyPipeQuery) -> Result<bool> {
|
|||
}))
|
||||
}
|
||||
|
||||
pub async fn playlists_for_shorts(rp: &RustyPipeQuery) -> Result<bool> {
|
||||
let playlist = rp.playlist("UUSHh8gHdtzO2tXd593_bjErWg").await?;
|
||||
let v1 = playlist
|
||||
.videos
|
||||
.items
|
||||
.first()
|
||||
.ok_or_else(|| anyhow::anyhow!("no videos"))?;
|
||||
Ok(v1.publish_date_txt.is_none())
|
||||
}
|
||||
|
||||
pub async fn track_viewcount(rp: &RustyPipeQuery) -> Result<bool> {
|
||||
let res = rp.music_search("lieblingsmensch namika").await?;
|
||||
|
||||
|
|
@ -273,12 +285,19 @@ pub async fn track_viewcount(rp: &RustyPipeQuery) -> Result<bool> {
|
|||
Ok(track.view_count.is_some())
|
||||
}
|
||||
|
||||
pub async fn playlists_for_shorts(rp: &RustyPipeQuery) -> Result<bool> {
|
||||
let playlist = rp.playlist("UUSHh8gHdtzO2tXd593_bjErWg").await?;
|
||||
let v1 = playlist
|
||||
.videos
|
||||
.items
|
||||
.first()
|
||||
.ok_or_else(|| anyhow::anyhow!("no videos"))?;
|
||||
Ok(v1.publish_date_txt.is_none())
|
||||
pub async fn channel_about_modal(rp: &RustyPipeQuery) -> Result<bool> {
|
||||
let id = "UC2DjFE7Xf11URZqWBigcVOQ";
|
||||
let res = rp
|
||||
.raw(
|
||||
ClientType::Desktop,
|
||||
"browse",
|
||||
&QBrowse {
|
||||
context: rp.get_context(ClientType::Desktop, true, None).await,
|
||||
browse_id: id,
|
||||
params: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
Ok(!res.contains("\"EgVhYm91dPIGBAoCEgA%3D\""))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ async fn channel_playlists() {
|
|||
}
|
||||
|
||||
async fn channel_info() {
|
||||
let json_path = path!(*TESTFILES_DIR / "channel" / "channel_info.json");
|
||||
let json_path = path!(*TESTFILES_DIR / "channel" / "channel_info2.json");
|
||||
if json_path.exists() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,11 +202,20 @@ pub enum Country {
|
|||
.to_owned();
|
||||
|
||||
let mut code_lang_array = format!(
|
||||
"/// Array of all available languages\npub const LANGUAGES: [Language; {}] = [\n",
|
||||
r#"/// Array of all available languages
|
||||
/// The languages are sorted by their native names. This array can be used to display
|
||||
/// a language selection or to get the language code from a language name using binary search.
|
||||
pub const LANGUAGES: [Language; {}] = [
|
||||
"#,
|
||||
languages.len()
|
||||
);
|
||||
let mut code_country_array = format!(
|
||||
"/// Array of all available countries\npub const COUNTRIES: [Country; {}] = [\n",
|
||||
r#"/// Array of all available countries
|
||||
///
|
||||
/// The countries are sorted by their english names. This array can be used to display
|
||||
/// a country selection or to get the country code from a country name using binary search.
|
||||
pub const COUNTRIES: [Country; {}] = [
|
||||
"#,
|
||||
countries.len()
|
||||
);
|
||||
|
||||
|
|
@ -252,9 +261,6 @@ pub enum Country {
|
|||
code_langs += &enum_name;
|
||||
code_langs += ",\n";
|
||||
|
||||
// Language array
|
||||
writeln!(code_lang_array, " Language::{enum_name},").unwrap();
|
||||
|
||||
// Language names
|
||||
writeln!(
|
||||
code_lang_names,
|
||||
|
|
@ -264,6 +270,24 @@ pub enum Country {
|
|||
}
|
||||
code_langs += "}\n";
|
||||
|
||||
// Language array
|
||||
let languages_by_name = languages
|
||||
.iter()
|
||||
.map(|(k, v)| (v, k))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
for code in languages_by_name.values() {
|
||||
let enum_name = code.split('-').fold(String::new(), |mut output, c| {
|
||||
let _ = write!(
|
||||
output,
|
||||
"{}{}",
|
||||
c[0..1].to_owned().to_uppercase(),
|
||||
c[1..].to_owned().to_lowercase()
|
||||
);
|
||||
output
|
||||
});
|
||||
writeln!(code_lang_array, " Language::{enum_name},").unwrap();
|
||||
}
|
||||
|
||||
for (c, n) in &countries {
|
||||
let enum_name = c[0..1].to_owned().to_uppercase() + &c[1..].to_owned().to_lowercase();
|
||||
|
||||
|
|
@ -271,9 +295,6 @@ pub enum Country {
|
|||
writeln!(code_countries, " /// {n}").unwrap();
|
||||
writeln!(code_countries, " {enum_name},").unwrap();
|
||||
|
||||
// Country array
|
||||
writeln!(code_country_array, " Country::{enum_name},").unwrap();
|
||||
|
||||
// Country names
|
||||
writeln!(
|
||||
code_country_names,
|
||||
|
|
@ -282,6 +303,16 @@ pub enum Country {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
// Country array
|
||||
let countries_by_name = countries
|
||||
.iter()
|
||||
.map(|(k, v)| (v, k))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
for c in countries_by_name.values() {
|
||||
let enum_name = c[0..1].to_owned().to_uppercase() + &c[1..].to_owned().to_lowercase();
|
||||
writeln!(code_country_array, " Country::{enum_name},").unwrap();
|
||||
}
|
||||
|
||||
// Add Country::Zz / Global
|
||||
code_countries += " /// Global (can only be used for music charts)\n";
|
||||
code_countries += " Zz,\n";
|
||||
|
|
|
|||
Reference in a new issue