Add mock and test for video without videoDetails

- New mock: no-videodetails.player.json (player response without videoDetails)
- Test verifies fallback extraction from videoPrimaryInfoRenderer,
  videoSecondaryInfoRenderer, and videoOwnerRenderer when
  videoDetails is missing from the player response
This commit is contained in:
Emilien 2026-06-26 17:58:11 +02:00
parent c3f16be5c4
commit c5eb4cee9d
2 changed files with 42 additions and 1 deletions

2
mocks

@ -1 +1 @@
Subproject commit b55d58dea94f7144ff0205857dfa70ec14eaa872
Subproject commit 562192243e0348bd53bb85a5bf6d404109b21da0

View File

@ -163,4 +163,45 @@ Spectator.describe "parse_video_info" do
expect(info["authorVerified"].as_bool).to be_false
expect(info["subCountText"].as_s).to eq("3.11K")
end
it "parses a video without videoDetails (fallback to /next data)" do
_player = load_mock("video/no-videodetails.player")
_next = load_mock("video/regular_no-description.next")
raw_data = _player.merge!(_next)
info = Invidious::Videos::Parser.parse_video_info("no-videodetails-id", raw_data)
expect(typeof(info)).to eq(Hash(String, JSON::Any))
# Title falls back to videoPrimaryInfoRenderer
expect(info["title"].as_s).to eq("Chris Rea - Auberge")
# Views from videoPrimaryInfoRenderer
expect(info["views"].as_i).to eq(14_324_584)
# Likes still work (from videoPrimaryInfoRenderer buttons)
expect(info["likes"].as_i).to eq(35_870)
# Length from microformat
expect(info["lengthSeconds"].as_i).to eq(283_i64)
# Published from microformat, or dateText fallback
expect(info["published"].as_s).to eq("2012-05-21T00:00:00Z")
# Author from videoOwnerRenderer
expect(info["author"].as_s).to eq("ChrisReaVideos")
expect(info["ucid"].as_s).to eq("UC_5q6nWPbD30-y6oiWF_oNA")
# Family friendly defaults to true when missing
expect(info["isFamilyFriendly"].as_bool).to be_true
# isListed defaults to true when no badges
expect(info["isListed"].as_bool).to be_true
# Description
expect(info["descriptionHtml"].as_s).to eq("")
# Related videos still work from /next
expect(info["relatedVideos"].as_a.size).to eq(20)
end
end