refactor: update recommended video response model
This commit is contained in:
parent
999ebf7c36
commit
71c77fcfb6
19 changed files with 1100 additions and 863 deletions
|
|
@ -19,7 +19,6 @@ pub use trends::Trending;
|
|||
pub use url_endpoint::ResolvedUrl;
|
||||
pub use video_details::VideoComments;
|
||||
pub use video_details::VideoDetails;
|
||||
pub use video_details::VideoRecommendations;
|
||||
pub use video_item::YouTubeListItem;
|
||||
pub use video_item::YouTubeListMapper;
|
||||
|
||||
|
|
@ -497,9 +496,12 @@ pub struct Continuation {
|
|||
/// Number of search results
|
||||
#[serde_as(as = "Option<JsonString>")]
|
||||
pub estimated_results: Option<u64>,
|
||||
#[serde(alias = "onResponseReceivedCommands")]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub on_response_received_actions: Vec<ContinuationActionWrap>,
|
||||
#[serde(
|
||||
alias = "onResponseReceivedCommands",
|
||||
alias = "onResponseReceivedEndpoints"
|
||||
)]
|
||||
#[serde_as(as = "Option<VecSkipError<_>>")]
|
||||
pub on_response_received_actions: Option<Vec<ContinuationActionWrap>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ use crate::serializer::{
|
|||
MapResult, VecLogError,
|
||||
};
|
||||
|
||||
use super::YouTubeListItem;
|
||||
use super::{
|
||||
url_endpoint::BrowseEndpoint, ContinuationEndpoint, ContinuationItemRenderer, Icon,
|
||||
MusicContinuation, Thumbnails, VideoListItem, VideoOwner,
|
||||
MusicContinuation, Thumbnails, VideoOwner,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -282,7 +283,7 @@ pub struct RecommendationResultsWrap {
|
|||
pub struct RecommendationResults {
|
||||
/// Can be `None` for age-restricted videos
|
||||
#[serde_as(as = "Option<VecLogError<_>>")]
|
||||
pub results: Option<MapResult<Vec<VideoListItem>>>,
|
||||
pub results: Option<MapResult<Vec<YouTubeListItem>>>,
|
||||
#[serde_as(as = "Option<VecSkipError<_>>")]
|
||||
pub continuations: Option<Vec<MusicContinuation>>,
|
||||
}
|
||||
|
|
@ -416,36 +417,6 @@ pub struct CommentItemSectionHeaderMenuItem {
|
|||
pub service_endpoint: ContinuationEndpoint,
|
||||
}
|
||||
|
||||
/*
|
||||
#RECOMMENDATIONS CONTINUATION
|
||||
*/
|
||||
|
||||
/// Video recommendations continuation response
|
||||
#[serde_as]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct VideoRecommendations {
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "VecSkipError<_>")]
|
||||
pub on_response_received_endpoints: Vec<RecommendationsContItem>,
|
||||
}
|
||||
|
||||
/// Video recommendations continuation
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RecommendationsContItem {
|
||||
pub append_continuation_items_action: AppendRecommendations,
|
||||
}
|
||||
|
||||
/// Video recommendations continuation
|
||||
#[serde_as]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppendRecommendations {
|
||||
#[serde_as(as = "VecLogError<_>")]
|
||||
pub continuation_items: MapResult<Vec<VideoListItem>>,
|
||||
}
|
||||
|
||||
/*
|
||||
#COMMENTS CONTINUATION
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ pub struct VideoRenderer {
|
|||
pub title: String,
|
||||
#[serde(rename = "shortBylineText")]
|
||||
pub channel: Option<TextComponent>,
|
||||
pub channel_thumbnail: Option<Thumbnails>,
|
||||
pub channel_thumbnail_supported_renderers: Option<ChannelThumbnailSupportedRenderers>,
|
||||
#[serde_as(as = "Option<Text>")]
|
||||
pub published_time_text: Option<String>,
|
||||
|
|
@ -221,8 +222,10 @@ impl<T> YouTubeListMapper<T> {
|
|||
name: c.name,
|
||||
avatar: video
|
||||
.channel_thumbnail_supported_renderers
|
||||
.map(|tn| tn.channel_thumbnail_with_link_renderer.thumbnail.into())
|
||||
.unwrap_or_default(),
|
||||
.map(|tn| tn.channel_thumbnail_with_link_renderer.thumbnail)
|
||||
.or(video.channel_thumbnail)
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
verification: video.owner_badges.into(),
|
||||
subscriber_count: None,
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue