o
    i                     @   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>[^#?]+)safariz+https://mm-v2.simplestream.com/ssmp/api.phpzPhttps://www.gbnews.com/news/bbc-claudine-gay-harvard-university-antisemitism-row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-royal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/watchlive1069	watchliveis_livezre:^GB News Live)r   r   r   r   live_statusr   skip_downloadm3u8)r   r   paramsNc                 C   s~   | j si | _ |s
d}|sd}||f}| j |}|r|S | j| jd d||dd}t|ddthf}|s8td|| j |< |S )	NGB003
productionz&Downloading Simplestream JSON metadata)r   envqueryresponseapi_hostnamezNo API host found)_SS_ENDPOINTSget_download_json	_SSMP_URLr   r   r   )selfdata_iddata_envkeyresult	json_datameta_url r/   K/home/ubuntu/.local/lib/python3.10/site-packages/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p&dvr*|}q|s3tddd	| |d
|d}|d }	|d}
|
rN|
dkrPd}
| j| d|
 d|	 |	d|d| j	dd}t
|drr| |	 |	|| j|d d| j|d d| t
|ddthf|	d| j|d d|
dkdS )N/r   simplestreamsidebarclass zCould not find video elementT)expectedzdata-idzdata-envz	data-uvidz	data-typevodshowz/api/z/stream/zDownloading stream JSONzdata-key)r+   platformr    drm)defaultr"   streamr   live)r   r   r   r   formatsr   r   )	_match_id
rpartition_download_webpager   r   r%   r   r1   r&   	_PLATFORMr   
report_drm_og_search_title_og_search_description_extract_m3u8_formatsr   _og_search_thumbnail)r(   r   r   webpage
video_dataelementshtml_tag
attributesendpoint_urluvid
video_typestream_datar/   r/   r0   _real_extractL   sJ   



zGBNewsIE._real_extract)__name__
__module____qualname__IE_DESC
_VALID_URLrC   r'   _TESTSr$   r1   rR   r/   r/   r/   r0   r	      sJ     r	   N)
commonr   utilsr   r   r   r   utils.traversalr   r	   r/   r/   r/   r0   <module>   s    