U
    g
                     @   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                   @   s\   e Zd ZdZdZdZdddddd	d
ddddddddddgdd
ddgZdd Zdd ZdS )LaXarxaMesIEzShttps?://(?:www\.)?laxarxames\.cat/(?:[^/?#]+/)*?(player|movie-details)/(?P<id>\d+)Z
laxarxamesNz)https://www.laxarxames.cat/player/3459421Z 0966f46c34275934c19af78f3df6e2bcZ6339612436112Zmp4u"   Resum | UA Horta — UD Viladecansi"3ezre:https?://.*\.jpg Z20231021gGz.`@ZottZesportsz23-24z futbolz futbol-partitsZelitZresumZ5779379807001)
idexttitle	timestampZ	thumbnaildescriptionZupload_datedurationtagsZuploader_idzRequires login)urlmd5Z	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 sdtdddd S )Nz/https://api.laxarxames.cat/Authorization/SignInz
Logging inhttps://laxarxames.catapplication/json)X-TenantoriginContent-TypeZWEBz	Mac OS ())ZPlatformCodeName)ZUsernameZPasswordZDevicei  )ZnoteheadersdataZexpected_statusZAuthorizationTokenTokenzLogin failedTexpected)_TOKEN_download_jsonjsondumpsencoder   strr   )selfusernamepasswordlogin r(   ?/tmp/pip-unpacked-wheel-q5ljy6pj/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sl| j
d
dd | d|d	  t||dS )Nz1https://api.laxarxames.cat/Media/GetMediaPlayInfoZMAIN)ZMediaIdZ
StreamTypezBearer r   r   )Authorizationr   r   )r   r   Z
ContentUrlzNo video foundTr   zPhttps://players.brightcove.net/5779379807001/default_default/index.html?videoId=ZTitle)Z	_match_idr   Zraise_login_requiredr   r    r!   intr"   r   r#   Zraise_no_formatsZ
url_resultr   get)r$   r   Zvideo_idZmedia_play_infor(   r(   r)   _real_extract4   s.    
 

  zLaXarxaMesIE._real_extract)	__name__
__module____qualname__Z
_VALID_URLZ_NETRC_MACHINEr   Z_TESTSr*   r.   r(   r(   r(   r)   r   	   s(   r   )
r    Z
brightcover   commonr   utilsr   Zutils.traversalr   r   r(   r(   r(   r)   <module>   s
   