Compare commits

..

No commits in common. "53bdd5f0d288fe58e3d1dc93be7b1dfc899aa11d" and "cc50862408e5ebcd4d0bd0b9b240ac0f8987c68c" have entirely different histories.

19 changed files with 27 additions and 70 deletions

View file

@ -25,9 +25,9 @@ impl RustyPipeQuery {
.http_request_txt(self.client.inner.http.get(&url).build()?)
.await
.map_err(|e| match e {
Error::HttpStatus(404, _) => Error::Extraction(
ExtractionError::ContentUnavailable("Channel not found".into()),
),
Error::HttpStatus(404) => Error::Extraction(ExtractionError::ContentUnavailable(
"Channel not found".into(),
)),
_ => e,
})?;

View file

@ -538,7 +538,7 @@ impl RustyPipe {
let status = res.status();
if status.is_client_error() || status.is_server_error() {
Err(Error::HttpStatus(status.into(), "none".into()))
Err(Error::HttpStatus(status.into()))
} else {
Ok(res)
}
@ -1086,18 +1086,26 @@ impl RustyPipeQuery {
};
if status.is_client_error() || status.is_server_error() {
let error_msg = serde_json::from_str::<response::ErrorResponse>(&resp_str)
.map(|r| r.error.message)
.unwrap_or_default();
let status_code = status.as_u16();
return match status {
StatusCode::NOT_FOUND => Err(Error::Extraction(
ExtractionError::ContentUnavailable(error_msg.into()),
ExtractionError::ContentUnavailable("404 Not found".into()),
)),
StatusCode::BAD_REQUEST => Err(Error::Extraction(ExtractionError::BadRequest(
error_msg.into(),
))),
_ => Err(Error::HttpStatus(status.as_u16(), error_msg.into())),
StatusCode::BAD_REQUEST => {
let error_res = serde_json::from_str::<response::ErrorResponse>(&resp_str);
Err(Error::Extraction(ExtractionError::BadRequest(
error_res
.map(|r| r.error.message)
.unwrap_or_default()
.into(),
)))
}
_ => {
let e = Error::HttpStatus(status_code);
create_report(Level::ERR, Some(e.to_string()), vec![]);
Err(e)
}
};
}

View file

@ -166,7 +166,7 @@ fn map_artist_page(
lang: crate::param::Language,
skip_extendables: bool,
) -> Result<MapResult<(MusicArtist, Vec<String>)>, ExtractionError> {
// dbg!(&res);
// dbg!(&self);
let header = res.header.music_immersive_header_renderer;
@ -272,13 +272,6 @@ fn map_artist_page(
.map(|m| m.as_str().to_owned())
});
let radio_id = header.start_radio_button.and_then(|b| {
b.button_renderer
.navigation_endpoint
.watch_endpoint
.and_then(|w| w.playlist_id)
});
Ok(MapResult {
c: (
MusicArtist {
@ -299,7 +292,6 @@ fn map_artist_page(
similar_artists: mapped.c.artists,
tracks_playlist_id,
videos_playlist_id,
radio_id,
},
album_page_params,
),

View file

@ -5,7 +5,7 @@ use crate::serializer::text::Text;
use super::{
music_item::{
Button, Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
},
SectionList, Tab,
};
@ -41,9 +41,6 @@ pub(crate) struct MusicHeaderRenderer {
#[serde(default)]
#[serde_as(as = "DefaultOnError")]
pub share_endpoint: Option<ShareEndpoint>,
#[serde(default)]
#[serde_as(as = "DefaultOnError")]
pub start_radio_button: Option<Button>,
}
#[derive(Debug, Deserialize)]

View file

@ -320,14 +320,14 @@ pub(crate) struct MusicCarouselShelfHeader {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct MusicCarouselShelfHeaderRenderer {
pub more_content_button: Option<Button>,
pub more_content_button: Option<MoreContentButton>,
#[serde(default)]
pub title: TextComponents,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Button {
pub(crate) struct MoreContentButton {
pub button_renderer: ButtonRenderer,
}

View file

@ -3649,5 +3649,4 @@ MusicArtist(
],
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
)

View file

@ -152,5 +152,4 @@ MusicArtist(
similar_artists: [],
tracks_playlist_id: None,
videos_playlist_id: None,
radio_id: None,
)

View file

@ -1387,5 +1387,4 @@ MusicArtist(
],
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
)

View file

@ -966,5 +966,4 @@ MusicArtist(
],
tracks_playlist_id: Some("OLAK5uy_m6843aeUO05cz_t1seql2dQ9eUgwyuOXI"),
videos_playlist_id: None,
radio_id: Some("RDEMd8PZIv9CPsvvEDbo_pUD4w"),
)

View file

@ -1885,5 +1885,4 @@ MusicArtist(
],
tracks_playlist_id: Some("OLAK5uy_nGjQIyWU6PsJZdJst7WOJHVZ7N7DupP04"),
videos_playlist_id: Some("OLAK5uy_mulXOv4f1FNKi1-0zgY3YouLDTXX2wLu4"),
radio_id: Some("RDEMzMxPuaGyofN40xcgHuZAbw"),
)

View file

@ -626,5 +626,4 @@ MusicArtist(
],
tracks_playlist_id: None,
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
)

View file

@ -19,8 +19,8 @@ pub enum Error {
#[error("http error: {0}")]
Http(#[from] reqwest::Error),
/// Erroneous HTTP status code received
#[error("http status code: {0} message: {1}")]
HttpStatus(u16, Cow<'static, str>),
#[error("http status code: {0}")]
HttpStatus(u16),
/// Unspecified error
#[error("error: {0}")]
Other(Cow<'static, str>),

View file

@ -1111,8 +1111,6 @@ pub struct MusicArtist {
pub tracks_playlist_id: Option<String>,
/// ID of the playlist containging the artist's videos
pub videos_playlist_id: Option<String>,
/// ID of the artist radio
pub radio_id: Option<String>,
}
/// YouTube Music search result

View file

@ -316,5 +316,4 @@ MusicArtist(
similar_artists: "[artists]",
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
)

View file

@ -661,5 +661,4 @@ MusicArtist(
similar_artists: "[artists]",
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
)

View file

@ -15,5 +15,4 @@ MusicArtist(
similar_artists: "[artists]",
tracks_playlist_id: None,
videos_playlist_id: None,
radio_id: None,
)

View file

@ -151,5 +151,4 @@ MusicArtist(
similar_artists: "[artists]",
tracks_playlist_id: Some("OLAK5uy_miHesZCUQY5S9EwqfoNP2tZR9nZ0NBAeU"),
videos_playlist_id: Some("OLAK5uy_mqbgE6T9uvusUWrAxJGiImf4_P4dM7IvQ"),
radio_id: Some("RDEM7AbogW0cCnElSU0WYm1GqA"),
)

View file

@ -31,5 +31,4 @@ MusicArtist(
similar_artists: "[artists]",
tracks_playlist_id: None,
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
)

View file

@ -2031,34 +2031,7 @@ async fn music_radio_playlist_not_found() {
.music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ")
.await;
if let Err(err) = res {
assert!(
matches!(
err,
Error::Extraction(ExtractionError::ContentUnavailable(_))
),
"got: {}",
err
);
}
}
#[tokio::test]
async fn music_radio_artist() {
let rp = RustyPipe::builder().strict().build();
let tracks = rp
.query()
.music_radio("RDEM_Ktu-TilkxtLvmc9wX1MLQ")
.await
.unwrap();
assert_next_items(tracks, rp.query(), 20).await;
}
#[tokio::test]
async fn music_radio_not_found() {
let rp = RustyPipe::builder().strict().build();
let res = rp.query().music_radio("RDEM_Ktu-TilkxtLvmc9wXZZZZ").await;
// Currently this returns valid data
if let Err(err) = res {
assert!(
matches!(