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, tab: ChannelVideoTab,
order: ChannelOrder, order: ChannelOrder,
) -> Result<Paginator<VideoItem>, Error> { ) -> Result<Paginator<VideoItem>, Error> {
let visitor_data = match tab { let visitor_data = Some(self.get_visitor_data().await?);
ChannelVideoTab::Shorts => Some(self.get_visitor_data().await?),
_ => None,
};
self.continuation( self.continuation(
order_ctoken(channel_id.as_ref(), tab, order), order_ctoken(channel_id.as_ref(), tab, order),

View file

@ -1563,9 +1563,14 @@ mod tests {
fn t_get_visitor_data() { fn t_get_visitor_data() {
let rp = RustyPipe::new(); let rp = RustyPipe::new();
let visitor_data = tokio_test::block_on(rp.get_visitor_data()).unwrap(); 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!( assert!(
visitor_data.ends_with("%3D") && visitor_data.len() == 32, visitor_data.starts_with("Cg")
"got: {visitor_data}" && visitor_data.len() > 23
); && &visitor_data[22..23] == "-",
"invalid visitor data: {visitor_data}"
)
} }
} }

View file

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

View file

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

View file

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

View file

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