o
    id1                     @   s   d dl ZddlmZ ddlmZmZmZmZm	Z	m
Z
mZ ddlmZ G dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )    N   )InfoExtractor   )
clean_htmldict_getint_or_noneparse_durationunified_timestampurl_or_noneurljoin)traverse_objc                	   @   s>   e Zd ZdZdZdZdddddd	d
ddZdd Zdd ZdS )SkyItBaseIEFskyz:https://player.sky.it/player/external.html?id=%s&domain=%s+Hh9O7M8ks5yi6nSROL7bKYz933rdf3GhwZlTLMgvy4Q+kW020K2jq2lk2eKRJD2vWEg832ncx2EivZlTLQput2C A5Nn9GGb326CI7vP5e27d7E4PIaQjota C6D585FD1615272C98DE38235F38BD86+VJwfFuSGnLKnd9Phe9y96WkXgYDCguPMJ2dLhGMb2RE+F96WlOd8yoFmLQgiqv6fNQRvHZcsWk5jDaYnDvhbiJk+LWk29hfiU39NNdq87ePeRach3nzTSV20o0lTv2001Cd PRSGmDMsg6QMGc04Obpoy7Vsbn7i2Whp)cielohotclubmtv8
salesforcesitocommercialer   skyarte
theupfrontc                 C   s   |  | j|| jf t |S N)
url_result_PLAYER_TMPL_DOMAINSkyItPlayerIEie_key)selfvideo_id r&   J/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/skyit.py_player_url_result    s   zSkyItBaseIE._player_url_resultc              
   C   s   | ddk}| |rdndd }|s$| |rdndr$| jdgd	 | ||d
}|| d|t|d| dp;d t| dt| dpNt| d|dS )Ntypelive	streaminghls_urlgeoblockgeobIT)	countriesmp4title)video_stillvideo_still_mediumthumb
short_desccreate_dateduration_secduration)idr3   formats	thumbnaildescription	timestampr:   is_live)getraise_geo_restricted_extract_m3u8_formatsr   r	   r   r   )r$   videor%   r@   hls_urlr<   r&   r&   r'   _parse_video%   s   zSkyItBaseIE._parse_videoN)	__name__
__module____qualname___GEO_BYPASSr!   r    
_TOKEN_MAPr(   rF   r&   r&   r&   r'   r      s    r   c                   @   s   e Zd ZdZdZdd ZdS )r"   zplayer.sky.itzNhttps?://player\.sky\.it/player/(?:external|social)\.html\?.*?\bid=(?P<id>\d+)c                 C   sh   |  |}tjtj|jdd gd }t| j|df}| j	d|d||d| 
 d}| ||S )Ndomainr   r   z'https://apid.sky.it/vdp/v1/getVideoData)callerr;   token)queryheaders)	_match_idurllibparseparse_qsurlparserO   rA   r   rK   _download_jsongeo_verification_headersrF   )r$   urlr%   rL   rN   rD   r&   r&   r'   _real_extract=   s&   
zSkyItPlayerIE._real_extractN)rG   rH   rI   IE_NAME
_VALID_URLrY   r&   r&   r&   r'   r"   9   s    r"   c                
   @   sP   e Zd ZdZdZddddddd	d
ddddidddddddgZdd ZdS )SkyItVideoIEzvideo.sky.itzVhttps?://(?:masterchef|video|xfactor)\.sky\.it(?:/[^/]+)*/video/[0-9a-z-]+-(?P<id>\d+)zShttps://video.sky.it/news/mondo/video/uomo-ucciso-da-uno-squalo-in-australia-631227 5b858a62d9ffe2ab77b397553024184a631227r2   &Uomo ucciso da uno squalo in Australia*_20201122   Dhttps://video.sky.it/captures/thumbs/631227/631227_thumb_880x494.jpgr;   extr3   r?   upload_dater:   r=   skip_downloadm3u8rX   md5	info_dictparamszDhttps://xfactor.sky.it/video/x-factor-2020-replay-audizioni-1-615820T)rX   only_matchingzWhttps://masterchef.sky.it/video/masterchef-9-cosa-e-successo-nella-prima-puntata-562831c                 C   s   |  |}| |S r   )rQ   r(   )r$   rX   r%   r&   r&   r'   rY   d   s   

zSkyItVideoIE._real_extractN)rG   rH   rI   rZ   r[   _TESTSrY   r&   r&   r&   r'   r\   L   s.    	r\   c                   @   s8   e Zd ZdZdZddddddd	d
didZdd ZdS )SkyItVideoLiveIEzvideo.sky.it:livez0https?://video\.sky\.it/diretta/(?P<id>[^/?&#]+)z!https://video.sky.it/diretta/tg241r2   z-re:Diretta TG24 \d{4}-\d{2}-\d{2} \d{2}:\d{2}z~re:(?:Clicca play e )?[Gg]uarda la diretta streaming di SkyTg24, segui con Sky tutti gli appuntamenti e gli speciali di Tg24\.r@   )r;   re   r3   r>   live_statusrg   TrX   rk   rl   c                 C   sZ   |  |}| ||}t| ||d d d d d }| jd|d|id}| ||S )	NpropsinitialStatelivePagecontentasset_id(https://apid.sky.it/vdp/v1/getLivestreamr;   rO   )rQ   _download_webpagestr_search_nextjs_datarV   rF   )r$   rX   
display_idwebpagerw   
livestreamr&   r&   r'   rY   {   s   
$zSkyItVideoLiveIE._real_extractN)rG   rH   rI   rZ   r[   _TESTrY   r&   r&   r&   r'   ro   i   s    	ro   c                   @   sb   e Zd ZdZdZddddddd	d
dddidddddddddddddidgZdZdd ZdS )SkyItIEzsky.itzNhttps?://(?:sport|tg24)\.sky\.it(?:/[^/]+)*/\d{4}/\d{2}/\d{2}/(?P<id>[^/?&#]+)zBhttps://sport.sky.it/calcio/serie-a/2022/11/03/brozovic-inter-news789222r2   z9Brozovic con il gruppo: verso convocazione per Juve-Inter20221103icc   zUhttps://videoplatform.sky.it/still/2022/11/03/1667480526353_brozovic_videostill_1.jpgr;   re   r3   rf   r?   r:   r=   rg   rh   rr   zAhttps://tg24.sky.it/mondo/2020/11/22/australia-squalo-uccide-uomo fe5c91e59a84a3437eaa0bca6e134ccdr^   r_   r`   ra   rb   rc   rd   ri   zdata-videoid="(\d+)"c                 C   s0   |  |}| ||}| | j|d}| |S )Nzvideo id)rQ   rz   _search_regex_VIDEO_ID_REGEXr(   )r$   rX   r}   r~   r%   r&   r&   r'   rY      s   

zSkyItIE._real_extractN)rG   rH   rI   rZ   r[   rn   r   rY   r&   r&   r&   r'   r      s:    		r   c                
   @   @   e Zd ZdZdZddddddd	d
ddddidgZdZdZdS )SkyItArteIEzarte.sky.itz-https?://arte\.sky\.it/video/(?P<id>[^/?&#]+)zKhttps://arte.sky.it/video/oliviero-toscani-torino-galleria-mazzoleni-788962 515aee97b87d7a018b6c80727d3e7e17788962r2   z2La fotografia di Oliviero Toscani conquista Torino20221102i<bc   zwhttps://videoplatform.sky.it/still/2022/11/02/1667396388552_oliviero-toscani-torino-galleria-mazzoleni_videostill_1.jpgr   rg   rh   ri   r   zU"embedUrl"\s*:\s*"(?:https:)?//player\.sky\.it/player/external\.html\?[^"]*\bid=(\d+)NrG   rH   rI   rZ   r[   rn   r!   r   r&   r&   r&   r'   r      "    	r   c                
   @   r   )CieloTVItIEz
cielotv.itz8https?://(?:www\.)?cielotv\.it/video/(?P<id>[^.]+)\.htmlz>https://www.cielotv.it/video/Il-lunedi-e-sempre-un-dramma.html c4deed77552ba901c2a0d9258320304b499240r2   u   Il lunedì è sempre un dramma20190329i"\   z_https://videoplatform.sky.it/still/2019/03/29/1553858575610_lunedi_dramma_mant_videostill_1.jpgr   rg   rh   ri   r   zvideoId\s*=\s*"(\d+)"Nr   r&   r&   r&   r'   r      r   r   c                   @   sX   e Zd ZdZdZddddddd	d
ddddidddddddddddddgZdZdS )TV8ItIEztv8.itzEhttps?://(?:www\.)?tv8\.it/(?:show)?video/(?:[0-9a-z-]+-)?(?P<id>\d+)zMhttps://www.tv8.it/video/ogni-mattina-ucciso-asino-di-andrea-lo-cicero-630529 9ab906a3f75ea342ed928442f9dabd21630529r2   z/Ogni mattina - Ucciso asino di Andrea Lo Ciceroi]_20201118r   zzhttps://videoplatform.sky.it/still/2020/11/18/1605717753954_ogni-mattina-ucciso-asino-di-andrea-lo-cicero_videostill_1.jpgrd   rg   rh   ri   zhttps://www.tv8.it/video/964361 1e58e807154658a16edc29e45be38107964361zGialappaShow - S.4 Ep.2z$md5:60bb4ff5af18bbeeaedabc1de5f9e1e2i^  z^https://videoplatform.sky.it/captures/494/2024/11/06/964361/964361_1730888412914_thumb_494.jpgi{=*g20241105)r;   re   r3   r>   r:   r=   r?   rf   )rX   rj   rk   r   N)rG   rH   rI   rZ   r[   rn   r!   r&   r&   r&   r'   r      s:    	r   c                   @   s:   e Zd ZdZdZdZdddeeddd	d
gZdd ZdS )TV8ItLiveIEztv8.it:livezTV8 Livez$https?://(?:www\.)?tv8\.it/streamingzhttps://tv8.it/streamingtv8r2   Tr@   )r;   re   r3   r>   r@   rq   )rX   rk   c                 C   s^   d}| j d|dddid}| j d|dd	}i | ||t|d
ddthfddthfdfS )Nr   rx   zDownloading manifest JSONr;   7ry   zhttps://tv8.it/api/getStreamingF)fatalinfor3   textr>   html)r3   r>   )rV   rF   r   r{   r   )r$   rX   r%   r   metadatar&   r&   r'   rY     s   


zTV8ItLiveIE._real_extractN)	rG   rH   rI   rZ   IE_DESCr[   r{   rn   rY   r&   r&   r&   r'   r      s    r   c                   @   sL   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gZdd ZdS )TV8ItPlaylistIEztv8.it:playlistzTV8 Playlistz;https?://(?:www\.)?tv8\.it/(?!video)[^/#?]+/(?P<id>[^/#?]+)z2https://tv8.it/intrattenimento/tv8-gialappas-night    ztv8-gialappas-nightzTv8 Gialappa's Nightz$md5:c876039d487d9cf40229b768872718edz/re:https://static\.sky\.it/.+\.(png|jpe?g|webp))r;   r3   r>   r=   )rX   playlist_mincountrk   z'https://tv8.it/sport/uefa-europa-league   zuefa-europa-leaguezUEFA Europa Leaguez$md5:9ab1832b7a8b1705b1f590e13a36bc6ac                    s     |} ||} ||d d d } fddt|dddd	 fD } j||fi t|d
dddthfddthfddthfdfS )Nrs   	pagePropsdatac                    s^   g | ]+} j td |d fdtit|ddthfddthfddthfdd	d
thfdqS )zhttps://tv8.ithrefie	extraData	videoDescrw   imagesrcr3   
typographyr   )r>   r;   r=   r3   )r   r   r   r   r{   r
   ).0cardr$   r&   r'   
<listcomp>3  s    



z1TV8ItPlaylistIE._real_extract.<locals>.<listcomp>lastContentcardsc                 S   s   |d S )Nr   r&   )_vr&   r&   r'   <lambda>;  s    z/TV8ItPlaylistIE._real_extract.<locals>.<lambda>r   desktopr>   r   r   r   r3   r   )r>   r=   r3   )rQ   rz   r|   r   playlist_resultr   r
   r{   )r$   rX   playlist_idr~   r   entriesr&   r   r'   rY   /  s   





zTV8ItPlaylistIE._real_extractN)rG   rH   rI   rZ   r   r[   rn   rY   r&   r&   r&   r'   r     s,    
r   )urllib.parserR   commonr   utilsr   r   r   r   r	   r
   r   utils.traversalr   r   r"   r\   ro   r   r   r   r   r   r   r&   r&   r&   r'   <module>   s    $	)'! 