fix: video with no view count
This commit is contained in:
parent
f526470b6a
commit
0cbeb0524d
2 changed files with 9 additions and 3 deletions
|
|
@ -77,7 +77,7 @@ pub(crate) enum VideoResultsItem {
|
|||
VideoPrimaryInfoRenderer {
|
||||
#[serde_as(as = "Text")]
|
||||
title: String,
|
||||
view_count: ViewCount,
|
||||
view_count: Option<ViewCount>,
|
||||
/// Like/Dislike button
|
||||
video_actions: VideoActions,
|
||||
/// Absolute textual date (e.g. `Dec 29, 2019`)
|
||||
|
|
|
|||
|
|
@ -166,14 +166,20 @@ impl MapResponse<VideoDetails> for response::VideoDetails {
|
|||
(
|
||||
title,
|
||||
// view count field contains `No views` if the view count is zero
|
||||
util::parse_numeric(&view_count.video_view_count_renderer.view_count)
|
||||
view_count
|
||||
.as_ref()
|
||||
.and_then(|vc| {
|
||||
util::parse_numeric(&vc.video_view_count_renderer.view_count).ok()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
// accessibility_data contains no digits if the like count is hidden,
|
||||
// so we ignore parse errors here for now
|
||||
like_btn.and_then(|btn| util::parse_numeric(&btn.accessibility_data).ok()),
|
||||
timeago::parse_textual_date_or_warn(lang, &date_text, &mut warnings),
|
||||
date_text,
|
||||
view_count.video_view_count_renderer.is_live,
|
||||
view_count
|
||||
.map(|vc| vc.video_view_count_renderer.is_live)
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
Reference in a new issue