Invidious is an alternative front-end to YouTube
Remove all backend code related to dislikes
Samantaz Foxeb226e1dcf4c
diff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex 1504e390..3204c98d 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -323,7 +323,7 @@ struct Videojson.field "viewCount", self.viewsjson.field "likeCount", self.likes- json.field "dislikeCount", self.dislikes+ json.field "dislikeCount", 0_i64json.field "paid", self.paidjson.field "premium", self.premium@@ -354,7 +354,7 @@ struct Videojson.field "lengthSeconds", self.length_secondsjson.field "allowRatings", self.allow_ratings- json.field "rating", self.average_rating+ json.field "rating", 0_i64json.field "isListed", self.is_listedjson.field "liveNow", self.live_nowjson.field "isUpcoming", self.is_upcoming@@ -556,11 +556,6 @@ struct Videoinfo["dislikes"]?.try &.as_i64 || 0_i64end- def average_rating : Float64- # (likes / (likes + dislikes) * 4 + 1)- info["videoDetails"]["averageRating"]?.try { |t| t.as_f? || t.as_i64?.try &.to_f64 }.try &.round(4) || 0.0- end-def published : Timeinfo.dig?("microformat", "playerMicroformatRenderer", "publishDate")@@ -813,14 +808,6 @@ struct Videoreturn info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_send- def wilson_score : Float64- ci_lower_bound(likes, likes + dislikes).round(4)- end-- def engagement : Float64- (((likes + dislikes) / views) * 100).round(4)- end-def reason : String?info["reason"]?.try &.as_send@@ -1005,7 +992,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_params["relatedVideos"] = JSON::Any.new(related)- # Likes/dislikes+ # Likestoplevel_buttons = video_primary_renderer.try &.dig?("videoActions", "menuRenderer", "topLevelButtons")@@ -1023,30 +1010,10 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_LOGGER.trace("extract_video_info: Found \"likes\" button. Button text is \"#{likes_txt}\"")LOGGER.debug("extract_video_info: Likes count is #{likes}") if likesend-- dislikes_button = toplevel_buttons.as_a- .find(&.dig("toggleButtonRenderer", "defaultIcon", "iconType").as_s.== "DISLIKE")- .try &.["toggleButtonRenderer"]-- if dislikes_button- dislikes_txt = (dislikes_button["defaultText"]? || dislikes_button["toggledText"]?)- .try &.dig?("accessibility", "accessibilityData", "label")- dislikes = dislikes_txt.as_s.gsub(/\D/, "").to_i64? if dislikes_txt-- LOGGER.trace("extract_video_info: Found \"dislikes\" button. Button text is \"#{dislikes_txt}\"")- LOGGER.debug("extract_video_info: Dislikes count is #{dislikes}") if dislikes- end- end-- if likes && likes != 0_i64 && (!dislikes || dislikes == 0_i64)- if rating = player_response.dig?("videoDetails", "averageRating").try { |x| x.as_i64? || x.as_f? }- dislikes = (likes * ((5 - rating)/(rating - 1))).round.to_i64- LOGGER.debug("extract_video_info: Dislikes count (using fallback method) is #{dislikes}")- endendparams["likes"] = JSON::Any.new(likes || 0_i64)- params["dislikes"] = JSON::Any.new(dislikes || 0_i64)+ params["dislikes"] = JSON::Any.new(0_i64)# Descriptiondiff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecrindex d1fdcce2..50c63d21 100644--- a/src/invidious/views/watch.ecr+++ b/src/invidious/views/watch.ecr@@ -173,7 +173,7 @@ we're going to need to do it here in order to allow for translations.<p id="views"><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p><p id="likes"><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>- <p id="dislikes"></p>+ <p id="dislikes" style="display: none; visibility: hidden;"></p><p id="genre"><%= translate(locale, "Genre: ") %><% if !video.genre_url %><%= video.genre %>@@ -185,9 +185,9 @@ we're going to need to do it here in order to allow for translations.<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p><% end %><p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>- <p id="wilson"><%= translate(locale, "Wilson score: ") %><%= video.wilson_score %></p>- <p id="rating"></p>- <p id="engagement"><%= translate(locale, "Engagement: ") %><%= video.engagement %>%</p>+ <p id="wilson" style="display: none; visibility: hidden;"></p>+ <p id="rating" style="display: none; visibility: hidden;"></p>+ <p id="engagement" style="display: none; visibility: hidden;"></p><% if video.allowed_regions.size != REGIONS.size %><p id="allowed_regions"><% if video.allowed_regions.size < REGIONS.size // 2 %>