a
    hd1                     @   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=%sZ+Hh9O7M8ks5yi6nSROL7bKYz933rdf3GhwZlTLMgvy4QZ+kW020K2jq2lk2eKRJD2vWEg832ncx2EivZlTLQput2CZ A5Nn9GGb326CI7vP5e27d7E4PIaQjotaZ C6D585FD1615272C98DE38235F38BD86Z+VJwfFuSGnLKnd9Phe9y96WkXgYDCguPMJ2dLhGMb2REZ+F96WlOd8yoFmLQgiqv6fNQRvHZcsWk5jDaYnDvhbiJkZ+LWk29hfiU39NNdq87ePeRach3nzTSV20o0lTv2001CdZ PRSGmDMsg6QMGc04Obpoy7Vsbn7i2Whp)cieloZhotclubmtv8Z
salesforceZsitocommercialer   skyarteZ
theupfrontc                 C   s   |  | j|| jf t |S N)
url_result_PLAYER_TMPL_DOMAINSkyItPlayerIEZie_key)selfvideo_id r   K/mnt/pikpak/tmp/myenv/lib/python3.9/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 }|sH| |r4dndrH| jdgd	 | ||d
}|| d|t|d| dpvd t| dt| dpt| d|dS )NtypeZliveZ	streamingZhls_urlZgeoblockZgeobZIT)Z	countriesmp4title)Zvideo_stillZvideo_still_mediumZthumbZ
short_descZcreate_dateZduration_secduration)idr   formats	thumbnaildescription	timestampr    is_live)getZraise_geo_restrictedZ_extract_m3u8_formatsr   r	   r   r   )r   videor   r&   Zhls_urlr"   r   r   r   _parse_video%   s    zSkyItBaseIE._parse_videoN)	__name__
__module____qualname__Z_GEO_BYPASSr   r   
_TOKEN_MAPr   r)   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)Zcallerr!   token)queryheaders)	_match_idurllibparseparse_qsurlparser0   r'   r   r-   _download_jsonZgeo_verification_headersr)   )r   urlr   r.   r/   r(   r   r   r   _real_extract=   s&    
zSkyItPlayerIE._real_extractN)r*   r+   r,   IE_NAME
_VALID_URLr9   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-631227Z 5b858a62d9ffe2ab77b397553024184a631227r   &Uomo ucciso da uno squalo in Australia*_20201122   Dhttps://video.sky.it/captures/thumbs/631227/631227_thumb_880x494.jpgr!   extr   r%   upload_dater    r#   skip_downloadm3u8r8   md5	info_dictparamszDhttps://xfactor.sky.it/video/x-factor-2020-replay-audizioni-1-615820T)r8   Zonly_matchingzWhttps://masterchef.sky.it/video/masterchef-9-cosa-e-successo-nella-prima-puntata-562831c                 C   s   |  |}| |S r   )r2   r   )r   r8   r   r   r   r   r9   d   s    
zSkyItVideoIE._real_extractN)r*   r+   r,   r:   r;   _TESTSr9   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1r   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!   rD   r   r$   live_statusrF   Tr8   rJ   rK   c                 C   sZ   |  |}| ||}t| ||d d d d d }| jd|d|id}| ||S )	NpropsZinitialStateZlivePagecontentasset_id(https://apid.sky.it/vdp/v1/getLivestreamr!   r0   )r2   _download_webpagestr_search_nextjs_datar7   r)   )r   r8   
display_idwebpagerS   
livestreamr   r   r   r9   {   s    
$zSkyItVideoLiveIE._real_extractN)r*   r+   r,   r:   r;   Z_TESTr9   r   r   r   r   rM   i   s   	rM   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-newsZ789222r   z9Brozovic con il gruppo: verso convocazione per Juve-InterZ20221103icc   zUhttps://videoplatform.sky.it/still/2022/11/03/1667480526353_brozovic_videostill_1.jpgr!   rD   r   rE   r%   r    r#   rF   rG   rP   zAhttps://tg24.sky.it/mondo/2020/11/22/australia-squalo-uccide-uomoZ fe5c91e59a84a3437eaa0bca6e134ccdr=   r>   r?   r@   rA   rB   rC   rH   zdata-videoid="(\d+)"c                 C   s0   |  |}| ||}| | j|d}| |S )Nzvideo id)r2   rV   Z_search_regex_VIDEO_ID_REGEXr   )r   r8   rY   rZ   r   r   r   r   r9      s    
zSkyItIE._real_extractN)r*   r+   r,   r:   r;   rL   r_   r9   r   r   r   r   r\      s8   		r\   c                
   @   s@   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-788962Z 515aee97b87d7a018b6c80727d3e7e17Z788962r   z2La fotografia di Oliviero Toscani conquista TorinoZ20221102i<bc   zwhttps://videoplatform.sky.it/still/2022/11/02/1667396388552_oliviero-toscani-torino-galleria-mazzoleni_videostill_1.jpgr^   rF   rG   rH   r   zU"embedUrl"\s*:\s*"(?:https:)?//player\.sky\.it/player/external\.html\?[^"]*\bid=(\d+)Nr*   r+   r,   r:   r;   rL   r   r_   r   r   r   r   r`      s    	r`   c                
   @   s@   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 )CieloTVItIEz
cielotv.itz8https?://(?:www\.)?cielotv\.it/video/(?P<id>[^.]+)\.htmlz>https://www.cielotv.it/video/Il-lunedi-e-sempre-un-dramma.htmlZ c4deed77552ba901c2a0d9258320304bZ499240r   u   Il lunedì è sempre un drammaZ20190329i"\   z_https://videoplatform.sky.it/still/2019/03/29/1553858575610_lunedi_dramma_mant_videostill_1.jpgr^   rF   rG   rH   r   zvideoId\s*=\s*"(\d+)"Nrb   r   r   r   r   rc      s    	rc   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-630529Z 9ab906a3f75ea342ed928442f9dabd21Z630529r   z/Ogni mattina - Ucciso asino di Andrea Lo Ciceroi]_Z20201118r   zzhttps://videoplatform.sky.it/still/2020/11/18/1605717753954_ogni-mattina-ucciso-asino-di-andrea-lo-cicero_videostill_1.jpgrC   rF   rG   rH   zhttps://www.tv8.it/video/964361Z 1e58e807154658a16edc29e45be38107Z964361zGialappaShow - S.4 Ep.2z$md5:60bb4ff5af18bbeeaedabc1de5f9e1e2i^  z^https://videoplatform.sky.it/captures/494/2024/11/06/964361/964361_1730888412914_thumb_494.jpgi{=*gZ20241105)r!   rD   r   r$   r    r#   r%   rE   )r8   rI   rJ   r   N)r*   r+   r,   r:   r;   rL   r   r   r   r   r   re      s8   	re   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tv8r   Tr&   )r!   rD   r   r$   r&   rO   )r8   rJ   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 )Nrh   rT   zDownloading manifest JSONr!   7rU   zhttps://tv8.it/api/getStreamingF)fatalinfor   textr$   html)r   r$   )r7   r)   r   rW   r   )r   r8   r   r[   metadatar   r   r   r9     s    


zTV8ItLiveIE._real_extractN)	r*   r+   r,   r:   IE_DESCr;   rW   rL   r9   r   r   r   r   rg      s   rg   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!   r   r$   r#   )r8   Zplaylist_mincountrJ   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 )NrQ   Z	pagePropsdatac                    s^   g | ]V} 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hrefZieZ	extraDataZ	videoDescrS   imagesrcr   Z
typographyrl   )r$   r!   r#   r   )r   r   re   r   rW   r
   ).0cardr   r   r   
<listcomp>3  s   


z1TV8ItPlaylistIE._real_extract.<locals>.<listcomp>ZlastContentZcardsc                 S   s   |d S )Nrt   r   )_vr   r   r   <lambda>;      z/TV8ItPlaylistIE._real_extract.<locals>.<lambda>rx   Zdesktopr$   rm   ru   rv   r   rl   )r$   r#   r   )r2   rV   rX   r   Zplaylist_resultr   r
   rW   )r   r8   Zplaylist_idrZ   rs   entriesr   ry   r   r9   /  s    





zTV8ItPlaylistIE._real_extractN)r*   r+   r,   r:   ro   r;   rL   r9   r   r   r   r   rp     s*   
rp   )urllib.parser3   commonr   utilsr   r   r   r   r	   r
   r   Zutils.traversalr   r   r   r<   rM   r\   r`   rc   re   rg   rp   r   r   r   r   <module>   s   $	)'! 