U
    g)                     @   sP   d dl Z d dlZddlmZ ddlmZmZ G dd deZG dd	 d	eZdS )
    N   )InfoExtractor   )InAdvancePagedListtraverse_objc                   @   s   e Zd ZdZdddddddd	d
dddddddddddd
dddgZddddddddd
ddd	dd d!d"d#d$d%d&d'd
ddd	dgZd(d) Zd*S )+LeFigaroVideoEmbedIEz8https?://video\.lefigaro\.fr/embed/[^?#]+/(?P<id>[\w-]+)zhttps://video.lefigaro.fr/embed/figaro/video/les-francais-ne-veulent-ils-plus-travailler-suivez-en-direct-le-club-le-figaro-idees/Z a0c3069b7e4c4526abf0053a7713f56fZg9j7EovouQ   Les Français ne veulent-ils plus travailler ? Retrouvez Le Club Le Figaro Idéesz$md5:862b8813148ba4bf10763a65a69dfe41Z20230216ici  z!re:^https?://[^?#]+\.(?:jpeg|jpg)Zmp4)idtitledescriptionupload_date	timestampduration	thumbnailext)urlmd5	info_dictzZhttps://video.lefigaro.fr/embed/figaro/video/intelligence-artificielle-faut-il-sen-mefier/Z 319c662943dd777bab835cae1e2d73a5ZLeAgybycu4   Intelligence artificielle : faut-il s’en méfier ?z$md5:249d136e3e5934a67c8cb704f8abf4d2Z20230124i!ci\  znhttps://video.lefigaro.fr/figaro/video/suivez-en-direct-le-club-le-figaro-international-avec-philippe-gelie-9/Z 6289f9489efb969e38245f31721596feZQChnbPYAuP   Où en est le couple franco-allemand ? Retrouvez Le Club Le Figaro Internationalz$md5:6f47235b7e7c93b366fd8ebfa10572acZ20230123iciQ  r   )	r   r	   r
   r   r   r   r   Z	age_limitr   zhhttps://video.lefigaro.fr/figaro/video/la-philosophe-nathalie-sarthou-lajus-est-linvitee-du-figaro-live/Z f6df814cae53e85937621599d2967520ZQJzqoNbfuD   La philosophe Nathalie Sarthou-Lajus est l’invitée du Figaro Livez$md5:c586793bb72e726c83aa257f99a8c8c4Z20230217ici  c                 C   sd   |  |}| ||}| ||d d d d d }| jd|d  |d|d	|d
dS )NpropsZ	pagePropsZinitialPropsZpageDataZ
playerDatazjwplatform:ZvideoIdr	   r
   Zposterr	   r
   r   )	_match_idZ_download_webpageZ_search_nextjs_data
url_resultget)selfr   
display_idZwebpageZplayer_data r   =/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/lefigaro.py_real_extractH   s,    
   z"LeFigaroVideoEmbedIE._real_extractN)__name__
__module____qualname__
_VALID_URL_TESTSZ_WEBPAGE_TESTSr   r   r   r   r   r      sl   r   c                   @   sJ   e Zd ZdZdddddddd	d
dddgZdZdddZdd ZdS )LeFigaroVideoSectionIEz>https?://video\.lefigaro\.fr/figaro/(?P<id>[\w-]+)/?(?:[#?]|$)z9https://video.lefigaro.fr/figaro/le-club-le-figaro-idees/zle-club-le-figaro-ideesu   Le Club Le Figaro Idées)r   r	      )r   r   Zplaylist_mincountz'https://video.lefigaro.fr/figaro/factu/ZfactuZFactui     Nc                 C   s0   | j d||dt|| jdd|d ddS )Nz'https://api-graphql.lefigaro.fr/graphqlz]flive-website_UpdateListPage_1fb260f996bca2d78960805ac382544186b3225f5bedb43ad08b9b8abef79af6ZDESCZPUBLISHED_AT)ZslugZvideosLimitsortorderpage)r   	variables)notequery)Z_download_jsonjsondumps
_PAGE_SIZEencode)r   r   page_numr)   r   r   r   _get_api_responsei   s      
z(LeFigaroVideoSectionIE._get_api_responsec                    sb    | j ddd d } fdd}t|t|d j j}j| |dd	S )
Nr   )r/   dataplaylistc                    sD   j  | d d| d  d}fdd|d d d d	 d
 D S )Nr   zDownloading page )r)   c              
      s.   g | ]&} j |d  tft|ddddqS )ZembedUrlnamer
   ZthumbnailUrlr   )r   r   r   ).0video)r   r   r   
<listcomp>~   s    zKLeFigaroVideoSectionIE._real_extract.<locals>.page_func.<locals>.<listcomp>r1   r2   ZjsonLdr   ZitemListElement)r0   )r/   Zapi_responser   r   r   r   	page_func{   s    
z7LeFigaroVideoSectionIE._real_extract.<locals>.page_funcZ
videoCountr	   )Zplaylist_idZplaylist_title)r   r0   r   mathceilr-   Zplaylist_resultr   )r   r   Zinitial_responser8   entriesr   r7   r   r   w   s    

  z$LeFigaroVideoSectionIE._real_extract)N)r   r   r   r    r!   r-   r0   r   r   r   r   r   r"   T   s"   
r"   )	r+   r9   commonr   utilsr   r   r   r"   r   r   r   r   <module>   s
   I