U
    $Pf                     @   s@   d dl mZ ddlmZ ddlmZmZmZ G dd deZdS )	    )unicode_literals   )InfoExtractor   )ExtractorErrorint_or_noneurl_or_nonec                   @   s&   e Zd ZdZddddgZdd ZdS )	CamModelsIEz6https?://(?:www\.)?cammodels\.com/cam/(?P<id>[^/?#&]+)z+https://www.cammodels.com/cam/AutumnKnight/T   )urlZonly_matching	age_limitc                 C   s  |  |}| j|||  d}| jd|dd d}|snd}|D ]\}}||kr<|}d}	 qbq<d}d}	t||	d	| d
||f |}
g }|
d  D ]\}}t|tsq|	d}t|t
sq|	d}|	d}|D ]}t|tsqt|	d}|sq|g}t|	d}|d k	r&|d|  |d|t|	d|t|	dt|	dt|	d||d	}d|krd|d< nd|kr|ddd nq|| qq| | || |d|dd S )!N)headerszmanifestUrlRoot=([^&\']+)manifest)default))z%I'm offline, but let's stay connectedzThis user is currently offline)zin a private showzThis user is in a private show)zis currently performing LIVEz'This model is currently performing liveTz Unable to find manifest URL rootF)expectedz	%s%s.jsonformats	encodingsZ
videoCodecZ
audioCodeclocationZvideoHeightz%dp-Z
videoWidthZ	videoKbpsZ	audioKbpsfps)	r   	format_idwidthheightZvbrZabrr   vcodecacodecZrtmpZflvextZhlsZmp4)r   Z
preferencer
   )idtitleZis_liver   r   )Z	_match_idZ_download_webpageZgeo_verification_headersZ_html_search_regexr   Z_download_jsonitems
isinstancedictgetlistr   r   appendjoinupdateZ_sort_formatsZ_live_title)selfr   Zuser_idZwebpageZmanifest_rootZERRORSpatternmessageerrorr   r   r   r   Zformat_dictr   r   r   ZmediaZ	media_urlZformat_id_listr   f r,   B/tmp/pip-unpacked-wheel-7zdooeg3/youtube_dl/extractor/cammodels.py_real_extract   s    
     
 










zCamModelsIE._real_extractN)__name__
__module____qualname__Z
_VALID_URLZ_TESTSr.   r,   r,   r,   r-   r	      s   r	   N)	
__future__r   commonr   utilsr   r   r   r	   r,   r,   r,   r-   <module>   s   