o
    i
                     @   sL   d dl Z ddlmZ ddlmZ ddlmZ ddlmZ G dd	 d	eZ	dS )
    N   )BrightcoveNewIE)InfoExtractor   )ExtractorError)traverse_objc                   @   sR   e Zd ZdZdZdZdddddd	d
dddg ddd
ddgZdd Zdd ZdS )LaXarxaMesIEzShttps?://(?:www\.)?laxarxames\.cat/(?:[^/?#]+/)*?(player|movie-details)/(?P<id>\d+)
laxarxamesNz)https://www.laxarxames.cat/player/3459421 0966f46c34275934c19af78f3df6e2bc6339612436112mp4u"   Resum | UA Horta — UD Viladecansi"3ezre:https?://.*\.jpg 20231021gGz.`@)ottesportsz23-24z futbolz futbol-partitselitresum5779379807001)
idexttitle	timestamp	thumbnaildescriptionupload_datedurationtagsuploader_idzRequires login)urlmd5	info_dictskipc                 C   sh   | j rd S | jdd ddddt||dddd	 d
d}t|ddthf| _ | j s2tdddd S )Nz/https://api.laxarxames.cat/Authorization/SignInz
Logging inhttps://laxarxames.catapplication/json)X-TenantoriginContent-TypeWEBz	Mac OS ())PlatformCodeName)UsernamePasswordDevicei  )noteheadersdataexpected_statusAuthorizationTokenTokenzLogin failedTexpected)_TOKEN_download_jsonjsondumpsencoder   strr   )selfusernamepasswordlogin r>   O/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/laxarxames.py_perform_login   s(   zLaXarxaMesIE._perform_loginc                 C   s   |  |}| js|   | jd|tt|dd d| j dddd}t|d	t	hfs6| j
d
dd | d|d	  t||dS )Nz1https://api.laxarxames.cat/Media/GetMediaPlayInfoMAIN)MediaId
StreamTypezBearer r"   r#   )Authorizationr$   r%   )r.   r-   
ContentUrlzNo video foundTr2   zPhttps://players.brightcove.net/5779379807001/default_default/index.html?videoId=Title)	_match_idr4   raise_login_requiredr5   r6   r7   intr8   r   r9   raise_no_formats
url_resultr   get)r:   r   video_idmedia_play_infor>   r>   r?   _real_extract4   s*   

zLaXarxaMesIE._real_extract)	__name__
__module____qualname__
_VALID_URL_NETRC_MACHINEr4   _TESTSr@   rO   r>   r>   r>   r?   r   	   s*    r   )
r6   
brightcover   commonr   utilsr   utils.traversalr   r   r>   r>   r>   r?   <module>   s    