
    Sh                     v    d dl Z d dlmZmZmZmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ  G d	 d
e
          ZdS )    N)ListSequenceOptionalTextIOAny   )SSAEvent   )SubripFormat)	make_time)SSAFilec                       e Zd ZdZ ej        d          Zedede	fd            Z
edee	         defd            Zede	dee	         fd	            Zed
ddede	deddf
 fd            Zed
ddee         f fd            Z xZS )WebVTTFormatz
    Web Video Text Tracks (WebVTT) subtitle format implementation

    Currently, this shares implementation with :class:`pysubs2.formats.subrip.SubripFormat`.
    z%(\d{0,4}:)?(\d{2}):(\d{2})\.(\d{2,3})msreturnc                 V    t          j        |           }|                    dd          S )N,.)r   ms_to_timestampreplace)r   results     \/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pysubs2/formats/webvtt.pyr   zWebVTTFormat.ms_to_timestamp   s&    -b11~~c3'''    groupsc                     | \  }}}}|sd}n"t          |                    d                    }t          t           |||f          \  }}}t          ||||          S )Nr   :)hmsr   )intstripmapr   )	r   _h_m_s_msr   r   r   r   s	            r   timestamp_to_mszWebVTTFormat.timestamp_to_ms   sg     BC 	#AABHHSMM""AsRSM**1b1Q2....r   textc                 X    |                                                     d          rdS dS )z5See :meth:`pysubs2.formats.FormatBase.guess_format()`WEBVTTvttN)lstrip
startswith)clsr(   s     r   guess_formatzWebVTTFormat.guess_format!   s,     ;;==##H-- 	54r   subsr   fpformat_kwargsNc                 n    t          d|            t          t          |           j        d|||d|S )zy
        See :meth:`pysubs2.formats.SubripFormat.to_file()`, additional SRT options are supported by VTT as well
        zWEBVTT
)file)r0   r1   r2    )printsuperr   to_file)r.   r0   r1   r2   r3   	__class__s        r   r9   zWebVTTFormat.to_file)   sR    
 	jr""""/u\3''/ 9"g9 9179 9 	9r   c                 x    t                                          |          }|                    d            |S )Nc                     | j         S )N)start)es    r   <lambda>z1WebVTTFormat._get_visible_lines.<locals>.<lambda>5   s     r   )key)r8   _get_visible_linessort)r.   r0   visible_linesr:   s      r   rA   zWebVTTFormat._get_visible_lines2   s;    2248800111r   )__name__
__module____qualname____doc__recompile	TIMESTAMPstaticmethodr    strr   r   r'   classmethodr   r/   r   r   r9   r   r	   rA   __classcell__)r:   s   @r   r   r   
   sW        
 
CDDI(C (C ( ( ( \( / /# / / / \/      [ 99 9& 93 9# 9RV 9 9 9 9 9 [9 i DN      [    r   r   )rH   typingr   r   r   r   r   ssaeventr	   subripr   timer   ssafiler   r   r6   r   r   <module>rT      s    				 8 8 8 8 8 8 8 8 8 8 8 8 8 8                              , , , , ,< , , , , ,r   