Compare commits

...

22 Commits

Author SHA1 Message Date
RadoslavL d9749584b3
Merge 7b7197cde8 into b673695aa2 2024-04-22 16:26:59 +03:00
RadoslavL 7b7197cde8 retrigger checks 2024-04-22 16:26:49 +03:00
RadoslavL 6861148290 Moved code around and fixed a problem 2023-11-24 11:24:56 +02:00
RadoslavL 03f9962a47 This should work 2023-11-14 10:00:18 +02:00
RadoslavL d098e5ae9b I hope it works at this point 2023-11-14 09:58:37 +02:00
RadoslavL 4c486634e2 Another attempt at fixing the issue 2023-11-14 09:56:06 +02:00
RadoslavL 3bced4e12b Fixed another issue 2023-11-14 09:51:12 +02:00
RadoslavL 0d22af6564 Moved methods around 2023-11-14 09:47:16 +02:00
RadoslavL 2a6a32e667 Fixed an issue 2023-11-14 09:43:52 +02:00
RadoslavL 50da6cf3e7
Organize the code better
Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com>
2023-11-12 20:52:11 +02:00
RadoslavL 7388e4ca72
Add translation to the `publishedText` parameter
Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com>
2023-11-12 20:51:33 +02:00
RadoslavL be216fff94 Added the text version of the published parameter 2023-11-12 08:37:13 +02:00
RadoslavL a0d24190b8 Made published be an optional parameter 2023-11-08 19:09:16 +02:00
RadoslavL 76369eb599 Removed unused attribute 2023-11-08 10:18:29 +02:00
RadoslavL 6236cea33e
Changed some variable names
Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com>
2023-11-08 10:13:16 +02:00
RadoslavL fa59f41f7b Fixed an issue 2023-10-11 09:12:27 +03:00
RadoslavL 20ca1ebcc0 Used the decode_date function instead 2023-10-11 09:08:23 +03:00
RadoslavL b0b4f09b3a Seperated the code in a function 2023-10-09 12:26:38 +03:00
RadoslavL 48af0af9d5 Added minutes as well 2023-10-09 12:18:50 +03:00
RadoslavL f9460e31bc Fixed an issue 2023-10-09 12:09:03 +03:00
RadoslavL b7a252b096 Removed need for more API calls by parsing the publishedTimeText string 2023-10-09 12:00:37 +03:00
RadoslavL 6b929da0e1 Added a 'published' video parameter 2023-10-07 16:57:47 +03:00
2 changed files with 12 additions and 0 deletions

View File

@ -246,6 +246,8 @@ module Invidious::JSONify::APIv1
json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i
json.field "viewCountText", rv["short_view_count"]?
json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64
json.field "published", rv["published"]?
json.field "publishedTimeText", translate(locale, "`x` ago", rv["publishedText"].to_s.gsub(" ago", ""))
end
end
end

View File

@ -36,6 +36,14 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
LOGGER.trace("parse_related_video: Found \"watchNextEndScreenRenderer\" container")
if published_time_text = related["publishedTimeText"]?
decoded_time = decode_date(published_time_text["simpleText"].to_s)
published = decoded_time.to_unix.to_s
published_time_text = published_time_text["simpleText"].to_s
else
published = nil
end
# TODO: when refactoring video types, make a struct for related videos
# or reuse an existing type, if that fits.
return {
@ -47,6 +55,8 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
"view_count" => JSON::Any.new(view_count || "0"),
"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(published_time_text || ""),
}
end