@@ -86,6 +86,8 @@ def parse(cls, block: Union[dict, "Block"]) -> Optional["Block"]:
8686 return CallBlock (** block )
8787 elif type == HeaderBlock .type :
8888 return HeaderBlock (** block )
89+ elif type == VideoBlock .type :
90+ return VideoBlock (** block )
8991 else :
9092 cls .logger .warning (f"Unknown block detected and skipped ({ block } )" )
9193 return None
@@ -492,3 +494,100 @@ def _validate_text(self):
492494 @JsonValidator (f"text attribute cannot exceed { text_max_length } characters" )
493495 def _validate_alt_text_length (self ):
494496 return self .text is None or len (self .text .text ) <= self .text_max_length
497+
498+
499+ class VideoBlock (Block ):
500+ type = "video"
501+ title_max_length = 200
502+ author_name_max_length = 50
503+
504+ @property
505+ def attributes (self ) -> Set [str ]:
506+ return super ().attributes .union (
507+ {
508+ "alt_text" ,
509+ "video_url" ,
510+ "thumbnail_url" ,
511+ "title" ,
512+ "title_url" ,
513+ "description" ,
514+ "provider_icon_url" ,
515+ "provider_name" ,
516+ "author_name" ,
517+ }
518+ )
519+
520+ def __init__ (
521+ self ,
522+ * ,
523+ block_id : Optional [str ] = None ,
524+ alt_text : Optional [str ] = None ,
525+ video_url : Optional [str ] = None ,
526+ thumbnail_url : Optional [str ] = None ,
527+ title : Optional [Union [str , dict , PlainTextObject ]] = None ,
528+ title_url : Optional [str ] = None ,
529+ description : Optional [Union [str , dict , PlainTextObject ]] = None ,
530+ provider_icon_url : Optional [str ] = None ,
531+ provider_name : Optional [str ] = None ,
532+ author_name : Optional [str ] = None ,
533+ ** others : dict ,
534+ ):
535+ """A video block is designed to embed videos in all app surfaces
536+ (e.g. link unfurls, messages, modals, App Home) —
537+ anywhere you can put blocks! To use the video block within your app,
538+ you must have the links.embed:write scope.
539+ https://api.slack.com/reference/block-kit/blocks#video
540+
541+ Args:
542+ block_id: A string acting as a unique identifier for a block. If not specified, one will be generated.
543+ Maximum length for this field is 255 characters.
544+ block_id should be unique for each message and each iteration of a message.
545+ If a message is updated, use a new block_id.
546+ alt_text (required): A tooltip for the video. Required for accessibility
547+ video_url (required): The URL to be embedded. Must match any existing unfurl domains within the app
548+ and point to a HTTPS URL.
549+ thumbnail_url (required): The thumbnail image URL
550+ title (required): Video title in plain text format. Must be less than 200 characters.
551+ title_url: Hyperlink for the title text. Must correspond to the non-embeddable URL for the video.
552+ Must go to an HTTPS URL.
553+ description: Description for video in plain text format.
554+ provider_icon_url: Icon for the video provider - ex. Youtube icon
555+ provider_name: The originating application or domain of the video ex. Youtube
556+ author_name: Author name to be displayed. Must be less than 50 characters.
557+ """
558+ super ().__init__ (type = self .type , block_id = block_id )
559+ show_unknown_key_warning (self , others )
560+
561+ self .alt_text = alt_text
562+ self .video_url = video_url
563+ self .thumbnail_url = thumbnail_url
564+ self .title = TextObject .parse (title , default_type = PlainTextObject .type )
565+ self .title_url = title_url
566+ self .description = TextObject .parse (description , default_type = PlainTextObject .type )
567+ self .provider_icon_url = provider_icon_url
568+ self .provider_name = provider_name
569+ self .author_name = author_name
570+
571+ @JsonValidator ("alt_text attribute must be specified" )
572+ def _validate_alt_text (self ):
573+ return self .alt_text is not None
574+
575+ @JsonValidator ("video_url attribute must be specified" )
576+ def _validate_video_url (self ):
577+ return self .video_url is not None
578+
579+ @JsonValidator ("thumbnail_url attribute must be specified" )
580+ def _validate_thumbnail_url (self ):
581+ return self .thumbnail_url is not None
582+
583+ @JsonValidator ("title attribute must be specified" )
584+ def _validate_title (self ):
585+ return self .title is not None
586+
587+ @JsonValidator (f"title attribute cannot exceed { title_max_length } characters" )
588+ def _validate_title_length (self ):
589+ return self .title is None or len (self .title .text ) < self .title_max_length
590+
591+ @JsonValidator (f"author_name attribute cannot exceed { author_name_max_length } characters" )
592+ def _validate_author_name_length (self ):
593+ return self .author_name is None or len (self .author_name ) < self .author_name_max_length
0 commit comments