|
|
@ -560,30 +560,21 @@ def parse_content(content : JSON::Any, video_id : String? = "") : String
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def content_to_comment_html(content, video_id : String? = "")
|
|
|
|
def content_to_comment_html(content, video_id : String? = "")
|
|
|
|
comment_html = content.map do |run|
|
|
|
|
html_array = content.map do |run|
|
|
|
|
text = HTML.escape(run["text"].as_s)
|
|
|
|
text = HTML.escape(run["text"].as_s)
|
|
|
|
|
|
|
|
|
|
|
|
if run["bold"]?
|
|
|
|
|
|
|
|
text = "<b>#{text}</b>"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if run["italics"]?
|
|
|
|
|
|
|
|
text = "<i>#{text}</i>"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if run["navigationEndpoint"]?
|
|
|
|
if run["navigationEndpoint"]?
|
|
|
|
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
|
|
|
|
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
|
|
|
|
url = URI.parse(url)
|
|
|
|
url = URI.parse(url)
|
|
|
|
displayed_url = url
|
|
|
|
displayed_url = text
|
|
|
|
|
|
|
|
|
|
|
|
if url.host == "youtu.be"
|
|
|
|
if url.host == "youtu.be"
|
|
|
|
url = "/watch?v=#{url.request_target.lstrip('/')}"
|
|
|
|
url = "/watch?v=#{url.request_target.lstrip('/')}"
|
|
|
|
displayed_url = "youtube.com#{url}"
|
|
|
|
|
|
|
|
elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
|
|
|
|
elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
|
|
|
|
if url.path == "/redirect"
|
|
|
|
if url.path == "/redirect"
|
|
|
|
# Sometimes, links can be corrupted (why?) so make sure to fallback
|
|
|
|
# Sometimes, links can be corrupted (why?) so make sure to fallback
|
|
|
|
# nicely. See https://github.com/iv-org/invidious/issues/2682
|
|
|
|
# nicely. See https://github.com/iv-org/invidious/issues/2682
|
|
|
|
url = HTTP::Params.parse(url.query.not_nil!)["q"]? || ""
|
|
|
|
url = url.query_params["q"]? || ""
|
|
|
|
displayed_url = url
|
|
|
|
displayed_url = url
|
|
|
|
else
|
|
|
|
else
|
|
|
|
url = url.request_target
|
|
|
|
url = url.request_target
|
|
|
@ -623,10 +614,13 @@ def content_to_comment_html(content, video_id : String? = "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = "<b>#{text}</b>" if run["bold"]?
|
|
|
|
|
|
|
|
text = "<i>#{text}</i>" if run["italics"]?
|
|
|
|
|
|
|
|
|
|
|
|
text
|
|
|
|
text
|
|
|
|
end.join("").delete('\ufeff')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return comment_html
|
|
|
|
return html_array.join("").delete('\ufeff')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def produce_comment_continuation(video_id, cursor = "", sort_by = "top")
|
|
|
|
def produce_comment_continuation(video_id, cursor = "", sort_by = "top")
|
|
|
|