feat: add artist radio
This commit is contained in:
parent
fe76b2ac66
commit
53bdd5f0d2
16 changed files with 56 additions and 5 deletions
|
|
@ -166,7 +166,7 @@ fn map_artist_page(
|
|||
lang: crate::param::Language,
|
||||
skip_extendables: bool,
|
||||
) -> Result<MapResult<(MusicArtist, Vec<String>)>, ExtractionError> {
|
||||
// dbg!(&self);
|
||||
// dbg!(&res);
|
||||
|
||||
let header = res.header.music_immersive_header_renderer;
|
||||
|
||||
|
|
@ -272,6 +272,13 @@ 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 {
|
||||
|
|
@ -292,6 +299,7 @@ fn map_artist_page(
|
|||
similar_artists: mapped.c.artists,
|
||||
tracks_playlist_id,
|
||||
videos_playlist_id,
|
||||
radio_id,
|
||||
},
|
||||
album_page_params,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::serializer::text::Text;
|
|||
|
||||
use super::{
|
||||
music_item::{
|
||||
Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
|
||||
Button, Grid, ItemSection, MusicThumbnailRenderer, SimpleHeader, SingleColumnBrowseResult,
|
||||
},
|
||||
SectionList, Tab,
|
||||
};
|
||||
|
|
@ -41,6 +41,9 @@ 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)]
|
||||
|
|
|
|||
|
|
@ -320,14 +320,14 @@ pub(crate) struct MusicCarouselShelfHeader {
|
|||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct MusicCarouselShelfHeaderRenderer {
|
||||
pub more_content_button: Option<MoreContentButton>,
|
||||
pub more_content_button: Option<Button>,
|
||||
#[serde(default)]
|
||||
pub title: TextComponents,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct MoreContentButton {
|
||||
pub(crate) struct Button {
|
||||
pub button_renderer: ButtonRenderer,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3649,4 +3649,5 @@ MusicArtist(
|
|||
],
|
||||
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
||||
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
||||
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -152,4 +152,5 @@ MusicArtist(
|
|||
similar_artists: [],
|
||||
tracks_playlist_id: None,
|
||||
videos_playlist_id: None,
|
||||
radio_id: None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1387,4 +1387,5 @@ MusicArtist(
|
|||
],
|
||||
tracks_playlist_id: Some("OLAK5uy_mHzt_lZ0Vdnv3NAqvCLQw5CiYe0q96iBs"),
|
||||
videos_playlist_id: Some("OLAK5uy_k9FAxC8Xb8T0KqP5wFbn8KsP3VkUjb334"),
|
||||
radio_id: Some("RDEM_Ktu-TilkxtLvmc9wX1MLQ"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -966,4 +966,5 @@ MusicArtist(
|
|||
],
|
||||
tracks_playlist_id: Some("OLAK5uy_m6843aeUO05cz_t1seql2dQ9eUgwyuOXI"),
|
||||
videos_playlist_id: None,
|
||||
radio_id: Some("RDEMd8PZIv9CPsvvEDbo_pUD4w"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1885,4 +1885,5 @@ MusicArtist(
|
|||
],
|
||||
tracks_playlist_id: Some("OLAK5uy_nGjQIyWU6PsJZdJst7WOJHVZ7N7DupP04"),
|
||||
videos_playlist_id: Some("OLAK5uy_mulXOv4f1FNKi1-0zgY3YouLDTXX2wLu4"),
|
||||
radio_id: Some("RDEMzMxPuaGyofN40xcgHuZAbw"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -626,4 +626,5 @@ MusicArtist(
|
|||
],
|
||||
tracks_playlist_id: None,
|
||||
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
||||
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1111,6 +1111,8 @@ 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
|
||||
|
|
|
|||
|
|
@ -316,4 +316,5 @@ MusicArtist(
|
|||
similar_artists: "[artists]",
|
||||
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
||||
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
||||
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -661,4 +661,5 @@ MusicArtist(
|
|||
similar_artists: "[artists]",
|
||||
tracks_playlist_id: Some("OLAK5uy_n6aX-F_lCQxgyTIv4FJhp78bXV93b9NUM"),
|
||||
videos_playlist_id: Some("OLAK5uy_nrePwvOEzmO7SydszEFfCDu8gAJxKfFtw"),
|
||||
radio_id: Some("RDEMdgjzN3Qrk_GD7BooQbkJ4A"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@ MusicArtist(
|
|||
similar_artists: "[artists]",
|
||||
tracks_playlist_id: None,
|
||||
videos_playlist_id: None,
|
||||
radio_id: None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -151,4 +151,5 @@ MusicArtist(
|
|||
similar_artists: "[artists]",
|
||||
tracks_playlist_id: Some("OLAK5uy_miHesZCUQY5S9EwqfoNP2tZR9nZ0NBAeU"),
|
||||
videos_playlist_id: Some("OLAK5uy_mqbgE6T9uvusUWrAxJGiImf4_P4dM7IvQ"),
|
||||
radio_id: Some("RDEM7AbogW0cCnElSU0WYm1GqA"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,4 +31,5 @@ MusicArtist(
|
|||
similar_artists: "[artists]",
|
||||
tracks_playlist_id: None,
|
||||
videos_playlist_id: Some("OLAK5uy_lmH3iVq6lqjsnLkBWzpvRTh0DidLzbU-I"),
|
||||
radio_id: Some("RDEMYsk_DTFHAng1G7n5toi_oA"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2031,7 +2031,34 @@ async fn music_radio_playlist_not_found() {
|
|||
.music_radio_playlist("PL5dDx681T4bR7ZF1IuWzOv1omlZZZZZZZ")
|
||||
.await;
|
||||
|
||||
// Currently this returns valid data
|
||||
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;
|
||||
|
||||
if let Err(err) = res {
|
||||
assert!(
|
||||
matches!(
|
||||
|
|
|
|||
Reference in a new issue