Ë
    Eü´j)  ã                   ób  — d dl Z d dlZd dlZ	 d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ ej                  dfej                   d	fej"                  d
fej$                  dfej&                  dffZ ed„ eD «       «      Z ed„ eD «       «      Z G d„ dee«      Zy# e$ r	 d dlmZ Y Œ™w xY w)é    N)ÚUserList)Úchain)Úcopy)ÚError)Ú
SubRipItem©ÚstrÚ	utf_32_leÚ	utf_32_beÚ	utf_16_leÚ	utf_16_beÚutf_8c              #   ó>   K  — | ]  \  }}|t        ||«      f–— Œ y ­w©Nr   )Ú.0ÚbomÚcodecs      úK/root/workspace/ytshorts/venv/lib/python3.12/site-packages/pysrt/srtfile.pyú	<genexpr>r      s   è ø€ ÒC±
°°U�Eœ3˜s E›?Ô+ÑCùs   ‚c              #   ó8   K  — | ]  \  }}t        |«      –— Œ y ­wr   )Úlen)r   r   Úencodings      r   r   r      s   è ø€ Ò4™m˜c 8”�S—Ñ4ùs   ‚c                   ó  — e Zd ZdZdZdZdZdZdd„Zd„ Z	d	„ Z
 ee	e
«      Z	 	 dd
„Zdd„Zd„ Zd„ Zed„ «       Zeddefd„«       Zed„ «       Zefd„Zeefd„«       Zdd„Zdd„Zed„ «       Zed„ «       Zed„ «       Zedd„«       Zed„ «       Zy)Ú
SubRipFileaÌ  
    SubRip file descriptor.

    Provide a pure Python mapping on all metadata.

    SubRipFile(items, eol, path, encoding)

    items -> list of SubRipItem. Default to [].
    eol -> str: end of line character. Default to linesep used in opened file
        if any else to os.linesep.
    path -> str: path where file will be saved. To open an existant file see
        SubRipFile.open.
    encoding -> str: encoding used at file save. Default to utf-8.
    r   é   é   r   Nc                 ób   — t        j                  | |xs g «       || _        || _        || _        y r   )r   Ú__init__Ú_eolÚpathr   )ÚselfÚitemsÚeolr    r   s        r   r   zSubRipFile.__init__0   s+   € Ü×Ñ˜$ ¢¨Ô,ØˆŒ	ØˆŒ	Ø ˆ�ó    c                 ó>   — | j                   xs t        j                  S r   )r   ÚosÚlinesep©r!   s    r   Ú_get_eolzSubRipFile._get_eol6   s   € Ø�y‰yÒ&œBŸJ™JÐ&r$   c                 ó.   — | j                   xs || _         y r   )r   )r!   r#   s     r   Ú_set_eolzSubRipFile._set_eol9   s   € Ø—I‘IÒ$ ˆ�	r$   c                 ó8  ‡‡‡‡— t        | «      }‰rˆfd„|j                  D «       |_        ‰rˆfd„|j                  D «       |_        ‰rˆfd„|j                  D «       |_        ‰rˆfd„|j                  D «       |_        t        |j                  «      |_        |S )aV  
        slice([starts_before][, starts_after][, ends_before][, ends_after]) -> SubRipFile clone

        All arguments are optional, and should be coercible to SubRipTime
        object.

        It reduce the set of subtitles to those that match match given time
        constraints.

        The returned set is a clone, but still contains references to original
        subtitles. So if you shift this returned set, subs contained in the
        original SubRipFile instance will be altered too.

        Example:
            >>> subs.slice(ends_after={'seconds': 20}).shift(seconds=2)
        c              3   óB   •K  — | ]  }|j                   ‰k  sŒ|–— Œ y ­wr   ©Ústart)r   ÚiÚstarts_befores     €r   r   z#SubRipFile.slice.<locals>.<genexpr>T   s   øè ø€ ÒK °1·7±7¸]Ó3Jœ!ÑKùó   ƒ˜c              3   óB   •K  — | ]  }|j                   ‰kD  sŒ|–— Œ y ­wr   r.   )r   r0   Ústarts_afters     €r   r   z#SubRipFile.slice.<locals>.<genexpr>V   s   øè ø€ ÒJ °1·7±7¸\Ó3Iœ!ÑJùr2   c              3   óB   •K  — | ]  }|j                   ‰k  sŒ|–— Œ y ­wr   ©Úend)r   r0   Úends_befores     €r   r   z#SubRipFile.slice.<locals>.<genexpr>X   s   øè ø€ ÒG °1·5±5¸;Ó3Fœ!ÑGùr2   c              3   óB   •K  — | ]  }|j                   ‰kD  sŒ|–— Œ y ­wr   r6   )r   r0   Ú
ends_afters     €r   r   z#SubRipFile.slice.<locals>.<genexpr>Z   s   øè ø€ ÒF °1·5±5¸:Ó3Eœ!ÑFùr2   )r   ÚdataÚlist)r!   r1   r4   r8   r:   Úclones    ```` r   ÚslicezSubRipFile.slice>   so   û€ ô& �T“
ˆáÛK U§Z¡ZÔKˆEŒJÙÛJ U§Z¡ZÔJˆEŒJÙÛG U§Z¡ZÔGˆEŒJÙÛF U§Z¡ZÔFˆEŒJä˜%Ÿ*™*Ó%ˆŒ
Øˆr$   c                 ó4   — |xs |}| j                  ||¬«      S )aW  
        at(timestamp) -> SubRipFile clone

        timestamp argument should be coercible to SubRipFile object.

        A specialization of slice. Return all subtiles visible at the
        timestamp mark.

        Example:
            >>> subs.at((0, 0, 20, 0)).shift(seconds=2)
            >>> subs.at(seconds=20).shift(seconds=2)
        )r1   r:   )r>   )r!   Ú	timestampÚkwargsÚtimes       r   ÚatzSubRipFile.at_   s!   € ð Ò"˜FˆØ�z‰z¨¸ˆzÓ>Ð>r$   c                 ó6   — | D ]  } |j                   |i |¤Ž Œ y)a
  shift(hours, minutes, seconds, milliseconds, ratio)

        Shift `start` and `end` attributes of each items of file either by
        applying a ratio or by adding an offset.

        `ratio` should be either an int or a float.
        Example to convert subtitles from 23.9 fps to 25 fps:
        >>> subs.shift(ratio=25/23.9)

        All "time" arguments are optional and have a default value of 0.
        Example to delay all subs from 2 seconds and half
        >>> subs.shift(seconds=2, milliseconds=500)
        N)Úshift)r!   ÚargsrA   Úitems       r   rE   zSubRipFile.shifto   s&   € ð ò 	(ˆDØˆD�J‰J˜Ð' Ó'ñ	(r$   c                 ó^   — | j                  «        t        | «      D ]  \  }}|dz   |_        Œ y)zŸ
        clean_indexes()

        Sort subs and reset their index attribute. Should be called after
        destructive operations like split or such.
        r   N)ÚsortÚ	enumerateÚindex)r!   rK   rG   s      r   Úclean_indexeszSubRipFile.clean_indexes€   s/   € ð 	�	‰	ŒÜ$ T›?ò 	#‰KˆE�4Ø ™ˆD�Jñ	#r$   c                 ó2   — dj                  d„ | D «       «      S )Nú
c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr   )Útext)r   r0   s     r   r   z"SubRipFile.text.<locals>.<genexpr>�   s   è ø€ Ò. A˜Ÿ�Ñ.ùs   ‚)Újoinr(   s    r   rP   zSubRipFile.text‹   s   € à�y‰yÑ.¨Ô.Ó.Ð.r$   Ú c                 óŒ   — | j                  ||¬«      \  }} | ||¬«      }|j                  ||¬«       |j                  «        |S )z¾
        open([path, [encoding]])

        If you do not provide any encoding, it can be detected if the file
        contain a bit order mark, unless it is set to utf-8 as default.
        )Úclaimed_encoding)r    r   ©Úerror_handling)Ú_open_unicode_fileÚreadÚclose)Úclsr    r   rV   Úsource_fileÚnew_files         r   ÚopenzSubRipFile.open�   sK   € ð !$× 6Ñ 6°tÈhÐ 6Ó WÑˆ�XÙ˜D¨8Ô4ˆØ�‰�k°.ˆÔAØ×ÑÔØˆr$   c                 ó~   — |j                  dd«      } | di |¤Ž}|j                  |j                  d«      |¬«       |S )z°
        from_string(source, **kwargs) -> SubRipFile

        `source` -> a unicode instance or at least a str instance encoded with
        `sys.getdefaultencoding()`
        rV   NTrU   © )ÚpoprX   Ú
splitlines)rZ   ÚsourcerA   rV   r\   s        r   Úfrom_stringzSubRipFile.from_string�   s@   € ð  Ÿ™Ð$4°dÓ;ˆÙ‘=˜‘=ˆØ�‰�f×'Ñ'¨Ó-¸nˆÔMØˆr$   c                 óv   — | j                  |«      | _        | j                  | j                  ||¬«      «       | S )a5  
        read(source_file, [error_handling])

        This method parse subtitles contained in `source_file` and append them
        to the current instance.

        `source_file` -> Any iterable that yield unicode strings, like a file
            opened with `codecs.open()` or an array of unicode.
        rU   )Ú
_guess_eolr#   ÚextendÚstream)r!   r[   rV   s      r   rX   zSubRipFile.readª   s2   € ð —?‘? ;Ó/ˆŒØ�‰�D—K‘K ¸N�KÓKÔLØˆr$   c              #   ó€  K  — g }t        t        |d«      «      D ]R  \  }}|j                  «       r|j                  |«       Œ(|}g }|sŒ/t	        |«      sŒ;	 t        j                  |«      –— ŒT y# t        $ rB}|xj                  dj                  |«      fz  c_        | j                  |||«       Y d}~Œœd}~ww xY w­w)ao  
        stream(source_file, [error_handling])

        This method yield SubRipItem instances a soon as they have been parsed
        without storing them. It is a kind of SAX parser for .srt files.

        `source_file` -> Any iterable that yield unicode strings, like a file
            opened with `codecs.open()` or an array of unicode.

        Example:
            >>> import pysrt
            >>> import codecs
            >>> file = codecs.open('movie.srt', encoding='utf-8')
            >>> for sub in pysrt.stream(file):
            ...     sub.text += "
Hello !"
            ...     print unicode(sub)
        rN   rR   N)rJ   r   ÚstripÚappendÚallr   Ú
from_linesr   rF   rQ   Ú_handle_error)rZ   r[   rV   Ústring_bufferrK   Úlinerb   Úerrors           r   rg   zSubRipFile.stream¸   s°   è ø€ ð& ˆÜ$¤U¨;¸Ó%=Ó>ò 	H‰KˆE�4Ø�z‰zŒ|Ø×$Ñ$ TÕ*à&�Ø "�Úœc &�kðHÜ(×3Ñ3°FÓ;Ó;ñ	Høô !ò HØŸ
š
 r§w¡w¨v£Ð&9Ñ9�
Ø×)Ñ)¨%°À×GÑGûðHüs6   ‚AB>Á	B>ÁA0Á-B>Á0	B;Á98B6Â1B>Â6B;Â;B>c                 óº   — |xs | j                   }|xs | j                  }t        j                  |d|¬«      }| j	                  ||¬«       |j                  «        y)zÂ
        save([path][, encoding][, eol])

        Use initial path if no other provided.
        Use initial encoding if no other provided.
        Use initial eol if no other provided.
        zw+©r   )r#   N)r    r   Úcodecsr]   Ú
write_intorY   )r!   r    r   r#   Ú	save_files        r   ÚsavezSubRipFile.saveÙ   sL   € ð Ò �t—y‘yˆØÒ,˜tŸ}™}ˆä—K‘K  d°XÔ>ˆ	Ø�‰˜	 sˆÔ+Ø�‰Õr$   c                 óä   — |xs | j                   }| D ][  }t        |«      }|dk7  r|j                  d|«      }|j                  |«       |j	                  d|z  «      rŒK|j                  |«       Œ] y)zÈ
        write_into(output_file [, eol])

        Serialize current state into `output_file`.

        `output_file` -> Any instance that respond to `write()`, typically a
        file object
        rN   r   N)r#   r	   ÚreplaceÚwriteÚendswith)r!   Úoutput_filer#   Ú
output_eolrG   Ústring_reprs         r   rt   zSubRipFile.write_intoè   ss   € ð ’_˜DŸH™Hˆ
àò 
	.ˆDÜ˜d›)ˆKØ˜TÒ!Ø)×1Ñ1°$¸
ÓC�Ø×Ñ˜kÔ*ð
 ×'Ñ'¨¨J©Õ7Ø×!Ñ! *Õ-ñ
	.r$   c                 ó|   — | j                  |«      }dD ]  }|j                  |«      sŒ|c S  t        j                  S )N)z
úrN   )Ú_get_first_linerz   r&   r'   )rZ   Ústring_iterableÚ
first_liner#   s       r   re   zSubRipFile._guess_eolÿ   s@   € à×(Ñ(¨Ó9ˆ
Ø'ò 	ˆCØ×"Ñ" 3Õ'Ø’
ð	ô �z‰zÐr$   c                 óÀ   — t        |d«      r|j                  «       }	 t        t        |«      «      }t        |d«      r|j                  «       |S # t        $ r Y yw xY w)NÚtellrR   Úseek)Úhasattrr„   ÚnextÚiterÚStopIterationr…   )rZ   r�   Úprevious_positionr‚   s       r   r€   zSubRipFile._get_first_line  sd   € ä�? FÔ+Ø /× 4Ñ 4Ó 6Ðð	Üœd ?Ó3Ó4ˆJô �? FÔ+Ø× Ñ Ð!2Ô3àÐøô ò 	Ùð	ús   žA Á	AÁAc                 óÂ   — t        |d«      }|j                  t        «      }|j                  «        t        D ]  \  }}|j                  |«      sŒ|c S  | j                  S )NÚrb)r]   rX   Ú
BIGGER_BOMrY   ÚBOMSÚ
startswithÚDEFAULT_ENCODING)rZ   r    Úfile_descriptorÚfirst_charsr   r   s         r   Ú_detect_encodingzSubRipFile._detect_encoding  s^   € ä˜t TÓ*ˆØ%×*Ñ*¬:Ó6ˆØ×ÑÔä!ò 	 ‰MˆC�Ø×%Ñ% cÕ*Ø’ð	 ð
 ×#Ñ#Ð#r$   c                 óô   — |xs | j                  |«      }t        j                  |d|¬«      }t        j	                  |d «      }|r0|j                  t        |«      «      }||k(  s|j                  d«       ||fS )NÚrrr   r   )r“   rs   r]   ÚCODECS_BOMSÚgetrX   r   r…   )rZ   r    rT   r   r[   Úpossible_bomÚfile_boms          r   rW   zSubRipFile._open_unicode_file"  st   € à#ÒA s×';Ñ';¸DÓ'AˆÜ—k‘k $¨°hÔ?ˆô #—‘ x°Ó6ˆÙØ"×'Ñ'¬¨LÓ(9Ó:ˆHØ˜|Ò+Ø× Ñ  Ô#Ø˜HÐ$Ð$r$   c                 óœ  — || j                   k(  r|f|j                  z   |_        |‚|| j                  k(  r—t        |«      j                  }t
        j                  j                  d|›d|›d�«       t
        j                  j                  |j                  d   j                  dd«      «       t
        j                  j                  d«       y y )NzPySRT-z(line z): 
r   Úasciirx   rN   )	ÚERROR_RAISErF   Ú	ERROR_LOGÚtypeÚ__name__ÚsysÚstderrry   Úencode)rZ   rp   rV   rK   Únames        r   rm   zSubRipFile._handle_error/  s•   € à˜SŸ_™_Ò,Ø˜ U§Z¡ZÑ/ˆEŒJØˆKØ˜SŸ]™]Ò*Ü˜“;×'Ñ'ˆDÜ�J‰J×ÒººeÐDÔEÜ�J‰J×Ñ˜UŸZ™Z¨™]×1Ñ1°'¸9ÓEÔFÜ�J‰J×Ñ˜TÕ"ð	 +r$   )NNNzutf-8)NNNNr   )NNN)rŸ   Ú
__module__Ú__qualname__Ú__doc__Ú
ERROR_PASSr�   rœ   r�   r   r)   r+   Úpropertyr#   r>   rC   rE   rL   rP   Úclassmethodr]   rc   rX   rg   rv   rt   re   r€   r“   rW   rm   r_   r$   r   r   r      s+  „ ñð €JØ€IØ€KàÐó!ò'ò%ñ �8˜XÓ
&€CàGKØóóB?ò (ò"	#ð ñ/ó ð/ð Ø D¸ò ó ðð ñ
ó ð
ð 0:ó ð Ø0:ò Hó ðHó@ó.ð. ñó ðð ñó ðð ñ
$ó ð
$ð ò
%ó ð
%ð ñ#ó ñ#r$   r   )r&   r    rs   Úcollectionsr   ÚImportErrorÚ	itertoolsr   r   Úpysrt.srtexcr   Úpysrt.srtitemr   Úpysrt.compatr	   ÚBOM_UTF32_LEÚBOM_UTF32_BEÚBOM_UTF16_LEÚBOM_UTF16_BEÚBOM_UTF8rŽ   Údictr–   Úmaxr�   Úobjectr   r_   r$   r   ú<module>r¸      s¸   ðã 	Û 
Û ð"Ý$õ Ý å Ý $Ý à	×	Ñ	˜kÐ*Ø	×	Ñ	˜kÐ*Ø	×	Ñ	˜kÐ*Ø	×	Ñ	˜kÐ*Ø	�‰˜'Ð"ð	$€ñ
 ÑC¸dÔCÓC€ÙÑ4¨tÔ4Ó4€
ô]#�˜6õ ]#øð' ò "ß!ð"ús   ŽB  Â B.Â-B.