o
    i                     @   sD   d dl Z ddlmZ ddlmZmZmZmZmZ G dd deZ	dS )    N   )InfoExtractor   )extract_attributesint_or_nonejoin_nonemptyparse_iso8601try_getc                   @   s   e Zd ZdZde 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ddddddddgZdddddddddddgdgZddgdfg d d!fgZed"d# Z	d$d% Z
d&S )'ArcPublishingIEz([\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12}z%arcpublishing:(?P<org>[a-z]+):(?P<id>)z6arcpublishing:adn:8c99cb6e-b29c-4bc9-9173-7bf9979225abT)urlonly_matchingz>arcpublishing:bostonglobe:232b7ae6-7d73-432d-bc0a-85dbf0119ab1z6arcpublishing:cmg:cfb1cf1b-3ab5-4d1b-86c5-a5515d311f2az=arcpublishing:elcomercio:27a7e1f8-2ec7-4177-874f-a4feed2885b3z6arcpublishing:gmg:c8793fb2-8d44-4242-881e-2db31da2d9fez7arcpublishing:gray:0b0ba30e-032a-4598-8810-901d70e6033ez>arcpublishing:gruponacion:dfcbfa57-527f-45ff-a69b-35fe71054143z6arcpublishing:mco:aa0ca6fe-1127-46d4-b32c-be0d6fdb8055z?arcpublishing:mentormedier:47a12084-650b-4011-bfd0-3699b6947b2dz9arcpublishing:raycom:b89f61f8-79fa-4c09-8255-e64237119bf7z7arcpublishing:tgam:411b34c1-8701-4036-9831-26964711664bz8arcpublishing:tronc:460f2931-8130-4719-8ea1-ffcb2d7cb685zdhttps://www.uppermichiganssource.com/2025/07/18/scattered-showers-storms-bring-heavy-rain-potential/z$508116f7-e999-48db-b7c2-60a04842679bmp4z5Scattered showers & storms bring heavy rain potentiali  zre:https?://.+\.jpgizh20250718)idexttitledescriptionduration	thumbnail	timestampupload_datez2Ignoring subtitle tracks found in the HLS manifest)r   	info_dictexpected_warningscmgprisaz.%s-config-prod.api.cdn.arcpublishing.com/video)adnadvancelocalanswersbonnierbostonglobedemogmggruponacioninfobaemconzmepmnraycom	spectatortbttgamtroncwapowweekz&video-api-cdn.%s.arcpublishing.com/apic                 C   sb   g }t dtj d|D ]!}t|pi }|d}|d}|r.|r.|d| d|  q|S )Nz4(<div[^>]+class="[^"]*\bpowa\b[^"]*"[^>]+data-uuid="z"[^>]*>)zdata-orgz	data-uuidzarcpublishing::)refindallr
   _UUID_REGEXr   getappend)clsr   webpageentriespowa_elpowaorguuid r<   R/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/arcpublishing.py_extract_embed_urlsX   s   

z#ArcPublishingIE._extract_embed_urlsc                 C   s  |  | \}}| jD ]\}}||v r|} nqd}|dkr!d}| jd||  |d|idd }|d d	 }|d
dk}	g }
g }|dg D ]}|d}|rU||
v rVqH|
| |d}|dkr| j||dd}|D ]6}|d drd|d< |d dsd|d  |d< t	|d t
r|d d |d< |d= d|d  |d< qn|| qH|dv r| j||d|	ddd}td d! |D rqH|D ]}|d"}|sq| jd#| |d dd d$}|rt||d< q|| qHt|d%}|t|||t|d&t|d"t|d'|d(d) qHi }t|d*d+ tpg D ]}|d}|r5|d,g d|i q ||t|d-d+ t|d.d+ |t|d/d0t|d1||	d2	S )3Nz+%s-prod-cdn.video-api.arcpublishing.com/apir-   washpostz"https://%s/v1/ansvideos/findByUuidr;   )queryr   	headlinesbasicstatuslivestreamsr   stream_typesmilF)fatalz/cfx/stzcfx/stapp	play_pathzmp4:tbri  vbrzrtmp-%d	format_id)tshlsr   rO   )rD   m3u8_idrH   c                 s   s    | ]
}| d dkV  qdS )acodecnoneN)r3   ).0fr<   r<   r=   	<genexpr>   s    z0ArcPublishingIE._real_extract.<locals>.<genexpr>heightz[_x]%d[_-](\d+))defaultbitratewidthfilesizei)rM   rL   rY   rV   rZ   r   qualityc                 S      | d d S )N	subtitlesurlsr<   xr<   r<   r=   <lambda>       z/ArcPublishingIE._real_extract.<locals>.<lambda>enc                 S   r\   )Npromo_imager   r<   r_   r<   r<   r=   ra      rb   c                 S   r\   )NsubheadlinesrB   r<   r_   r<   r<   r=   ra      rb   r   d   created_date)	r   r   r   r   formatsr   r   r]   is_live)_match_valid_urlgroups_POWA_DEFAULTS_download_jsonr3   r4   _extract_smil_formatsendswith
startswith
isinstancefloatextend_extract_m3u8_formatsall_search_regexintr   r   r	   list
setdefaultr   )selfr   r:   r;   orgstmplbase_api_tmplvideor   ri   r^   rh   ss_urlrF   smil_formatsrT   m3u8_formatsrV   rL   r]   subtitlesubtitle_urlr<   r<   r=   _real_extractd   s   







zArcPublishingIE._real_extractN)__name__
__module____qualname__r2   
_VALID_URL_TESTS_WEBPAGE_TESTSrl   classmethodr>   r   r<   r<   r<   r=   r
      sx    2

	
r
   )
r0   commonr   utilsr   r   r   r   r	   r
   r<   r<   r<   r=   <module>   s    	