diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2023-03-20 19:15:12 +0100 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2023-03-20 19:15:12 +0100 |
| commit | 8a44bd11d2abab8c9203d6dc3c3d5824e5e26327 (patch) | |
| tree | 479ded7e79d205c818d50f1a76ef112b0239d99f /src | |
| parent | c0410602e780c7e4a08715ef5a8c835b8751cde4 (diff) | |
| parent | 4ae158ef6dcb89c2cd0eec646a42f11ebc207fba (diff) | |
| download | invidious-8a44bd11d2abab8c9203d6dc3c3d5824e5e26327.tar.gz invidious-8a44bd11d2abab8c9203d6dc3c3d5824e5e26327.tar.bz2 invidious-8a44bd11d2abab8c9203d6dc3c3d5824e5e26327.zip | |
Videos: Fix 0 views and empty license field (#3557)
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/videos/parser.cr | 10 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 6 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 7cfc7ea7..608ae99d 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -185,10 +185,12 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # We have to try to extract viewCount from videoPrimaryInfoRenderer first, # then from videoDetails, as the latter is "0" for livestreams (we want # to get the amount of viewers watching). - views_txt = video_primary_renderer - .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") - views_txt ||= video_details["viewCount"]? - views = views_txt.try &.as_s.gsub(/\D/, "").to_i64? + views_txt = extract_text( + video_primary_renderer + .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount") + ) + views_txt ||= video_details["viewCount"]?.try &.as_s || "" + views = views_txt.gsub(/\D/, "").to_i64? length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) .try &.as_s.to_i64 diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index ce92a546..a3ec94e8 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -181,7 +181,11 @@ we're going to need to do it here in order to allow for translations. <% end %> </p> <% if video.license %> - <p id="license"><%= translate(locale, "License: ") %><%= video.license %></p> + <% if video.license.empty? %> + <p id="license"><%= translate(locale, "License: ") %><%= translate(locale, "Standard YouTube license") %></p> + <% else %> + <p id="license"><%= translate(locale, "License: ") %><%= video.license %></p> + <% end %> <% end %> <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> |
