U
    g                     @   s@   d dl Z ddlmZ ddlmZ ddlmZ G dd deZdS )	    N   )CloudflareStreamIE)InfoExtractor   )traverse_objc                	   @   sX   e Zd ZdZdddddddd	d
dddgdddddddgZdd Zdd ZdS )HytaleIEz>https?://(?:www\.)?hytale\.com/news/\d+/\d+/(?P<id>[a-z0-9-]+)z>https://hytale.com/news/2021/07/summer-2021-development-updatezsummer-2021-development-updatezSummer 2021 Development Update)idtitle   Z 0854ebe347d233ee19b86ab7b2ead610Z ed51a2609d21bad6e14145c37c334999Zmp4zAvatar Personalizationz;re:https://videodelivery\.net/\w+/thumbnails/thumbnail\.jpg)r   extr	   Z	thumbnail)md5	info_dict)urlr   playlist_countZplaylistz:https://www.hytale.com/news/2019/11/hytale-graphics-updatezhytale-graphics-updatezHytale graphics updater   )r   r   r   c                 C   sD   | j dd dddpd}t| d|dd dp.g }d	d
 |D | _d S )Nzhttps://hytale.com/mediazDownloading list of mediaF)Znotefatal z-window\.__INITIAL_COMPONENTS_STATE__\s*=\s*\[z
clips json)ZmediaZclipsc                 S   s   i | ]}| d | dqS )srccaption)get).0Zclip r   ;/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/hytale.py
<dictcomp>-   s      z-HytaleIE._real_initialize.<locals>.<dictcomp>)_download_webpager   Z_search_json_titles)selfZmedia_webpageZ
clips_jsonr   r   r   _real_initialize#   s(         zHytaleIE._real_initializec                    sD     |} ||} fddtd|D } || |S )Nc                    s.   g | ]&} j d | dt j|ddqS )zhttps://cloudflarestream.com/z9/manifest/video.mpd?parentOrigin=https%3A%2F%2Fhytale.comT)r	   Zurl_transparent)Z
url_resultr   r   r   )r   Z
video_hashr   r   r   
<listcomp>2   s   
 
 z*HytaleIE._real_extract.<locals>.<listcomp>zI<stream\s+class\s*=\s*"ql-video\s+cf-stream"\s+src\s*=\s*"([a-f0-9]{32})")Z	_match_idr   refindallZplaylist_resultZ_og_search_title)r   r   Zplaylist_idZwebpageentriesr   r   r   _real_extract/   s    

	zHytaleIE._real_extractN)__name__
__module____qualname__Z
_VALID_URLZ_TESTSr   r"   r   r   r   r   r      s.   r   )r   Zcloudflarestreamr   commonr   Zutils.traversalr   r   r   r   r   r   <module>   s   