U
    g                     @   s(   d dl Z ddlmZ G dd deZdS )    N   )InfoExtractorc                   @   s"   e Zd ZdZdZdZdddZdS )OnceIEzhttps?://.+?\.unicornmedia\.com/now/(?:ads/vmap/)?[^/]+/[^/]+/(?P<domain_id>[^/]+)/(?P<application_id>[^/]+)/(?:[^/]+/)?(?P<media_item_id>[^/]+)/content\.(?:once|m3u8|mp4)zFhttp://once.unicornmedia.com/now/master/playlist/%s/%s/%s/content.m3u8zJhttp://once.unicornmedia.com/now/media/progressive/%s/%s/%s/%s/content.mp4Nc                 C   s   t tj| \}}}| j| j|||f |dddd}g }|D ]t}t dd|d |d< | jd|d d	d d
}	|	r@|	 }
|

| j|||	|f |d ddd|d ||
 q@| || || |S )NZmp4ZhlsF)Zm3u8_idfatalz\badsegmentlength=\d+zadsegmentlength=0urlz'/now/media/playlist/[^/]+/[^/]+/([^/]+)zredition id)default	format_idhttp)r   r   protocolZ
preference)rematchr   
_VALID_URLgroupsZ_extract_m3u8_formatsADAPTIVE_URL_TEMPLATEsubZ_search_regexcopyupdatePROGRESSIVE_URL_TEMPLATEreplaceappendZ_check_formatsextend)selfr   Zhttp_formats_preferenceZ	domain_idZapplication_idZmedia_item_idformatsZprogressive_formatsZadaptive_formatZrendition_idZprogressive_format r   9/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/once.py_extract_once_formats   s`                  
zOnceIE._extract_once_formats)N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s   r   )r   commonr   r   r   r   r   r   <module>   s   