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
|
||||
include DB::Serializable
|
||||
alias AttachmentType = (VideoRenderer | PlaylistRenderer | CommunityPoll | String)? # string is image/gif
|
||||
|
||||
# Author information
|
||||
property author : String
|
||||
|
@ -35,7 +36,7 @@ module YouTubeStructs
|
|||
# Community post data
|
||||
property post_id : String
|
||||
property content_html : String
|
||||
property attachment : (VideoRenderer | PlaylistRenderer | CommunityPoll | String)? # string is image/gif
|
||||
property attachment : AttachmentType
|
||||
property likes : Int32
|
||||
property published : Time
|
||||
|
||||
|
|
|
@ -353,7 +353,9 @@ private module Parsers
|
|||
attachment = YouTubeStructs::CommunityPoll.new({choices: choices, total_votes: votes})
|
||||
else
|
||||
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
|
||||
|
||||
likes = short_text_to_number(item_contents["voteCount"]["simpleText"].as_s.split(" ")[0]) # Youtube doesn't provide dislikes...
|
||||
|
|
Loading…
Reference in a new issue