From 9d385e8e9b69f63661790963f9c03ca1aa44d342 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sun, 30 Jul 2023 17:00:47 +0200 Subject: [PATCH 1/3] fix: player from android client --- src/client/player.rs | 5 +++++ tests/snapshots/youtube__music_artist_only_singles.snap | 2 +- tests/youtube.rs | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/player.rs b/src/client/player.rs index 9f74ef9..f5bd905 100644 --- a/src/client/player.rs +++ b/src/client/player.rs @@ -40,6 +40,8 @@ struct QPlayer<'a> { content_check_ok: bool, /// Probably refers to allowing sensitive content, too racy_check_ok: bool, + #[serde(skip_serializing_if = "Option::is_none")] + params: Option<&'a str>, } #[derive(Debug, Serialize)] @@ -113,6 +115,7 @@ impl RustyPipeQuery { video_id, content_check_ok: true, racy_check_ok: true, + params: None, } } else { QPlayer { @@ -122,6 +125,8 @@ impl RustyPipeQuery { video_id, content_check_ok: true, racy_check_ok: true, + // Source: https://github.com/TeamNewPipe/NewPipeExtractor/pull/1084 + params: Some("CgIQBg").filter(|_| client_type == ClientType::Android), } }; diff --git a/tests/snapshots/youtube__music_artist_only_singles.snap b/tests/snapshots/youtube__music_artist_only_singles.snap index 9258bcb..9e673ba 100644 --- a/tests/snapshots/youtube__music_artist_only_singles.snap +++ b/tests/snapshots/youtube__music_artist_only_singles.snap @@ -6,7 +6,7 @@ MusicArtist( id: "UCfwCE5VhPMGxNPFxtVv7lRw", name: "Sulli", header_image: "[header_image]", - description: Some("Choi Jin-ri, better known by her stage name Sulli, was a South Korean actress and singer. She first made her debut as a child actress, appearing as a supporting cast member on the SBS historical drama Ballad of Seodong. Following this, she earned a number of guest roles, appearing in the television series Love Needs a Miracle and Drama City, and the film Vacation. She then subsequently appeared in the independent films Punch Lady and BA:BO, the former being her first time cast in a substantial dramatic role.\nAfter signing a record deal with SM Entertainment, Sulli rose to prominence as a member of the girl group f(x) formed in 2009. The group achieved both critical and commercial success, with four Korean number-one singles and international recognition after becoming the first K-pop act to perform at SXSW. Concurrently with her music career, Sulli returned to acting by starring in the SBS romantic comedy series, To the Beautiful You, a Korean adaptation of the shōjo manga Hana-Kimi where her performance was positively received and earned her two SBS Drama Awards and a nomination at the 49th Paeksang Arts Awards.\n\nFrom Wikipedia (https://en.wikipedia.org/wiki/Sulli) under Creative Commons Attribution CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/legalcode)"), + description: Some("Choi Jin-ri, better known by her stage name Sulli, was a South Korean singer and actress. She first made her debut as a child actress, appearing as a supporting cast member on the SBS historical drama Ballad of Seodong. Following this, she earned a number of guest roles, appearing in the television series Love Needs a Miracle and Drama City, and the film Vacation. She then subsequently appeared in the independent films Punch Lady and BA:BO, the former being her first time cast in a substantial dramatic role.\nAfter signing a record deal with SM Entertainment, Sulli rose to prominence as a member of the girl group f(x) formed in 2009. The group achieved both critical and commercial success, with four Korean number-one singles and international recognition after becoming the first K-pop act to perform at SXSW. Concurrently with her music career, Sulli returned to acting by starring in the SBS romantic comedy series, To the Beautiful You, a Korean adaptation of the shōjo manga Hana-Kimi where her performance was positively received and earned her two SBS Drama Awards and a nomination at the 49th Paeksang Arts Awards.\n\nFrom Wikipedia (https://en.wikipedia.org/wiki/Sulli) under Creative Commons Attribution CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/legalcode)"), wikipedia_url: Some("https://en.wikipedia.org/wiki/Sulli"), subscriber_count: "[subscriber_count]", tracks: "[tracks]", diff --git a/tests/youtube.rs b/tests/youtube.rs index f3c5c96..e3c9027 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -28,8 +28,7 @@ use rustypipe::param::{ #[rstest] #[case::desktop(ClientType::Desktop)] #[case::tv_html5_embed(ClientType::TvHtml5Embed)] -// The Android client became flaky -// #[case::android(ClientType::Android)] +#[case::android(ClientType::Android)] #[case::ios(ClientType::Ios)] #[test_log::test] fn get_player_from_client(#[case] client_type: ClientType, rp: RustyPipe) { From 687ddec50d2a1cad217b6fbaa8a78625b1e60682 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sun, 30 Jul 2023 17:02:03 +0200 Subject: [PATCH 2/3] fix: make error enums exhaustive --- src/error.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index 471568c..0b29cc0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,7 +6,6 @@ use reqwest::StatusCode; /// Error type for the RustyPipe library #[derive(thiserror::Error, Debug)] -#[non_exhaustive] pub enum Error { /// Error extracting content from YouTube #[error("extraction error: {0}")] @@ -24,7 +23,6 @@ pub enum Error { /// Error extracting content from YouTube #[derive(thiserror::Error, Debug)] -#[non_exhaustive] pub enum ExtractionError { /// Video cannot be extracted with RustyPipe /// From ca2335d03f5f656dcb9c2f0ad783b7813fc89cfe Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sun, 30 Jul 2023 18:02:06 +0200 Subject: [PATCH 3/3] fix: parsing playlist channel (more than 1 text component led to an error) --- src/serializer/text.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/serializer/text.rs b/src/serializer/text.rs index e1c6ae9..f8d070d 100644 --- a/src/serializer/text.rs +++ b/src/serializer/text.rs @@ -201,13 +201,6 @@ impl<'de> Deserialize<'de> for TextComponent { D: Deserializer<'de>, { let mut text = RichTextInternal::deserialize(deserializer)?; - if text.runs.len() != 1 { - return Err(serde::de::Error::invalid_length( - text.runs.len(), - &"1 run, use TextComponents for more", - )); - } - Ok(text.runs.swap_remove(0).into()) } }