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   