
    Ri)                     d   S SK r S SKrS SKr S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  \R                  S4\R                   S	4\R"                  S
4\R$                  S4\R&                  S44r\" S \ 5       5      r\" S \ 5       5      r " S S\\5      rg! \ a	    S SKJr   Nf = f)    N)UserList)chain)copy)Error)
SubRipItemstr	utf_32_le	utf_32_be	utf_16_le	utf_16_beutf_8c              #   @   #    U  H  u  pU[        X5      4v   M     g 7fNr   ).0bomcodecs      _/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/pysrt/srtfile.py	<genexpr>r      s     Cd
E3s?+ds   c              #   <   #    U  H  u  p[        U5      v   M     g 7fr   )len)r   r   encodings      r   r   r      s     4tmcSts   c                   8   \ rS rSrSrSrSrSrSrSS jr	S	 r
S
 r\" \
\5      r  SS jrSS jrS rS r\S 5       r\SS\4S j5       r\S 5       r\4S jr\\4S j5       rS S jrSS jr\S 5       r\S 5       r\S 5       r\SS j5       r\S 5       rSrg)!
SubRipFile   a  
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                 f    [         R                  " X=(       d    / 5        X l        X0l        X@l        g r   )r   __init___eolpathr   )selfitemseolr!   r   s        r   r   SubRipFile.__init__0   s#    $,		     c                 H    U R                   =(       d    [        R                  $ r   )r    oslinesepr"   s    r   _get_eolSubRipFile._get_eol6   s    yy&BJJ&r&   c                 8    U R                   =(       d    UU l         g r   )r    )r"   r$   s     r   _set_eolSubRipFile._set_eol9   s    II$	r&   c                 h  ^^^^ [        U 5      nT(       a  U4S jUR                   5       Ul        T(       a  U4S jUR                   5       Ul        T(       a  U4S jUR                   5       Ul        T(       a  U4S jUR                   5       Ul        [        UR                  5      Ul        U$ )a  
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   J   >#    U  H  oR                   T:  d  M  Uv   M     g 7fr   start)r   istarts_befores     r   r   #SubRipFile.slice.<locals>.<genexpr>T   s     KZ77]3J!!Z   #	#c              3   J   >#    U  H  oR                   T:  d  M  Uv   M     g 7fr   r2   )r   r4   starts_afters     r   r   r6   V   s     JZ77\3I!!Zr7   c              3   J   >#    U  H  oR                   T:  d  M  Uv   M     g 7fr   end)r   r4   ends_befores     r   r   r6   X   s     GZ55;3F!!Zr7   c              3   J   >#    U  H  oR                   T:  d  M  Uv   M     g 7fr   r;   )r   r4   
ends_afters     r   r   r6   Z   s     FZ55:3E!!Zr7   )r   datalist)r"   r5   r9   r=   r?   clones    ```` r   sliceSubRipFile.slice>   so    & T
KUZZKEJJUZZJEJGUZZGEJFUZZFEJ%**%
r&   c                 6    U=(       d    UnU R                  X3S9$ )a  
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)
)r5   r?   )rC   )r"   	timestampkwargstimes       r   atSubRipFile.at_   s     "Fzzz>>r&   c                 :    U  H  nUR                   " U0 UD6  M     g)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"   argsrG   items       r   rL   SubRipFile.shifto   s     DJJ'' r&   c                 `    U R                  5         [        U 5       H  u  pUS-   Ul        M     g)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"   rS   rN   s      r   clean_indexesSubRipFile.clean_indexes   s(     			$T?KEDJ +r&   c                 2    SR                  S U  5       5      $ )N
c              3   8   #    U  H  oR                   v   M     g 7fr   )text)r   r4   s     r   r   "SubRipFile.text.<locals>.<genexpr>   s     .As   )joinr*   s    r   rY   SubRipFile.text   s    yy....r&    c                 r    U R                  XS9u  pBU " XS9nUR                  XCS9  UR                  5         U$ )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   ra   source_filenew_files         r   openSubRipFile.open   sC     !$ 6 6t 6 WD4kAr&   c                 x    UR                  SS5      nU " S0 UD6nUR                  UR                  S5      US9  U$ )z
from_string(source, **kwargs) -> SubRipFile

`source` -> a unicode instance or at least a str instance encoded with
`sys.getdefaultencoding()`
ra   NTr`    )poprc   
splitlines)re   sourcerG   ra   rg   s        r   from_stringSubRipFile.from_string   s@      $4d;==f''-nMr&   c                 n    U R                  U5      U l        U R                  U R                  XS95        U $ )a  
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.
r`   )
_guess_eolr$   extendstream)r"   rf   ra   s      r   rc   SubRipFile.read   s0     ??;/DKKKKLr&   c              #     #    / n[        [        US5      5       He  u  pEUR                  5       (       a  UR                  U5        M-  Un/ nU(       d  M:  [	        U5      (       d  ML   [
        R                  " U5      v   Mg     g! [         aB  nU=R                  SR                  U5      4-  sl        U R                  XrU5         SnAM  SnAff = f7f)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)
        rW   r]   N)rR   r   stripappendallr   
from_linesr   rM   r[   _handle_error)re   rf   ra   string_bufferrS   linern   errors           r   rt   SubRipFile.stream   s     & $U;%=>KEzz||$$T*& "6c&kkH(33F;; ? ! H

rwwv&99
))%GGHs6   ACC'B?C
C7CCCCc                     U=(       d    U R                   nU=(       d    U R                  n[        R                  " USUS9nU R	                  XCS9  UR                  5         g)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   codecsrh   
write_intord   )r"   r!   r   r$   	save_files        r   saveSubRipFile.save   sJ      tyy,t}}KKdX>		+r&   c                     U=(       d    U R                   nU  Hc  n[        U5      nUS:w  a  UR                  SU5      nUR                  U5        UR	                  SU-  5      (       a  MR  UR                  U5        Me     g)z
write_into(output_file [, eol])

Serialize current state into `output_file`.

`output_file` -> Any instance that respond to `write()`, typically a
file object
rW   r   N)r$   r	   replacewriteendswith)r"   output_filer$   
output_eolrN   string_reprs         r   r   SubRipFile.write_into   sq     _DHH
Dd)KT!)11$
Ck*
 ''J77!!*- r&   c                     U R                  U5      nS H  nUR                  U5      (       d  M  Us  $    [        R                  $ )N)z
rW   )_get_first_liner   r(   r)   )re   string_iterable
first_liner$   s       r   rr   SubRipFile._guess_eol   s>    ((9
'C""3''
 ( zzr&   c                     [        US5      (       a  UR                  5       n [        [        U5      5      n[        US5      (       a  UR                  W5        U$ ! [         a     gf = f)Ntellr]   seek)hasattrr   nextiterStopIterationr   )re   r   previous_positionr   s       r   r   SubRipFile._get_first_line  sj    ?F++ / 4 4 6	d?34J ?F++  !23  		s   A 
A('A(c                     [        US5      nUR                  [        5      nUR                  5         [         H  u  pEUR                  U5      (       d  M  Us  $    U R                  $ )Nrb)rh   rc   
BIGGER_BOMrd   BOMS
startswithDEFAULT_ENCODING)re   r!   file_descriptorfirst_charsr   r   s         r   _detect_encodingSubRipFile._detect_encoding  sZ    tT*%**:6!MC%%c** "
 ###r&   c                    U=(       d    U R                  U5      n[        R                  " USUS9n[        R	                  US 5      nU(       a0  UR                  [        U5      5      nXe:X  d  UR                  S5        XC4$ )Nrr   r   )r   r   rh   CODECS_BOMSgetrc   r   r   )re   r!   r_   r   rf   possible_bomfile_boms          r   rb   SubRipFile._open_unicode_file"  sp    #As';';D'Akk$h? #x6"''L(9:H+  #$$r&   c                    X R                   :X  a  U4UR                  -   Ul        UeX R                  :X  a  [        U5      R                  n[
        R                  R                  SU< SU< S35        [
        R                  R                  UR                  S   R                  SS5      5        [
        R                  R                  S5        g g )NzPySRT-z(line z): 
r   asciir   rW   )	ERROR_RAISErM   	ERROR_LOGtype__name__sysstderrr   encode)re   r~   ra   rS   names        r   r{   SubRipFile._handle_error/  s    __,UZZ/EJK]]*;''DJJeDEJJUZZ]11'9EFJJT"	 +r&   )r    r   r$   r!   )NNNzutf-8)NNNNr   )NNN) r   
__module____qualname____firstlineno____doc__
ERROR_PASSr   r   r   r   r+   r.   propertyr$   rC   rI   rL   rT   rY   classmethodrh   ro   rc   rt   r   r   rr   r   r   rb   r{   __static_attributes__rk   r&   r   r   r      s+    JIK!'% 8X
&CGKB? ("	# / / D   
 
 0:  0: H H@..     
$ 
$ 
% 
% # #r&   r   )r(   r   r   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   rk   r&   r   <module>r      s    	 
 "$    $ 			k*			k*			k*			k*	'"	$
 CdCC4t44
]#6 ]#'  "!"s   B   B/.B/