Skip to content

Commit 5cfe294

Browse files
shiny-comicFijxu
andauthored
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 <[email protected]>
1 parent 0c13c4f commit 5cfe294

File tree

5 files changed

+2
-13
lines changed

5 files changed

+2
-13
lines changed

spec/invidious/videos/regular_videos_extract_spec.cr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Spectator.describe "parse_video_info" do
5252
expect(info["relatedVideos"][0]["title"]).to eq("$1 vs $250,000,000 Private Island!")
5353
expect(info["relatedVideos"][0]["author"]).to eq("MrBeast")
5454
expect(info["relatedVideos"][0]["ucid"]).to eq("UCX6OQ3DkcsbYNE6H8uQQuVA")
55-
expect(info["relatedVideos"][0]["view_count"]).to eq("230617484")
5655
expect(info["relatedVideos"][0]["short_view_count"]).to eq("230M")
5756
expect(info["relatedVideos"][0]["author_verified"]).to eq("true")
5857

@@ -138,7 +137,6 @@ Spectator.describe "parse_video_info" do
138137
expect(info["relatedVideos"][0]["title"]).to eq("Chris Rea - The Road To Hell 1989 Full Version")
139138
expect(info["relatedVideos"][0]["author"]).to eq("NEA ZIXNH")
140139
expect(info["relatedVideos"][0]["ucid"]).to eq("UCYMEOGcvav3gCgImK2J07CQ")
141-
expect(info["relatedVideos"][0]["view_count"]).to eq("53298661")
142140
expect(info["relatedVideos"][0]["short_view_count"]).to eq("53M")
143141
expect(info["relatedVideos"][0]["author_verified"]).to eq("false")
144142

spec/invidious/videos/scheduled_live_extract_spec.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Spectator.describe "parse_video_info" do
7575
expect(info["relatedVideos"][0]["id"]).to eq("j7jPzzjbVuk")
7676
expect(info["relatedVideos"][0]["author"]).to eq("Democracy Now!")
7777
expect(info["relatedVideos"][0]["ucid"]).to eq("UCzuqE7-t13O4NIDYJfakrhw")
78-
expect(info["relatedVideos"][0]["view_count"]).to eq("7576")
7978
expect(info["relatedVideos"][0]["short_view_count"]).to eq("7.5K")
8079
expect(info["relatedVideos"][0]["author_verified"]).to eq("true")
8180

src/invidious/jsonify/api_v1/video_json.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ module Invidious::JSONify::APIv1
266266

267267
json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i
268268
json.field "viewCountText", rv["short_view_count"]?
269-
json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64
270269
json.field "published", rv["published"]?
271270
if rv["published"]?.try &.presence
272271
json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.parse_rfc3339(rv["published"].to_s), locale))

src/invidious/videos/parser.cr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
2525

2626
ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) }
2727

28-
# "4,088,033 views", only available on compact renderer
29-
# and when video is not a livestream
30-
view_count = related.dig?("viewCountText", "simpleText")
31-
.try &.as_s.gsub(/\D/, "")
32-
3328
short_view_count = related.try do |r|
3429
HelperExtractors.get_short_view_count(r).to_s
3530
end
@@ -51,7 +46,6 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
5146
"author" => author || JSON::Any.new(""),
5247
"ucid" => JSON::Any.new(ucid || ""),
5348
"length_seconds" => JSON::Any.new(length || "0"),
54-
"view_count" => JSON::Any.new(view_count || "0"),
5549
"short_view_count" => JSON::Any.new(short_view_count || "0"),
5650
"author_verified" => JSON::Any.new(author_verified),
5751
"published" => JSON::Any.new(published || ""),

src/invidious/views/watch.ecr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,8 @@ we're going to need to do it here in order to allow for translations.
355355
356356
<div class="pure-u-10-24" style="text-align:right">
357357
<b class="width:100%"><%=
358-
views = rv["view_count"]?.try &.to_i?
359-
views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
360-
translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
358+
views = short_text_to_number(rv["short_view_count"]? || "0")
359+
translate_count(locale, "generic_views_count", views, NumberFormatting::Short)
361360
%></b>
362361
</div>
363362
</h5>

0 commit comments

Comments
 (0)