fix: use visitor data for ordered channel videos

tests: fix tests
This commit is contained in:
ThetaDev 2023-08-15 22:37:55 +02:00
parent dff95d1272
commit 6cf59a167a
6 changed files with 47 additions and 38 deletions

View file

@ -117,10 +117,7 @@ impl RustyPipeQuery {
tab: ChannelVideoTab,
order: ChannelOrder,
) -> Result<Paginator<VideoItem>, Error> {
let visitor_data = match tab {
ChannelVideoTab::Shorts => Some(self.get_visitor_data().await?),
_ => None,
};
let visitor_data = Some(self.get_visitor_data().await?);
self.continuation(
order_ctoken(channel_id.as_ref(), tab, order),

View file

@ -1563,9 +1563,14 @@ mod tests {
fn t_get_visitor_data() {
let rp = RustyPipe::new();
let visitor_data = tokio_test::block_on(rp.get_visitor_data()).unwrap();
// First part of visitor data must be 22 characters
// Example: CgthVjBVUDJrd2Q3dyi3te-mBg%3D%3D
assert!(
visitor_data.ends_with("%3D") && visitor_data.len() == 32,
"got: {visitor_data}"
);
visitor_data.starts_with("Cg")
&& visitor_data.len() > 23
&& &visitor_data[22..23] == "-",
"invalid visitor data: {visitor_data}"
)
}
}

View file

@ -22,7 +22,7 @@ MusicAlbum(
TrackItem(
id: "g0iRiJ_ck48",
name: "[name]",
duration: Some(216),
duration: Some(217),
cover: [],
artists: [
ArtistId(
@ -43,7 +43,7 @@ MusicAlbum(
TrackItem(
id: "rREEBXp0y9s",
name: "[name]",
duration: Some(224),
duration: Some(225),
cover: [],
artists: [
ArtistId(
@ -64,7 +64,7 @@ MusicAlbum(
TrackItem(
id: "zvU5Y8Q19hU",
name: "[name]",
duration: Some(176),
duration: Some(177),
cover: [],
artists: [
ArtistId(
@ -85,7 +85,7 @@ MusicAlbum(
TrackItem(
id: "ARKLrzzTQA0",
name: "[name]",
duration: Some(215),
duration: Some(216),
cover: [],
artists: [
ArtistId(
@ -106,7 +106,7 @@ MusicAlbum(
TrackItem(
id: "tstLgN8A_Ng",
name: "[name]",
duration: Some(268),
duration: Some(269),
cover: [],
artists: [
ArtistId(
@ -127,7 +127,7 @@ MusicAlbum(
TrackItem(
id: "k2DjgQOY3Ts",
name: "[name]",
duration: Some(202),
duration: Some(203),
cover: [],
artists: [
ArtistId(
@ -148,7 +148,7 @@ MusicAlbum(
TrackItem(
id: "azHwhecxEsI",
name: "[name]",
duration: Some(185),
duration: Some(186),
cover: [],
artists: [
ArtistId(
@ -169,7 +169,7 @@ MusicAlbum(
TrackItem(
id: "_FcsdYIQ2co",
name: "[name]",
duration: Some(226),
duration: Some(227),
cover: [],
artists: [
ArtistId(
@ -190,7 +190,7 @@ MusicAlbum(
TrackItem(
id: "27bOWEbshyE",
name: "[name]",
duration: Some(207),
duration: Some(208),
cover: [],
artists: [
ArtistId(
@ -211,7 +211,7 @@ MusicAlbum(
TrackItem(
id: "riD_3oZwt8w",
name: "[name]",
duration: Some(211),
duration: Some(212),
cover: [],
artists: [
ArtistId(
@ -232,7 +232,7 @@ MusicAlbum(
TrackItem(
id: "8GNvjF3no9s",
name: "[name]",
duration: Some(179),
duration: Some(180),
cover: [],
artists: [
ArtistId(
@ -253,7 +253,7 @@ MusicAlbum(
TrackItem(
id: "YHMFzf1uN2U",
name: "[name]",
duration: Some(218),
duration: Some(219),
cover: [],
artists: [
ArtistId(
@ -274,7 +274,7 @@ MusicAlbum(
TrackItem(
id: "jvV-z5F3oAo",
name: "[name]",
duration: Some(277),
duration: Some(278),
cover: [],
artists: [
ArtistId(
@ -295,7 +295,7 @@ MusicAlbum(
TrackItem(
id: "u8_9cxlrh8k",
name: "[name]",
duration: Some(204),
duration: Some(205),
cover: [],
artists: [
ArtistId(
@ -316,7 +316,7 @@ MusicAlbum(
TrackItem(
id: "gSvKcvM1Wk0",
name: "[name]",
duration: Some(202),
duration: Some(203),
cover: [],
artists: [
ArtistId(
@ -337,7 +337,7 @@ MusicAlbum(
TrackItem(
id: "wQHgKRJ0pDQ",
name: "[name]",
duration: Some(222),
duration: Some(223),
cover: [],
artists: [
ArtistId(
@ -358,7 +358,7 @@ MusicAlbum(
TrackItem(
id: "Ckz5i6-hzf0",
name: "[name]",
duration: Some(177),
duration: Some(178),
cover: [],
artists: [
ArtistId(
@ -379,7 +379,7 @@ MusicAlbum(
TrackItem(
id: "y5zuUgyFqrc",
name: "[name]",
duration: Some(220),
duration: Some(221),
cover: [],
artists: [
ArtistId(

View file

@ -126,11 +126,11 @@ MusicAlbum(
cover: [],
artists: [
ArtistId(
id: None,
id: Some("UChm_d4qO8txdwS4YadlvpSw"),
name: "Brave Girls",
),
],
artist_id: None,
artist_id: Some("UChm_d4qO8txdwS4YadlvpSw"),
album: Some(AlbumId(
id: "MPREb_8QkDeEIawvX",
name: "Queendom2 FINAL",

View file

@ -1,5 +1,6 @@
---
source: tests/youtube.rs
assertion_line: 1396
expression: album
---
MusicAlbum(
@ -126,11 +127,11 @@ MusicAlbum(
cover: [],
artists: [
ArtistId(
id: None,
id: Some("UChm_d4qO8txdwS4YadlvpSw"),
name: "[name]",
),
],
artist_id: None,
artist_id: Some("UChm_d4qO8txdwS4YadlvpSw"),
album: Some(AlbumId(
id: "MPREb_8QkDeEIawvX",
name: "[name]",

View file

@ -978,15 +978,10 @@ fn channel_more(
}
#[rstest]
#[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos, "XqZsoesa55w")]
#[case::shorts("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Shorts, "k91vRvXGwHs")]
#[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live, "ojes5ULOqhc")]
fn channel_order(
#[case] id: &str,
#[case] tab: ChannelVideoTab,
#[case] most_popular: &str,
rp: RustyPipe,
) {
#[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos)]
#[case::shorts("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Shorts)]
#[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live)]
fn channel_order_latest(#[case] id: &str, #[case] tab: ChannelVideoTab, rp: RustyPipe) {
let latest = tokio_test::block_on(rp.query().channel_videos_tab_order(
id,
tab,
@ -1007,7 +1002,18 @@ fn channel_order(
}
}
assert_next(latest, rp.query(), 15, 1);
}
#[rstest]
#[case::videos("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Videos, "XqZsoesa55w")]
#[case::shorts("UCcdwLMPsaU2ezNSJU1nFoBQ", ChannelVideoTab::Shorts, "k91vRvXGwHs")]
#[case::live("UCvqRdlKsE5Q8mf8YXbdIJLw", ChannelVideoTab::Live, "ojes5ULOqhc")]
fn channel_order_popular(
#[case] id: &str,
#[case] tab: ChannelVideoTab,
#[case] most_popular: &str,
rp: RustyPipe,
) {
let popular = tokio_test::block_on(rp.query().channel_videos_tab_order(
id,
tab,