chore: A/B test 5
This commit is contained in:
parent
20ecea65ef
commit
fa4c845c2f
5 changed files with 94 additions and 53365 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use futures::{stream, StreamExt};
|
use futures::{stream, StreamExt};
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
|
|
@ -5,6 +7,7 @@ use num_enum::TryFromPrimitive;
|
||||||
use rustypipe::client::{ClientType, RustyPipe, YTContext};
|
use rustypipe::client::{ClientType, RustyPipe, YTContext};
|
||||||
use rustypipe::model::YouTubeItem;
|
use rustypipe::model::YouTubeItem;
|
||||||
use rustypipe::param::search_filter::{ItemType, SearchFilter};
|
use rustypipe::param::search_filter::{ItemType, SearchFilter};
|
||||||
|
use serde::de::IgnoredAny;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
@ -16,6 +19,7 @@ pub enum ABTest {
|
||||||
ThreeTabChannelLayout = 2,
|
ThreeTabChannelLayout = 2,
|
||||||
ChannelHandlesInSearchResults = 3,
|
ChannelHandlesInSearchResults = 3,
|
||||||
TrendsVideoTab = 4,
|
TrendsVideoTab = 4,
|
||||||
|
TrendsPageHeaderRenderer = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
const TESTS_TO_RUN: [ABTest; 1] = [ABTest::TrendsVideoTab];
|
const TESTS_TO_RUN: [ABTest; 1] = [ABTest::TrendsVideoTab];
|
||||||
|
|
@ -82,6 +86,9 @@ pub async fn run_test(
|
||||||
channel_handles_in_search_results(&rp, &visitor_data).await
|
channel_handles_in_search_results(&rp, &visitor_data).await
|
||||||
}
|
}
|
||||||
ABTest::TrendsVideoTab => trends_video_tab(&rp, &visitor_data).await,
|
ABTest::TrendsVideoTab => trends_video_tab(&rp, &visitor_data).await,
|
||||||
|
ABTest::TrendsPageHeaderRenderer => {
|
||||||
|
trends_page_header_renderer(&rp, &visitor_data).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.unwrap();
|
.unwrap();
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
|
|
@ -200,3 +207,28 @@ pub async fn trends_video_tab(rp: &RustyPipe, visitor_data: &str) -> Result<bool
|
||||||
|
|
||||||
Ok(res.contains("\"4gIOGgxtb3N0X3BvcHVsYXI%3D\""))
|
Ok(res.contains("\"4gIOGgxtb3N0X3BvcHVsYXI%3D\""))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn trends_page_header_renderer(rp: &RustyPipe, visitor_data: &str) -> Result<bool> {
|
||||||
|
let query = rp.query().visitor_data(visitor_data);
|
||||||
|
let context = query.get_context(ClientType::Desktop, true, None).await;
|
||||||
|
let res = query
|
||||||
|
.raw(
|
||||||
|
ClientType::Desktop,
|
||||||
|
"browse",
|
||||||
|
&QBrowse {
|
||||||
|
context,
|
||||||
|
browse_id: "FEtrending",
|
||||||
|
params: None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct D {
|
||||||
|
header: BTreeMap<String, IgnoredAny>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = serde_json::from_str::<D>(&res)?;
|
||||||
|
|
||||||
|
Ok(data.header.contains_key("pageHeaderRenderer"))
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -290,3 +290,58 @@ The data model for the video shelves did not change.
|
||||||
**NEW**
|
**NEW**
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## [5] Page header renderer on the Trending page
|
||||||
|
|
||||||
|
- **Encountered on:** 1.05.2023
|
||||||
|
- **Impact:** 🟢 Low
|
||||||
|
- **Endpoint:** browse (trending videos)
|
||||||
|
|
||||||
|
YouTube changed the header renderer type on the trending page to a `pageHeaderRenderer`.
|
||||||
|
|
||||||
|
**OLD**
|
||||||
|
|
||||||
|
```json
|
||||||
|
"c4TabbedHeaderRenderer": {
|
||||||
|
"avatar": {
|
||||||
|
"thumbnails": [
|
||||||
|
{
|
||||||
|
"height": 100,
|
||||||
|
"url": "https://www.youtube.com/img/trending/avatar/trending_avatar.png",
|
||||||
|
"width": 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "Trending",
|
||||||
|
"trackingParams": "CBAQ8DsiEwiXi_iUht76AhVM6hEIHfgTB2g="
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**NEW**
|
||||||
|
|
||||||
|
```json
|
||||||
|
"pageHeaderRenderer": {
|
||||||
|
"pageTitle": "Trending",
|
||||||
|
"content": {
|
||||||
|
"pageHeaderViewModel": {
|
||||||
|
"title": {
|
||||||
|
"dynamicTextViewModel": { "text": { "content": "Trending" } }
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"contentPreviewImageViewModel": {
|
||||||
|
"image": {
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"url": "https://www.youtube.com/img/trending/avatar/trending.png",
|
||||||
|
"width": 100,
|
||||||
|
"height": 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"style": "CONTENT_PREVIEW_IMAGE_STYLE_CIRCLE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -124,6 +124,7 @@ mod tests {
|
||||||
use std::{fs::File, io::BufReader};
|
use std::{fs::File, io::BufReader};
|
||||||
|
|
||||||
use path_macro::path;
|
use path_macro::path;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::{response, MapResponse},
|
client::{response, MapResponse},
|
||||||
|
|
@ -154,9 +155,11 @@ mod tests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[rstest]
|
||||||
fn map_trending() {
|
#[case::base("videos")]
|
||||||
let json_path = path!(*TESTFILES / "trends" / "trending.json");
|
#[case::page_header_renderer("20230501_page_header_renderer")]
|
||||||
|
fn map_trending(#[case] name: &str) {
|
||||||
|
let json_path = path!(*TESTFILES / "trends" / format!("trending_{name}.json"));
|
||||||
let json_file = File::open(json_path).unwrap();
|
let json_file = File::open(json_path).unwrap();
|
||||||
|
|
||||||
let startpage: response::Trending =
|
let startpage: response::Trending =
|
||||||
|
|
@ -170,7 +173,7 @@ mod tests {
|
||||||
map_res.warnings
|
map_res.warnings
|
||||||
);
|
);
|
||||||
|
|
||||||
insta::assert_ron_snapshot!("map_trending", map_res.c, {
|
insta::assert_ron_snapshot!(format!("map_trending_{name}"), map_res.c, {
|
||||||
"[].publish_date" => "[date]",
|
"[].publish_date" => "[date]",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Reference in a new issue