Video: Fix 0 views, and empty license field

pull/3557/head
techmetx11 2 years ago committed by Samantaz Fox
parent b287ff2126
commit 8eca5b270e
No known key found for this signature in database
GPG Key ID: F42821059186176E

@ -183,6 +183,7 @@
"Show annotations": "Show annotations", "Show annotations": "Show annotations",
"Genre: ": "Genre: ", "Genre: ": "Genre: ",
"License: ": "License: ", "License: ": "License: ",
"Standard YouTube license": "Standard YouTube license",
"Family friendly? ": "Family friendly? ", "Family friendly? ": "Family friendly? ",
"Wilson score: ": "Wilson score: ", "Wilson score: ": "Wilson score: ",
"Engagement: ": "Engagement: ", "Engagement: ": "Engagement: ",

@ -186,7 +186,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
# then from videoDetails, as the latter is "0" for livestreams (we want # then from videoDetails, as the latter is "0" for livestreams (we want
# to get the amount of viewers watching). # to get the amount of viewers watching).
views_txt = video_primary_renderer views_txt = video_primary_renderer
.try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "simpleText")
views_txt ||= video_details["viewCount"]? views_txt ||= video_details["viewCount"]?
views = views_txt.try &.as_s.gsub(/\D/, "").to_i64? views = views_txt.try &.as_s.gsub(/\D/, "").to_i64?

@ -181,8 +181,12 @@ we're going to need to do it here in order to allow for translations.
<% end %> <% end %>
</p> </p>
<% if video.license %> <% if video.license %>
<% if video.license == "" %>
<p id="license"><%= translate(locale, "License: ") %><%= translate(locale, "Standard YouTube license") %></p>
<% else %>
<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p> <p id="license"><%= translate(locale, "License: ") %><%= video.license %></p>
<% end %> <% end %>
<% end %>
<p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p> <p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
<p id="wilson" style="display: none; visibility: hidden;"></p> <p id="wilson" style="display: none; visibility: hidden;"></p>
<p id="rating" style="display: none; visibility: hidden;"></p> <p id="rating" style="display: none; visibility: hidden;"></p>

Loading…
Cancel
Save