Compare commits
No commits in common. "53bdd5f0d288fe58e3d1dc93be7b1dfc899aa11d" and "cc50862408e5ebcd4d0bd0b9b240ac0f8987c68c" have entirely different histories.
53bdd5f0d2
...
cc50862408
19 changed files with 27 additions and 70 deletions
|
@ -25,9 +25,9 @@ impl RustyPipeQuery {
|
||||||
.http_request_txt(self.client.inner.http.get(&url).build()?)
|
.http_request_txt(self.client.inner.http.get(&url).build()?)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| match e {
|
.map_err(|e| match e {
|
||||||
Error::HttpStatus(404, _) => Error::Extraction(
|
Error::HttpStatus(404) => Error::Extraction(ExtractionError::ContentUnavailable(
|
||||||
ExtractionError::ContentUnavailable("Channel not found".into()),
|
"Channel not found".into(),
|
||||||
),
|
)),
|
||||||
_ => e,
|
_ => e,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
@ -538,7 +538,7 @@ impl RustyPipe {
|
||||||
let status = res.status();
|
let status = res.status();
|
||||||
|
|
||||||
if status.is_client_error() || status.is_server_error() {
|
if status.is_client_error() || status.is_server_error() {
|
||||||
Err(Error::HttpStatus(status.into(), "none".into()))
|
Err(Error::HttpStatus(status.into()))
|
||||||
} else {
|
} else {
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
@ -1086,18 +1086,26 @@ impl RustyPipeQuery {
|
||||||
};
|
};
|
||||||
|
|
||||||
if status.is_client_error() || status.is_server_error() {
|
if status.is_client_error() || status.is_server_error() {
|
||||||
let error_msg = serde_json::from_str::<response::ErrorResponse>(&resp_str)
|
let status_code = status.as_u16();
|
||||||
.map(|r| r.error.message)
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
return match status {
|
return match status {
|
||||||
StatusCode::NOT_FOUND => Err(Error::Extraction(
|
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(
|
StatusCode::BAD_REQUEST => {
|
||||||
error_msg.into(),
|
let error_res = serde_json::from_str::<response::ErrorResponse>(&resp_str);
|
||||||
))),
|
Err(Error::Extraction(ExtractionError::BadRequest(
|
||||||
_ => Err(Error::HttpStatus(status.as_u16(), error_msg.into())),
|
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)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ fn map_artist_page(
|
||||||
lang: crate::param::Language,
|
lang: crate::param::Language,
|
||||||
skip_extendables: bool,
|
skip_extendables: bool,
|
||||||
) -> Result<MapResult<(MusicArtist, Vec<String>)>, ExtractionError> {
|
) -> Result<MapResult<(MusicArtist, Vec<String>)>, ExtractionError> {
|
||||||
// dbg!(&res);
|
// dbg!(&self);
|
||||||
|
|
||||||
let header = res.header.music_immersive_header_renderer;
|
let header = res.header.music_immersive_header_renderer;
|
||||||
|
|
||||||
|
@ -272,13 +272,6 @@ fn map_artist_page(
|
||||||
.map(|m| m.as_str().to_owned())
|
.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 {
|
Ok(MapResult {
|
||||||
c: (
|
c: (
|
||||||
MusicArtist {
|
MusicArtist {
|
||||||
|
@ -299,7 +292,6 @@ fn map_artist_page(
|
||||||
similar_artists: mapped.c.artists,
|
similar_artists: mapped.c.artists,
|
||||||
tracks_playlist_id,
|
tracks_playlist_id,
|
||||||
videos_playlist_id,
|
videos_playlist_id,
|
||||||
radio_id,
|
|
||||||
},
|
},
|
||||||
album_page_params,
|
album_page_params,
|
||||||
),
|
),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::serializer::text::Text;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
music_item::{
|
music_item::{
|
||||||
Button, Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
|
Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
|
||||||
},
|
},
|
||||||
SectionList, Tab,
|
SectionList, Tab,
|
||||||
};
|
};
|
||||||
|
@ -41,9 +41,6 @@ pub(crate) struct MusicHeaderRenderer {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[serde_as(as = "DefaultOnError")]
|
#[serde_as(as = "DefaultOnError")]
|
||||||
pub share_endpoint: Option<ShareEndpoint>,
|
pub share_endpoint: Option<ShareEndpoint>,
|
||||||
#[serde(default)]
|
|
||||||
#[serde_as(as = "DefaultOnError")]
|
|
||||||
pub start_radio_button: Option<Button>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
|
@ -320,14 +320,14 @@ pub(crate) struct MusicCarouselShelfHeader {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub(crate) struct MusicCarouselShelfHeaderRenderer {
|
pub(crate) struct MusicCarouselShelfHeaderRenderer {
|
||||||
pub more_content_button: Option<Button>,
|
pub more_content_button: Option<MoreContentButton>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub title: TextComponents,
|
pub title: TextComponents,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub(crate) struct Button {
|
pub(crate) struct MoreContentButton {
|
||||||
pub button_renderer: ButtonRenderer,
|
pub button_renderer: ButtonRenderer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3649,5 +3649,4 @@ MusicArtist(
|
||||||
],
|
],
|
||||||
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
||||||
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
||||||
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -152,5 +152,4 @@ MusicArtist(
|
||||||
similar_artists: [],
|
similar_artists: [],
|
||||||
tracks_playlist_id: None,
|
tracks_playlist_id: None,
|
||||||
videos_playlist_id: None,
|
videos_playlist_id: None,
|
||||||
radio_id: None,
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1387,5 +1387,4 @@ MusicArtist(
|
||||||
],
|
],
|
||||||
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
||||||
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
||||||
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -966,5 +966,4 @@ MusicArtist(
|
||||||
],
|
],
|
||||||
tracks_playlist_id: Some("OLAK5uy_m6843aeUO05cz_t1seql2dQ9eUgwyuOXI"),
|
tracks_playlist_id: Some("OLAK5uy_m6843aeUO05cz_t1seql2dQ9eUgwyuOXI"),
|
||||||
videos_playlist_id: None,
|
videos_playlist_id: None,
|
||||||
radio_id: Some("RDEMd8PZIv9CPsvvEDbo_pUD4w"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1885,5 +1885,4 @@ MusicArtist(
|
||||||
],
|
],
|
||||||
tracks_playlist_id: Some("OLAK5uy_nGjQIyWU6PsJZdJst7WOJHVZ7N7DupP04"),
|
tracks_playlist_id: Some("OLAK5uy_nGjQIyWU6PsJZdJst7WOJHVZ7N7DupP04"),
|
||||||
videos_playlist_id: Some("OLAK5uy_mulXOv4f1FNKi1-0zgY3YouLDTXX2wLu4"),
|
videos_playlist_id: Some("OLAK5uy_mulXOv4f1FNKi1-0zgY3YouLDTXX2wLu4"),
|
||||||
radio_id: Some("RDEMzMxPuaGyofN40xcgHuZAbw"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -626,5 +626,4 @@ MusicArtist(
|
||||||
],
|
],
|
||||||
tracks_playlist_id: None,
|
tracks_playlist_id: None,
|
||||||
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
||||||
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,8 +19,8 @@ pub enum Error {
|
||||||
#[error("http error: {0}")]
|
#[error("http error: {0}")]
|
||||||
Http(#[from] reqwest::Error),
|
Http(#[from] reqwest::Error),
|
||||||
/// Erroneous HTTP status code received
|
/// Erroneous HTTP status code received
|
||||||
#[error("http status code: {0} message: {1}")]
|
#[error("http status code: {0}")]
|
||||||
HttpStatus(u16, Cow<'static, str>),
|
HttpStatus(u16),
|
||||||
/// Unspecified error
|
/// Unspecified error
|
||||||
#[error("error: {0}")]
|
#[error("error: {0}")]
|
||||||
Other(Cow<'static, str>),
|
Other(Cow<'static, str>),
|
||||||
|
|
|
@ -1111,8 +1111,6 @@ pub struct MusicArtist {
|
||||||
pub tracks_playlist_id: Option<String>,
|
pub tracks_playlist_id: Option<String>,
|
||||||
/// ID of the playlist containging the artist's videos
|
/// ID of the playlist containging the artist's videos
|
||||||
pub videos_playlist_id: Option<String>,
|
pub videos_playlist_id: Option<String>,
|
||||||
/// ID of the artist radio
|
|
||||||
pub radio_id: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// YouTube Music search result
|
/// YouTube Music search result
|
||||||
|
|
|
@ -316,5 +316,4 @@ MusicArtist(
|
||||||
similar_artists: "[artists]",
|
similar_artists: "[artists]",
|
||||||
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
||||||
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
||||||
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -661,5 +661,4 @@ MusicArtist(
|
||||||
similar_artists: "[artists]",
|
similar_artists: "[artists]",
|
||||||
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
||||||
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
||||||
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,5 +15,4 @@ MusicArtist(
|
||||||
similar_artists: "[artists]",
|
similar_artists: "[artists]",
|
||||||
tracks_playlist_id: None,
|
tracks_playlist_id: None,
|
||||||
videos_playlist_id: None,
|
videos_playlist_id: None,
|
||||||
radio_id: None,
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -151,5 +151,4 @@ MusicArtist(
|
||||||
similar_artists: "[artists]",
|
similar_artists: "[artists]",
|
||||||
tracks_playlist_id: Some("OLAK5uy_miHesZCUQY5S9EwqfoNP2tZR9nZ0NBAeU"),
|
tracks_playlist_id: Some("OLAK5uy_miHesZCUQY5S9EwqfoNP2tZR9nZ0NBAeU"),
|
||||||
videos_playlist_id: Some("OLAK5uy_mqbgE6T9uvusUWrAxJGiImf4_P4dM7IvQ"),
|
videos_playlist_id: Some("OLAK5uy_mqbgE6T9uvusUWrAxJGiImf4_P4dM7IvQ"),
|
||||||
radio_id: Some("RDEM7AbogW0cCnElSU0WYm1GqA"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,5 +31,4 @@ MusicArtist(
|
||||||
similar_artists: "[artists]",
|
similar_artists: "[artists]",
|
||||||
tracks_playlist_id: None,
|
tracks_playlist_id: None,
|
||||||
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
||||||
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -2031,34 +2031,7 @@ async fn music_radio_playlist_not_found() {
|
||||||
.music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ")
|
.music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ")
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Err(err) = res {
|
// Currently this returns valid data
|
||||||
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;
|
|
||||||
|
|
||||||
if let Err(err) = res {
|
if let Err(err) = res {
|
||||||
assert!(
|
assert!(
|
||||||
matches!(
|
matches!(
|
||||||
|
|
Loading…
Reference in a new issue