Invidious is an alternative front-end to YouTube
Fixed an issue
RadoslavL2a6a32e667f5
diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.crindex 79f3d46f..f5450f3f 100644--- a/src/invidious/jsonify/api_v1/video_json.cr+++ b/src/invidious/jsonify/api_v1/video_json.cr@@ -246,7 +246,7 @@ module Invidious::JSONify::APIv1json.field "viewCountText", rv["short_view_count"]?json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64json.field "published", rv["published"]?- json.field "publishedTimeText", rv["publishedText"]?+ json.field "publishedTimeText", translate(locale, "`x` ago", rv["publishedText"].to_s)endendenddiff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.crindex 929d492f..b96f4279 100644--- a/src/invidious/videos/parser.cr+++ b/src/invidious/videos/parser.cr@@ -6,7 +6,7 @@ require "json"## TODO: "compactRadioRenderer" (Mix) and# TODO: Use a proper struct/class instead of a hacky JSON object-def parse_related_video(related : JSON::Any, published : String? = nil, publishedText : String? = nil) : Hash(String, JSON::Any)?+def parse_related_video(related : JSON::Any, published : String? = nil) : Hash(String, JSON::Any)?return nil if !related["videoId"]?# The compact renderer has video length in seconds, where the end@@ -36,6 +36,8 @@ def parse_related_video(related : JSON::Any, published : String? = nil, publisheLOGGER.trace("parse_related_video: Found \"watchNextEndScreenRenderer\" container")+ publishedText = related["publishedTimeText"]["simpleText"].to_s+# TODO: when refactoring video types, make a struct for related videos# or reuse an existing type, if that fits.return {@@ -48,7 +50,7 @@ def parse_related_video(related : JSON::Any, published : String? = nil, publishe"short_view_count" => JSON::Any.new(short_view_count || "0"),"author_verified" => JSON::Any.new(author_verified),"published" => JSON::Any.new(published || ""),- "publishedText" => JSON::Any.new(translate(locale, "`x` ago", recode_date(video.published, locale)) || ""),+ "publishedText" => JSON::Any.new(publishedText || ""),}end@@ -237,14 +239,13 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any.dig?("secondaryResults", "secondaryResults", "results")secondary_results.try &.as_a.each do |element|if item = element["compactVideoRenderer"]?- if rv_published_time_text = item["publishedTimeText"]?- rv_published_time_text = rv_published_time_text.as_s- rv_decoded_time = decode_date(rv_published_time_text)+ if rv_published_time_text = item["publishedTimeText"]["simpleText"]?+ rv_decoded_time = decode_date(rv_published_time_text.to_s)rv_published_timestamp = rv_decoded_time.to_unix.to_selserv_published_timestamp = nilend- related_video = parse_related_video(item, published: rv_published_timestamp, publishedText: rv_published_time_text)+ related_video = parse_related_video(item, published: rv_published_timestamp)related << JSON::Any.new(related_video) if related_videoendend