a
    Ò�éiE
  ã                   @   sR   d dl Z d dlmZmZ d dlmZ d dlmZ er@d dlm	Z	 G dd„ dƒZ
dS )é    N)ÚTYPE_CHECKINGÚUnion)ÚArtifact)ÚError)ÚPagec                   @   s€   e Zd Zdddœdd„Zedœdd„Zddœd	d
„Zeddœdd„Ze	j
dœdd„Zeee	j
f ddœdd„Zddœdd„ZdS )ÚVideor   N)ÚpageÚreturnc                    sL   |j ˆ _ |jˆ _|ˆ _|j  ¡ ˆ _| ¡ r4ˆ  ¡  n| d‡ fdd„¡ d S )NÚclosec                    s   ˆ   ¡ S ©N)Ú_page_closed)r   ©Úself© úG/home/Claro/venv/lib/python3.9/site-packages/playwright/_impl/_video.pyÚ<lambda>"   ó    z Video.__init__.<locals>.<lambda>)Z_loopZ_dispatcher_fiberÚ_pageZcreate_futureÚ_artifact_futureZ	is_closedr   Úon)r   r   r   r   r   Ú__init__   s    
zVideo.__init__)r	   c                 C   s   d| j › d�S )Nz<Video page=ú>)r   r   r   r   r   Ú__repr__$   s    zVideo.__repr__c                 C   s   | j  ¡ s| j  tdƒ¡ d S )NzPage closed)r   ÚdoneZset_exceptionr   r   r   r   r   r   '   s    
zVideo._page_closed)Úartifactr	   c                 C   s   | j  ¡ s| j  |¡ d S r   )r   r   Z
set_result©r   r   r   r   r   Ú_artifact_ready+   s    
zVideo._artifact_readyc                 Ã   s0   | j jjrtdƒ‚| jI d H }|s*tdƒ‚|jS )Nz[Path is not available when using browserType.connect(). Use save_as() to save a local copy.ú%Page did not produce any video frames)r   Ú_connectionZ	is_remoter   r   Zabsolute_pathr   r   r   r   Úpath/   s    
ÿz
Video.path)r   r	   c                 Ã   sF   | j jjr| j jstdƒ‚| jI d H }|s2tdƒ‚| |¡I d H  d S )Nz?Page is not yet closed. Close the page prior to calling save_asr   )r   r   Z_is_syncZ
_is_closedr   r   Úsave_as)r   r   r   r   r   r   r    9   s    ÿzVideo.save_asc                 Ã   s*   | j I d H }|stdƒ‚| ¡ I d H  d S )Nr   )r   r   Údeleter   r   r   r   r!   C   s    zVideo.delete)Ú__name__Ú
__module__Ú__qualname__r   Ústrr   r   r   r   ÚpathlibÚPathr   r   r    r!   r   r   r   r   r      s   


r   )r&   Útypingr   r   Zplaywright._impl._artifactr   Zplaywright._impl._helperr   Zplaywright._impl._pager   r   r   r   r   r   Ú<module>   s   