Videos: Fix empty response when rv published field is nonexistent (#5162)

Fixes #5161 by checking recommended videos published field for presence
before attempting to parse it in api
This commit is contained in:
syeopite 2025-02-26 14:09:28 -08:00
commit 6ac74f4362
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -268,7 +268,7 @@ module Invidious::JSONify::APIv1
json.field "viewCountText", rv["short_view_count"]? json.field "viewCountText", rv["short_view_count"]?
json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64 json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64
json.field "published", rv["published"]? json.field "published", rv["published"]?
if !rv["published"]?.nil? if rv["published"]?.try &.presence
json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.parse_rfc3339(rv["published"].to_s), locale)) json.field "publishedText", translate(locale, "`x` ago", recode_date(Time.parse_rfc3339(rv["published"].to_s), locale))
else else
json.field "publishedText", "" json.field "publishedText", ""