Videos: Fix genre url being unusable (#4717)

Closes issue 4700
This commit is contained in:
Samantaz Fox 2024-07-21 17:15:46 +02:00
commit 7fdbda612f
No known key found for this signature in database
GPG key ID: F42821059186176E
4 changed files with 5 additions and 5 deletions

View file

@ -67,7 +67,7 @@ Spectator.describe "parse_video_info" do
# Video metadata # Video metadata
expect(info["genre"].as_s).to eq("Entertainment") expect(info["genre"].as_s).to eq("Entertainment")
expect(info["genreUcid"].as_s).to be_empty expect(info["genreUcid"].as_s?).to be_nil
expect(info["license"].as_s).to be_empty expect(info["license"].as_s).to be_empty
# Author infos # Author infos
@ -151,7 +151,7 @@ Spectator.describe "parse_video_info" do
# Video metadata # Video metadata
expect(info["genre"].as_s).to eq("Music") expect(info["genre"].as_s).to eq("Music")
expect(info["genreUcid"].as_s).to be_empty expect(info["genreUcid"].as_s?).to be_nil
expect(info["license"].as_s).to be_empty expect(info["license"].as_s).to be_empty
# Author infos # Author infos

View file

@ -94,7 +94,7 @@ Spectator.describe "parse_video_info" do
# Video metadata # Video metadata
expect(info["genre"].as_s).to eq("Entertainment") expect(info["genre"].as_s).to eq("Entertainment")
expect(info["genreUcid"].as_s).to be_empty expect(info["genreUcid"].as_s?).to be_nil
expect(info["license"].as_s).to be_empty expect(info["license"].as_s).to be_empty
# Author infos # Author infos

View file

@ -250,7 +250,7 @@ struct Video
end end
def genre_url : String? def genre_url : String?
info["genreUcid"]? ? "/channel/#{info["genreUcid"]}" : nil info["genreUcid"].try &.as_s? ? "/channel/#{info["genreUcid"]}" : nil
end end
def is_vr : Bool? def is_vr : Bool?

View file

@ -424,7 +424,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
"shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), "shortDescription" => JSON::Any.new(short_description.try &.as_s || nil),
# Video metadata # Video metadata
"genre" => JSON::Any.new(genre.try &.as_s || ""), "genre" => JSON::Any.new(genre.try &.as_s || ""),
"genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""), "genreUcid" => JSON::Any.new(genre_ucid.try &.as_s?),
"license" => JSON::Any.new(license.try &.as_s || ""), "license" => JSON::Any.new(license.try &.as_s || ""),
# Music section # Music section
"music" => JSON.parse(music_list.to_json), "music" => JSON.parse(music_list.to_json),