mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-30 09:18:28 +00:00
Add logic to parse channel watermark data
This commit is contained in:
parent
d76fed5850
commit
44b8ecfab9
@ -55,6 +55,10 @@ module Invidious::JSONify::APIv1
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if watermark = video.watermark?
|
||||||
|
json.field "authorWatermark", watermark
|
||||||
|
end
|
||||||
|
|
||||||
json.field "subCountText", video.sub_count_text
|
json.field "subCountText", video.sub_count_text
|
||||||
|
|
||||||
json.field "lengthSeconds", video.length_seconds
|
json.field "lengthSeconds", video.length_seconds
|
||||||
|
@ -15,7 +15,7 @@ struct Video
|
|||||||
# NOTE: don't forget to bump this number if any change is made to
|
# NOTE: don't forget to bump this number if any change is made to
|
||||||
# the `params` structure in videos/parser.cr!!!
|
# the `params` structure in videos/parser.cr!!!
|
||||||
#
|
#
|
||||||
SCHEMA_VERSION = 2
|
SCHEMA_VERSION = 3
|
||||||
|
|
||||||
property id : String
|
property id : String
|
||||||
|
|
||||||
@ -258,6 +258,10 @@ struct Video
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def watermark?
|
||||||
|
return info["watermark"]?
|
||||||
|
end
|
||||||
|
|
||||||
# Macros defining getters/setters for various types of data
|
# Macros defining getters/setters for various types of data
|
||||||
|
|
||||||
private macro getset_string(name)
|
private macro getset_string(name)
|
||||||
|
@ -378,6 +378,18 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
.try &.as_s.split(" ", 2)[0]
|
.try &.as_s.split(" ", 2)[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Channel watermark
|
||||||
|
# Annotations is different from legacy annotations
|
||||||
|
if watermark = player_response.dig?("annotations", 0, "playerAnnotationsExpandedRenderer", "featuredChannel")
|
||||||
|
watermark_data = {
|
||||||
|
"startTimeMs" => watermark["startTimeMs"],
|
||||||
|
"endTimeMS" => watermark["endTimeMs"],
|
||||||
|
"thumbnailURL" => watermark["watermark"]["thumbnails"][0]["url"],
|
||||||
|
}
|
||||||
|
else
|
||||||
|
watermark_data = {} of String => JSON::Any
|
||||||
|
end
|
||||||
|
|
||||||
# Return data
|
# Return data
|
||||||
|
|
||||||
if live_now
|
if live_now
|
||||||
@ -422,6 +434,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
|||||||
"authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""),
|
"authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""),
|
||||||
"authorVerified" => JSON::Any.new(author_verified || false),
|
"authorVerified" => JSON::Any.new(author_verified || false),
|
||||||
"subCountText" => JSON::Any.new(subs_text || "-"),
|
"subCountText" => JSON::Any.new(subs_text || "-"),
|
||||||
|
"watermark" => JSON::Any.new(watermark_data),
|
||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
Loading…
Reference in New Issue
Block a user