
    g                     R    d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	  G d de	      Z
y)	zContains different functions to make end and opening credits, even though it is
difficult to fill everyone needs in this matter.
    )convert_path_to_string)CompositeVideoClip)Resize)	ImageClipTextClipc                   H     e Zd ZdZ ed      	 	 	 	 	 	 	 d fd	       Z xZS )CreditsClipa  Credits clip.

    Parameters
    ----------

    creditfile
      A string or path like object pointing to a text file
      whose content must be as follows:

      ..code:: python

          # This is a comment
          # The next line says : leave 4 blank lines
          .blank 4

          ..Executive Story Editor
          MARCEL DURAND

          ..Associate Producers
          MARTIN MARCEL
          DIDIER MARTIN

          ..Music Supervisor
          JEAN DIDIER

    width
      Total width of the credits text in pixels

    gap
      Horizontal gap in pixels between the jobs and the names

    color
      Color of the text. See ``TextClip.list('color')``
      for a list of acceptable names.

    font
      Name of the font to use. See ``TextClip.list('font')`` for
      the list of fonts you can use on your computer.

    font_size
      Size of font to use

    stroke_color
      Color of the stroke (=contour line) of the text. If ``None``,
      there will be no stroke.

    stroke_width
      Width of the stroke, in pixels. Can be a float, like 1.5.

    bg_color
      Color of the background. If ``None``, the background will be transparent.

    Returns
    -------

    image
      An ImageClip instance that looks like this and can be scrolled
      to make some credits: ::

          Executive Story Editor    MARCEL DURAND
             Associate Producers    MARTIN MARCEL
                                    DIDIER MARTIN
                Music Supervisor    JEAN DIDIER

    
creditfilec
                    g }
d}t        |      5 }|D ]  }|j                  d      r|j                  d      r?t        t        |j	                  d      d               D ]  }|
j                  ddg        e|j                  d      r|
j                  |dd  d	g       d}|r|
j                  d	|g       d
}|
j                  d|g        	 d d d        d t        |
 D        \  }}|df|dffD cg c]  \  }}t        |||||||       c}}\  }}t        ||j                  |j                  |	z   df      g|j                  |j                  z   |	z   |j                  f|      }|j                  t        |      g      }t        t        | ?  |j!                  d             t#        |j$                  j!                  d      d      | _        y # 1 sw Y   xY wc c}}w )NT)
#z.blank    r   z..    Fc              3   >   K   | ]  }d j                  |        yw)r   N)join).0lines     d/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/video/tools/credits.py	<genexpr>z'CreditsClip.__init__.<locals>.<genexpr>q   s     =rwwt}=s   leftright)textcolorstroke_colorstroke_widthfont	font_size
text_alignr   )sizebg_color)width)is_mask)open
startswithrangeintsplitappendzipr   r   with_positionwhwith_effectsr   super__init__	get_framer   mask)selfr
   r#   r   r   r   r   r   r"   gaptextsone_linefiler   ir   r   txtalignboth_columnsscaled	__class__s                        r   r1   zCreditsClip.__init__N   s    * 	/ /??;/__X."3tzz#q'9#:; 3dD\23__T*LL$qr(B0#HLL"d,$HLL$./	/$ >e=e !%f~w/?@
 U ))# 
e *5&&a'89:&&577"S(%''2
 **F,?+@A
 	h&v'7'7':;fkk33A6E	_	/ 	/*
s   B?G6G$G!)whiteblackr   zImpact-Normal<   Nr   )__name__
__module____qualname____doc__r   r1   __classcell__)r>   s   @r   r	   r	      s<    @D L)
 ?F *?F    r	   N)rE   moviepy.decoratorsr   ,moviepy.video.compositing.CompositeVideoClipr   moviepy.video.fx.Resizer   moviepy.video.VideoClipr   r   r	    rG   r   <module>rM      s(    6 K * 7CF( CFrG   