Fix templating for videos with 0 comments
This commit is contained in:
parent
0c8a1d46bd
commit
b9e2fee2c9
@ -2041,26 +2041,7 @@ get "/api/v1/comments/:id" do |env|
|
|||||||
halt env, status_code: 500, response: error_message
|
halt env, status_code: 500, response: error_message
|
||||||
end
|
end
|
||||||
|
|
||||||
if format == "json"
|
next comments
|
||||||
next comments
|
|
||||||
else
|
|
||||||
comments = JSON.parse(comments)
|
|
||||||
content_html = template_youtube_comments(comments)
|
|
||||||
|
|
||||||
response = JSON.build do |json|
|
|
||||||
json.object do
|
|
||||||
json.field "contentHtml", content_html
|
|
||||||
|
|
||||||
if comments["commentCount"]?
|
|
||||||
json.field "commentCount", comments["commentCount"]
|
|
||||||
else
|
|
||||||
json.field "commentCount", 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
next response
|
|
||||||
end
|
|
||||||
elsif source == "reddit"
|
elsif source == "reddit"
|
||||||
begin
|
begin
|
||||||
comments, reddit_thread = fetch_reddit_comments(id)
|
comments, reddit_thread = fetch_reddit_comments(id)
|
||||||
|
@ -264,6 +264,23 @@ def fetch_youtube_comments(id, continuation, proxies, format)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if format == "html"
|
||||||
|
comments = JSON.parse(comments)
|
||||||
|
content_html = template_youtube_comments(comments)
|
||||||
|
|
||||||
|
comments = JSON.build do |json|
|
||||||
|
json.object do
|
||||||
|
json.field "contentHtml", content_html
|
||||||
|
|
||||||
|
if comments["commentCount"]?
|
||||||
|
json.field "commentCount", comments["commentCount"]
|
||||||
|
else
|
||||||
|
json.field "commentCount", 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return comments
|
return comments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user