From 48af0af9d5e0ca873fb216e8bf88eadb18428a7e Mon Sep 17 00:00:00 2001 From: RadoslavL Date: Mon, 9 Oct 2023 12:18:50 +0300 Subject: [PATCH] Added minutes as well --- src/invidious/videos/parser.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index e7458672..1b627c62 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -241,6 +241,17 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any if !time_text.nil? time_string = time_text["simpleText"]? end + if !time_string.nil? && time_string.to_s.ends_with?("minute ago") + time = Time.utc.to_unix - 60 + end + if !time_string.nil? && time_string.to_s.ends_with?("minutes ago") && !time_string.to_s.starts_with?("Streamed") + minutes = time_string.to_s.rchop(" minutes ago").to_i + time = Time.utc.to_unix - 60*minutes + end + if !time_string.nil? && time_string.to_s.ends_with?("minutes ago") && time_string.to_s.starts_with?("Streamed") + minutes = time_string.to_s.lchop("Streamed ").rchop(" minutes ago").to_i + time = Time.utc.to_unix - 60*minutes + end if !time_string.nil? && time_string.to_s.ends_with?("hour ago") time = Time.utc.to_unix - 3600 end