diff --git a/src/invidious/data_structs/youtube/renderers/community_post.cr b/src/invidious/data_structs/youtube/renderers/community_post.cr index b883ee81..954632c0 100644 --- a/src/invidious/data_structs/youtube/renderers/community_post.cr +++ b/src/invidious/data_structs/youtube/renderers/community_post.cr @@ -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 diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index 919f9f57..b2aff56a 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -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...