mirror of
https://github.com/iv-org/invidious.git
synced 2025-10-21 08:18:31 -05:00
Fix 0 view count on related videos section (#5446)
* Fix 0 view count on related videos * Remove view_count variable since it's unused by Innertube * Remove view_count from specs and API --------- Co-authored-by: Fijxu <fijxu@nadeko.net>
This commit is contained in:
parent
0c13c4fab1
commit
5cfe294063
@ -52,7 +52,6 @@ Spectator.describe "parse_video_info" do
|
||||
expect(info["relatedVideos"][0]["title"]).to eq("$1 vs $250,000,000 Private Island!")
|
||||
expect(info["relatedVideos"][0]["author"]).to eq("MrBeast")
|
||||
expect(info["relatedVideos"][0]["ucid"]).to eq("UCX6OQ3DkcsbYNE6H8uQQuVA")
|
||||
expect(info["relatedVideos"][0]["view_count"]).to eq("230617484")
|
||||
expect(info["relatedVideos"][0]["short_view_count"]).to eq("230M")
|
||||
expect(info["relatedVideos"][0]["author_verified"]).to eq("true")
|
||||
|
||||
@ -138,7 +137,6 @@ Spectator.describe "parse_video_info" do
|
||||
expect(info["relatedVideos"][0]["title"]).to eq("Chris Rea - The Road To Hell 1989 Full Version")
|
||||
expect(info["relatedVideos"][0]["author"]).to eq("NEA ZIXNH")
|
||||
expect(info["relatedVideos"][0]["ucid"]).to eq("UCYMEOGcvav3gCgImK2J07CQ")
|
||||
expect(info["relatedVideos"][0]["view_count"]).to eq("53298661")
|
||||
expect(info["relatedVideos"][0]["short_view_count"]).to eq("53M")
|
||||
expect(info["relatedVideos"][0]["author_verified"]).to eq("false")
|
||||
|
||||
|
@ -75,7 +75,6 @@ Spectator.describe "parse_video_info" do
|
||||
expect(info["relatedVideos"][0]["id"]).to eq("j7jPzzjbVuk")
|
||||
expect(info["relatedVideos"][0]["author"]).to eq("Democracy Now!")
|
||||
expect(info["relatedVideos"][0]["ucid"]).to eq("UCzuqE7-t13O4NIDYJfakrhw")
|
||||
expect(info["relatedVideos"][0]["view_count"]).to eq("7576")
|
||||
expect(info["relatedVideos"][0]["short_view_count"]).to eq("7.5K")
|
||||
expect(info["relatedVideos"][0]["author_verified"]).to eq("true")
|
||||
|
||||
|
@ -266,7 +266,6 @@ module Invidious::JSONify::APIv1
|
||||
|
||||
json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i
|
||||
json.field "viewCountText", rv["short_view_count"]?
|
||||
json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64
|
||||
json.field "published", rv["published"]?
|
||||
if rv["published"]?.try &.presence
|
||||
json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.parse_rfc3339(rv["published"].to_s), locale))
|
||||
|
@ -25,11 +25,6 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
|
||||
|
||||
ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) }
|
||||
|
||||
# "4,088,033 views", only available on compact renderer
|
||||
# and when video is not a livestream
|
||||
view_count = related.dig?("viewCountText", "simpleText")
|
||||
.try &.as_s.gsub(/\D/, "")
|
||||
|
||||
short_view_count = related.try do |r|
|
||||
HelperExtractors.get_short_view_count(r).to_s
|
||||
end
|
||||
@ -51,7 +46,6 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
|
||||
"author" => author || JSON::Any.new(""),
|
||||
"ucid" => JSON::Any.new(ucid || ""),
|
||||
"length_seconds" => JSON::Any.new(length || "0"),
|
||||
"view_count" => JSON::Any.new(view_count || "0"),
|
||||
"short_view_count" => JSON::Any.new(short_view_count || "0"),
|
||||
"author_verified" => JSON::Any.new(author_verified),
|
||||
"published" => JSON::Any.new(published || ""),
|
||||
|
@ -355,9 +355,8 @@ we're going to need to do it here in order to allow for translations.
|
||||
|
||||
<div class="pure-u-10-24" style="text-align:right">
|
||||
<b class="width:100%"><%=
|
||||
views = rv["view_count"]?.try &.to_i?
|
||||
views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
|
||||
translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
|
||||
views = short_text_to_number(rv["short_view_count"]? || "0")
|
||||
translate_count(locale, "generic_views_count", views, NumberFormatting::Short)
|
||||
%></b>
|
||||
</div>
|
||||
</h5>
|
||||
|
Loading…
x
Reference in New Issue
Block a user