mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix typecheck when fetching community attachments
This commit is contained in:
parent
0137a43722
commit
34f9159277
2 changed files with 5 additions and 2 deletions
|
@ -26,6 +26,7 @@ module YouTubeStructs
|
||||||
|
|
||||||
struct CommunityPost
|
struct CommunityPost
|
||||||
include DB::Serializable
|
include DB::Serializable
|
||||||
|
alias AttachmentType = (VideoRenderer | PlaylistRenderer | CommunityPoll | String)? # string is image/gif
|
||||||
|
|
||||||
# Author information
|
# Author information
|
||||||
property author : String
|
property author : String
|
||||||
|
@ -35,7 +36,7 @@ module YouTubeStructs
|
||||||
# Community post data
|
# Community post data
|
||||||
property post_id : String
|
property post_id : String
|
||||||
property content_html : String
|
property content_html : String
|
||||||
property attachment : (VideoRenderer | PlaylistRenderer | CommunityPoll | String)? # string is image/gif
|
property attachment : AttachmentType
|
||||||
property likes : Int32
|
property likes : Int32
|
||||||
property published : Time
|
property published : Time
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,9 @@ private module Parsers
|
||||||
attachment = YouTubeStructs::CommunityPoll.new({choices: choices, total_votes: votes})
|
attachment = YouTubeStructs::CommunityPoll.new({choices: choices, total_votes: votes})
|
||||||
else
|
else
|
||||||
attachment = extract_item(attachment_container)
|
attachment = extract_item(attachment_container)
|
||||||
raise "Unreachable" if !attachment.is_a?(YouTubeStructs::VideoRenderer | YouTubeStructs::PlaylistRenderer)
|
if !attachment.is_a?(YouTubeStructs::CommunityPost::AttachmentType)
|
||||||
|
raise "Unexpected type found for attachment. Expected : '#{YouTubeStructs::CommunityPost::AttachmentType}' got #{typeof(attachment)}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0]) # Youtube doesn't provide dislikes...
|
likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0]) # Youtube doesn't provide dislikes...
|
||||||
|
|
Loading…
Reference in a new issue