mirror of
https://github.com/iv-org/invidious.git
synced 2025-02-24 16:28:22 -06:00
Added the text version of the published parameter
This commit is contained in:
parent
a0d24190b8
commit
be216fff94
@ -246,6 +246,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"]?
|
||||||
|
json.field "publishedTimeText", rv["publishedText"]?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ require "json"
|
|||||||
#
|
#
|
||||||
# TODO: "compactRadioRenderer" (Mix) and
|
# TODO: "compactRadioRenderer" (Mix) and
|
||||||
# TODO: Use a proper struct/class instead of a hacky JSON object
|
# TODO: Use a proper struct/class instead of a hacky JSON object
|
||||||
def parse_related_video(related : JSON::Any, published : String? = nil) : Hash(String, JSON::Any)?
|
def parse_related_video(related : JSON::Any, published : String? = nil, publishedText : String? = nil) : Hash(String, JSON::Any)?
|
||||||
return nil if !related["videoId"]?
|
return nil if !related["videoId"]?
|
||||||
|
|
||||||
# The compact renderer has video length in seconds, where the end
|
# The compact renderer has video length in seconds, where the end
|
||||||
@ -48,6 +48,7 @@ def parse_related_video(related : JSON::Any, published : String? = nil) : Hash(S
|
|||||||
"short_view_count" => JSON::Any.new(short_view_count || "0"),
|
"short_view_count" => JSON::Any.new(short_view_count || "0"),
|
||||||
"author_verified" => JSON::Any.new(author_verified),
|
"author_verified" => JSON::Any.new(author_verified),
|
||||||
"published" => JSON::Any.new(published || ""),
|
"published" => JSON::Any.new(published || ""),
|
||||||
|
"publishedText" => JSON::Any.new(publishedText || ""),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,12 +238,13 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
secondary_results.try &.as_a.each do |element|
|
secondary_results.try &.as_a.each do |element|
|
||||||
if item = element["compactVideoRenderer"]?
|
if item = element["compactVideoRenderer"]?
|
||||||
if item["publishedTimeText"]?
|
if item["publishedTimeText"]?
|
||||||
|
rv_published_time_text = item["publishedTimeText"].to_s
|
||||||
rv_decoded_time = decode_date(item["publishedTimeText"].to_s)
|
rv_decoded_time = decode_date(item["publishedTimeText"].to_s)
|
||||||
rv_published_timestamp = rv_decoded_time.to_unix.to_s
|
rv_published_timestamp = rv_decoded_time.to_unix.to_s
|
||||||
else
|
else
|
||||||
rv_published_timestamp = nil
|
rv_published_timestamp = nil
|
||||||
end
|
end
|
||||||
related_video = parse_related_video(item, published: rv_published_timestamp)
|
related_video = parse_related_video(item, published: rv_published_timestamp, publishedText: rv_published_time_text)
|
||||||
related << JSON::Any.new(related_video) if related_video
|
related << JSON::Any.new(related_video) if related_video
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user