diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 65f4b135..402857ce 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -553,12 +553,12 @@ def fill_links(html, scheme, host)
return html.to_xml(options: XML::SaveOptions::NO_DECL)
end
-def parse_content(content : JSON::Any) : String
+def parse_content(content : JSON::Any, clip_urls : Bool = true) : String
content["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
- content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s.gsub("\n", "
") } || ""
+ content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r, clip_urls).try &.to_s.gsub("\n", "
") } || ""
end
-def content_to_comment_html(content)
+def content_to_comment_html(content : Array(JSON::Any), clip_urls : Bool = true)
comment_html = content.map do |run|
text = HTML.escape(run["text"].as_s)
@@ -586,7 +586,11 @@ def content_to_comment_html(content)
end
end
- text = %(#{text})
+ if clip_urls
+ text = %(#{text})
+ else
+ text = %(#{url})
+ end
elsif watch_endpoint = run["navigationEndpoint"]["watchEndpoint"]?
length_seconds = watch_endpoint["startTimeSeconds"]?
video_id = watch_endpoint["videoId"].as_s
@@ -597,7 +601,11 @@ def content_to_comment_html(content)
text = %(#{text})
end
elsif url = run.dig?("navigationEndpoint", "commandMetadata", "webCommandMetadata", "url").try &.as_s
- text = %(#{text})
+ if clip_urls
+ text = %(#{text})
+ else
+ text = %(#{url})
+ end
end
end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 81fce5b8..8f3203ae 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -871,7 +871,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
}
end
-def extract_video_info(video_id : String, proxy_region : String? = nil, context_screen : String? = nil)
+def extract_video_info(video_id : String, proxy_region : String? = nil, context_screen : String? = nil, clip_urls : Bool? = true)
params = {} of String => JSON::Any
client_config = YoutubeAPI::ClientConfig.new(proxy_region: proxy_region)
@@ -1024,7 +1024,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Description
description_html = video_secondary_renderer.try &.dig?("description", "runs")
- .try &.as_a.try { |t| content_to_comment_html(t) }
+ .try &.as_a.try { |t| content_to_comment_html(t, clip_urls) }
params["descriptionHtml"] = JSON::Any.new(description_html || "