Add author_verified property to SearchVideo

This commit is contained in:
syeopite 2021-04-06 01:06:23 -07:00
parent 885120bd08
commit d3482831c8
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
3 changed files with 14 additions and 0 deletions

View File

@ -1302,6 +1302,7 @@ get "/feed/channel/:ucid" do |env|
title: title,
id: video_id,
author: author,
author_verified: false,
ucid: ucid,
published: published,
views: views,

View File

@ -265,6 +265,7 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
live_now = false
paid = false
premium = false
author_verified = false
premiere_timestamp = i["upcomingEventData"]?.try &.["startTime"]?.try { |t| Time.unix(t.as_s.to_i64) }
@ -284,10 +285,21 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
end
end
# Author Badges
i["ownerBadges"]?.try &.as_a.each do |badge|
b = badge["metadataBadgeRenderer"]
case b["style"].as_s
when "BADGE_STYLE_TYPE_VERIFIED"
author_verified = true
else nil
end
end
SearchVideo.new({
title: title,
id: video_id,
author: author,
author_verified: author_verified,
ucid: author_id,
published: published,
views: view_count,

View File

@ -4,6 +4,7 @@ struct SearchVideo
property title : String
property id : String
property author : String
property author_verified : Bool
property ucid : String
property published : Time
property views : Int64