
    Q&i"                        U d Z ddlmZ ddl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 ddlmZ dd	lmZ dd
lmZmZ dZdZ ej        e          ZddddddZeeef         ed<   	 g dZee         ed<   	 dededeeef         fdZ  G d dej!        ej"                  Z# G d de          Z$dede#ddfdZ%dede#ddfd Z&dede#ddfd!Z'd"edeee(f         fd#Z)dS )$z7Video extention to embed video in a html sphinx output.    )Path)AnyDictListTuple)urlparse)nodes)
directives)Sphinx)BuildEnvironment)logging)SphinxDirectiveSphinxTranslatorzRaphael Massabotz0.1.1z	video/mp4z	video/oggz
video/webm)z.mp4z.ogmz.ogvz.oggz.webmSUPPORTED_MIME_TYPES)autoplaycontrolsheightloopmutedposterpreloadwidthSUPPORTED_OPTIONSsrcenvreturnc                 .   t          t          |           j                  s|j                            d|            t          |           j        }|t          vrt          	                    d| d           t          
                    |d          }| |fS )aW  Return video and suffix.

    Load the video to the static directory if necessary and process the suffix. Raise a warning if not supported but do not stop the computation.

    Args:
        src: The source of the video file (can be local or url)
        env: the build environment

    Returns:
        the src file, the extention suffix
     zThe provided file type ("z.") is not a supported format. defaulting to "")boolr   netlocimagesadd_filer   suffixr   loggerwarningget)r   r   r#   types       `/home/geonatureadmin/si_en_reseau/tutos/venv/lib/python3.11/site-packages/sphinxcontrib/video.py	get_videor)   )   s     $%% %
B$$$#YYF)))^^^^	
 	
 	
  ##FB//D;    c                       e Zd ZdZdS )
video_nodezVideo node.N)__name__
__module____qualname____doc__ r*   r(   r,   r,   B   s        Dr*   r,   c            
           e Zd ZU dZdZeed<   dZeed<   dZ	eed<   e
j        e
j        e
j        e
j        e
j        e
j        e
j        e
j        e
j        d	Zeeef         ed<   d	ee         fd
ZdS )Videoz^Video directive.

    Wrapper for the html <video> tag embeding all the supported options
    Thas_content   required_argumentsoptional_arguments)	altr   
nocontrolsr   r   r   r   r   r   option_specr   c                    | j         }| j                            dd          }|r4|                                s t                              d| d           d}| j                            dd          }|r4|                                s t                              d| d           d}| j                            dd          }g d	}||vr t                              d
| d           d}t          | j        d         |          }d}t          | j                  dk    rt          | j        d         |          }n7|j	        j
        du r)t                              d| j        d          d           t          ||| j                            dd          d| j        v d| j        v|d| j        v d| j        v | j                            dd          ||          gS )z/Return the video node based on the set options.r   r   zThe provided height ("z$") is ignored as it's not an integerr   zThe provided width ("r   auto)r<   metadatanonezThe provided preload ("z1") is not an accepted value. defaulting to "auto"r   N   r5   Tz+A secondary source should be provided for ""r8   r   r9   r   r   r   )primary_srcsecondary_srcr8   r   r   r   r   r   r   r   r   )r   optionsr&   isdigitr$   r%   r)   	argumentslenconfigvideo_enforce_extra_sourcer,   )selfr   r   r   r   valid_preloadrA   rB   s           r(   runz	Video.run]   s    $ l&&x44 	&..** 	NNVVVV   F\%%gr22 	 	NNTTTT   E|''	6::444-''NNd'ddd   G  q 1377 t~!##%dnQ&7==MMZ2d::NNRdnQ>ORRR  
 '+L$$UB//#t|3%T\9t|+-|''"55  
 	
r*   N)r-   r.   r/   r0   r4   r   __annotations__r6   intr7   r
   	unchangedflagr:   r   strr   r   r,   rK   r1   r*   r(   r3   r3   H   s          
 K#O o&&'%
# 
#Kc3h 
 
 
5
T*% 5
 5
 5
 5
 5
 5
r*   r3   
translatornodeNc                 
   fdt           D             }dd                    |           d}d}| |j        d          z  }d         | |j        d          z  }|d	         z  }| j                            |           dS )
z#Entry point of the html video node.c                 <    g | ]}|         
| d |          dS )z="r@   r1   ).0krR   s     r(   
<listcomp>z)visit_video_node_html.<locals>.<listcomp>   s7    PPPaQP!))tAw)))PPPr*   z<video  >z<source src="{}" type="{}">rA   rB   Nr8   )r   joinformatbodyappend)rQ   rR   attrhtmlhtml_sources    `   r(   visit_video_node_htmlra      s     QPPP3DPPPD+#((4..+++D 0KK] 344DO(""D$9:: 	DKDO4     r*   c                 :    | j                             d           dS )zExit of the html video node.z</video>N)r\   r]   rQ   rR   s     r(   depart_video_node_htmlrd      s    O:&&&&&r*   c                 b    t                               d|d          d           t          j        )z&Entry point of the ignored video node.zvideo rA   z*: unsupported output format (node skipped))r$   r%   r	   SkipNoderc   s     r(   visit_video_node_unsuportedrg      s5    
NNPm$PPP   .r*   appc           
         |                      ddd           |                     t          t          t          ft
          dft
          dft
          dft
          dft
          df           |                     dt                     dddS )	z4Add video node and parameters to the Sphinx builder.rH   Fr_   N)r_   epublatexmantexinfotextvideoT)parallel_read_safeparallel_write_safe)add_config_valueadd_noder,   ra   rd   rg   add_directiver3   )rh   s    r(   setupru      s    5ufEEELL#%;<)40*D1($/,d3)40     gu%%% ##  r*   )*r0   pathlibr   typingr   r   r   r   urllib.parser   docutilsr	   docutils.parsers.rstr
   sphinx.applicationr   sphinx.environmentr   sphinx.utilr   sphinx.util.docutilsr   r   
__author____version__	getLoggerr-   r$   r   rP   rL   r   r)   GeneralElementr,   r3   ra   rd   rg   r   ru   r1   r*   r(   <module>r      s   = = =       ) ) ) ) ) ) ) ) ) ) ) ) ! ! ! ! ! !       + + + + + + % % % % % % / / / / / /       B B B B B B B B
		8	$	$ ( ( d38n    '	  	  	  49 	 	 	 +3 - %S/    2	 	 	 	 	 	 	 	J
 J
 J
 J
 J
O J
 J
 J
Z!&6 !j !T ! ! ! !$''7 'z 'd ' ' ' '
,< J SW    v $sDy/      r*   