
    gd                        d Z ddlZddlZddlZddlmZ ej                  d        Zej                  d        Zej                  d        Zej                  d        Z	ej                  d        Z
ej                  d	        Zej                  d
        Zd Zd Zd Zej                  d        Zej                  d        Zy)zDecorators used by moviepy.    N)convert_to_secondsc                 >    |j                         } | |g|i | |S )zKApplies ``func(clip.copy(), *args, **kwargs)`` and returns ``clip.copy()``.)copyfuncclipargskwargsnew_clips        [/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/decorators.pyoutplacer      s&     yy{H#D#F#O    c                 R    |j                   r|j                         } | |g|i |S )zEIf the clip is a mask, convert it to RGB before running the function.)is_maskto_RGBr   r   r	   r
   s       r   convert_masks_to_RGBr      s+     ||{{}&t&v&&r   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )zZApplies the same function ``func`` to the mask of the clip created with
    ``func``.
    maskN)getattrr   r   s        r   apply_to_maskr      sC    
 D*4*6*Hx&X]]<T<V<Or   c                 n     | |g|i |}t        |dd      r | |j                  g|i ||_        |S )zMApplies the function ``func`` to the audio of the clip created with ``func``.audioN)r   r   r   s        r   apply_to_audior   &   sC     D*4*6*Hx$'hnn>t>v>Or   c                 H    |j                   t        d       | |g|i |S )z,Raises an error if the clip has no duration.zAttribute 'duration' not set)duration
ValueErrorr   s       r   requires_durationr   /   s/     }}788D*4*6**r   c                 `    t        |d      r|j                  t        d       | |g|i |S )z'Raises an error if the clip has no fps.fpszAttribute 'fps' not set)hasattrr    r   r   s       r   requires_fpsr"   8   s8     4488#3233D*4*6**r   c                     t        |d      r*|j                   | ||j                  g|i ||_        |S  | ||g|i |S )zUse an audio function on a video/audio clip.

    This decorator tells that the function func (audioclip -> audioclip)
    can be also used on a video clip, at which case it returns a
    videoclip with unmodified video and modified audio.
    r   )r!   r   )r   effectr   r	   r
   s        r   audio_video_effectr%   A   sP     tW::!fdjjB4B6BDJFD242622r   c                 <      fd}t        j                   |      S )zCApplies fun to variables in varnames before launching the function.c                     t        j                  |       j                  }t        ||      D cg c]  \  }}|v r
| 
|      n| }}}|j	                         D ci c]  \  }}||v r 
|      n| }	}} | |i |	S c c}}w c c}}w )Ninspectgetfullargspecr	   zipitems)r   r	   r
   namesargnamenew_argskwargvalue
new_kwargsfunvarnamess             r   wrapperz preprocess_args.<locals>.wrapperT   s    &&t,11  #4/
d )CHcI
 
 #),,.
 (!23u:=

 
 X,,,

s   B B
)	decorator)r4   r5   r6   s   `` r   preprocess_argsr8   Q   s    
- w''r   c                 "    t        t        |       S )z,Converts the specified variables to seconds.)r8   r   r5   s    r   convert_parameter_to_secondsr;   c   s    -x88r   c                 6    t        t        j                  |       S )z2Converts the specified variables to a path string.)r8   osfspathr:   s    r   convert_path_to_stringr?   h   s    299h//r   c                 R    |j                   |j                         } | |g|i |S )z(Add a mask to the clip if there is none.)r   	with_maskr   s       r   add_mask_if_nonerB   m   s/     yy~~&t&v&&r   c                 <     fd}t        j                         j                  dd }t        ||      D cg c]  \  }}|dk(  r ||      n| }}}|j	                         D 	
ci c]  \  }	}
|	|	dk(  r ||
      n|
 }}	}
  g|i |S c c}}w c c}
}	w )zBWill use ``clip.fps`` if no ``fps=...`` is provided in **kwargs**.c                 n    | | S t        dd       rj                  S t        dj                  z        )Nr    zNo 'fps' (frames per second) attribute specified for function %s and the clip has no 'fps' attribute. Either provide e.g. fps=24 in the arguments of the function, or define the clip's fps with `clip.fps=24`)r   r    AttributeError__name__)r    r   r   s    r   find_fpsz)use_clip_fps_by_default.<locals>.find_fpsy   sC    ?JT5$'88O1 48==A
 	
r      Nr    r(   )r   r   r	   r
   rG   r-   r.   r/   r0   r1   r2   r3   s   ``          r   use_clip_fps_by_defaultrI   u   s    

 ""4(--ab1E FIuEU6AsD$%-c1H 
 %llnUE 	%5.xe;J 
 .x.:..s   B)B)__doc__r)   r=   r7   moviepy.toolsr   r   r   r   r   r   r"   r%   r8   r;   r?   rB   rI    r   r   <module>rM      s   !  	  ,   ' '     + + + + 3 3($9
0
 ' ' / /r   