U
    g                     @   sD   d dl mZ ddlmZmZmZmZ ddlmZ G dd deZ	dS )   )InfoExtractor   )ExtractorErrorextract_attributesget_elements_html_by_classurl_or_none)traverse_objc                
   @   s|   e Zd 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dddddddddddidgZdZdd Z	dd  Z
dS )!GBNewsIEz(GB News clips, features and live streamsz=https?://(?:www\.)?gbnews\.(?:uk|com)/(?:\w+/)?(?P<id>[^#?]+)Zsafariz+https://mm-v2.simplestream.com/ssmp/api.phpzPhttps://www.gbnews.com/news/bbc-claudine-gay-harvard-university-antisemitism-rowZ52264136mp4z3re:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)z4bbc-claudine-gay-harvard-university-antisemitism-rowz>The post was criticised by former employers of the broadcasterzNBBC deletes post after furious backlash over headline downplaying antisemitism)idext	thumbnail
display_iddescriptiontitle)url	info_dictzWhttps://www.gbnews.com/royal/prince-harry-in-love-with-kate-meghan-markle-jealous-royalZ52328390z:prince-harry-in-love-with-kate-meghan-markle-jealous-royalzWIngrid Seward has published 17 books documenting the highs and lows of the Royal FamilyzORoyal author claims Prince Harry was 'in love' with Kate - Meghan was 'jealous'zhttps://www.gbnews.uk/watchliveZ1069Z	watchliveis_livezre:^GB News Live)r   r   r   r   Zlive_statusr   Zskip_downloadZm3u8)r   r   paramsNc                 C   s~   | j si | _ |sd}|sd}||f}| j |}|r8|S | j| jd d||dd}t|ddthf}|sptd|| j |< |S )	NZGB003
productionz&Downloading Simplestream JSON metadata)r   envqueryresponseZapi_hostnamezNo API host found)_SS_ENDPOINTSget_download_json	_SSMP_URLr   r   r   )selfZdata_idZdata_envkeyresultZ	json_dataZmeta_url r!   ;/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/gbnews.py_get_ss_endpoint3   s.      
zGBNewsIE._get_ss_endpointc                 C   s2  |  |dd }| ||}d }td|}|D ]"}t|}d|dpLdkr2|}q2|sftddd	| |d
|d}|d }	|d}
|
r|
dkrd}
| j| d|
 d|	 |	d|d| j	dd}t
|dr| |	 |	|| j|d d| j|d d| t
|ddthf|	d| j|d d|
dkdS )N/r   ZsimplestreamZsidebarclass zCould not find video elementT)expectedzdata-idzdata-envz	data-uvidz	data-typeZvodshowz/api/z/stream/zDownloading stream JSONzdata-key)r   platformr   Zdrm)defaultr   streamr
   Zlive)r   r   r   r   formatsr   r   )Z	_match_id
rpartitionZ_download_webpager   r   r   r   r#   r   	_PLATFORMr   Z
report_drmZ_og_search_titleZ_og_search_descriptionZ_extract_m3u8_formatsr   Z_og_search_thumbnail)r   r   r   ZwebpageZ
video_dataelementsZhtml_tag
attributesZendpoint_urlZuvidZ
video_typeZstream_datar!   r!   r"   _real_extractL   sP    

 

   zGBNewsIE._real_extract)__name__
__module____qualname__ZIE_DESCZ
_VALID_URLr.   r   Z_TESTSr   r#   r1   r!   r!   r!   r"   r	      sH    r	   N)
commonr   utilsr   r   r   r   Zutils.traversalr   r	   r!   r!   r!   r"   <module>   s   