Add support for verified badges on comments

This commit is contained in:
syeopite 2021-04-07 02:16:20 -07:00
parent 814e8f14e2
commit 4f1cb26d96
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
4 changed files with 27 additions and 23 deletions

View File

@ -1302,7 +1302,7 @@ get "/feed/channel/:ucid" do |env|
title: title,
id: video_id,
author: author,
author_verified: false,
author_verified: false,
ucid: ucid,
published: published,
views: views,
@ -1550,7 +1550,7 @@ post "/feed/webhook/:token" do |env|
updated: updated,
ucid: video.ucid,
author: author,
author_verified: false,
author_verified: false,
length_seconds: video.length_seconds,
live_now: video.live_now,
premiere_timestamp: video.premiere_timestamp,

View File

@ -126,7 +126,7 @@ struct AboutChannel
property auto_generated : Bool
property author_url : String
property author_thumbnail : String
property author_verified : Bool
property author_verified : Bool
property banner : String?
property description_html : String
property paid : Bool
@ -276,7 +276,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
updated: Time.utc,
ucid: ucid,
author: author,
author_verified: false,
author_verified: false,
length_seconds: length_seconds,
live_now: live_now,
premiere_timestamp: premiere_timestamp,
@ -285,7 +285,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
# I don't understand enough about the database to do anything. Thus:
reduced_video_list = {video_id, title, published, Time.utc, ucid, author,
length_seconds, live_now, premiere_timestamp, views}
length_seconds, live_now, premiere_timestamp, views}
LOGGER.trace("fetch_channel: #{ucid} : video #{video_id} : Updating or inserting video")
@ -324,7 +324,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
updated: Time.utc,
ucid: video.ucid,
author: video.author,
author_verified: video.author_verified,
author_verified: video.author_verified,
length_seconds: video.length_seconds,
live_now: video.live_now,
premiere_timestamp: video.premiere_timestamp,
@ -925,7 +925,7 @@ def get_about_info(ucid, locale)
auto_generated: auto_generated,
author_url: author_url,
author_thumbnail: author_thumbnail,
author_verified: author_verified,
author_verified: author_verified,
banner: banner,
description_html: description_html,
paid: paid,

View File

@ -148,8 +148,10 @@ def fetch_youtube_comments(id, db, cursor, format, locale, thin_mode, region, so
content_html = node_comment["contentText"]?.try { |t| parse_content(t) } || ""
author = node_comment["authorText"]?.try &.["simpleText"]? || ""
author_verified = node_comment["authorCommentBadge"]?.try &.["authorCommentBadgeRenderer"]["iconTooltip"].to_s == "Verified" ? true : false || false
json.field "author", author
json.field "author_verified", author_verified
json.field "authorThumbnails" do
json.array do
node_comment["authorThumbnail"]["thumbnails"].as_a.each do |thumbnail|
@ -319,7 +321,9 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)
<p>
<b>
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{child["author"]}</a>
#{child["author_verified"]? == true ? "<a class=\"channel_badge\"><i class=\"icon ion-md-checkmark-circle\"></i></a>" : ""}
</b>
</p>
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
END_HTML

View File

@ -299,7 +299,7 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
title: title,
id: video_id,
author: author,
author_verified: author_verified,
author_verified: author_verified,
ucid: author_id,
published: published,
views: view_count,
@ -326,7 +326,7 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
SearchChannel.new({
author: author,
author_verified: author_verified,
author_verified: author_verified,
ucid: author_id,
author_thumbnail: author_thumbnail,
subscriber_count: subscriber_count,
@ -342,14 +342,14 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
playlist_thumbnail = i["thumbnail"]["thumbnails"][0]?.try &.["url"]?.try &.as_s || ""
SearchPlaylist.new({
title: title,
id: plid,
author: author_fallback || "",
title: title,
id: plid,
author: author_fallback || "",
author_verified: false,
ucid: author_id_fallback || "",
video_count: video_count,
videos: [] of SearchPlaylistVideo,
thumbnail: playlist_thumbnail,
ucid: author_id_fallback || "",
video_count: video_count,
videos: [] of SearchPlaylistVideo,
thumbnail: playlist_thumbnail,
})
elsif i = item["playlistRenderer"]?
title = i["title"]["simpleText"]?.try &.as_s || ""
@ -378,14 +378,14 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa
# TODO: i["publishedTimeText"]?
SearchPlaylist.new({
title: title,
id: plid,
author: author,
title: title,
id: plid,
author: author,
author_verified: author_verified,
ucid: author_id,
video_count: video_count,
videos: videos,
thumbnail: playlist_thumbnail,
ucid: author_id,
video_count: video_count,
videos: videos,
thumbnail: playlist_thumbnail,
})
elsif i = item["radioRenderer"]? # Mix
# TODO