3
b`G                 @   sH   d dl mZ d dlZddlmZ ddlmZmZmZ G dd deZ	dS )	    )unicode_literalsN   )InfoExtractor   )ExtractorErrorlowercase_escapeurl_or_nonec               @   sL   e Zd ZdZdddddddd	did
dddddddgZdZdd ZdS )ChaturbateIEzNhttps?://(?:[^/]+\.)?chaturbate\.com/(?:fullvideo/?\?.*?\bb=)?(?P<id>[^/?&#]+)z$https://www.chaturbate.com/siswet19/Zsiswet19mp4z:re:^siswet19 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$   T)idexttitle	age_limitis_liveskip_downloadzRoom is offline)url	info_dictparamsskipz*https://chaturbate.com/fullvideo/?b=caylin)r   only_matchingz#https://en.chaturbate.com/siswet19/zRoom is currently offlinec                s   | j |}| jd| || j d g }| j| jd dddd|tdd	}|rht|jd
}|rh|j| |sx(t	j
d D ]}|jt|jd qzW |sx$t	j
d D ]}|j|jd qW g }xB|D ]:}||jdd }	}
x"|	|
fD ]}||kr|j| qW qW |sl| jddg ddd d}|sRt fdd| jddfD rR| j}|rdt|ddtdg }xb|D ]Z}x&d#D ]}d| |kr|}P qW d }|j| j||d|dkrd$nd |ddd  qvW | j| || j|d!| | j d|d"S )%Nzhttps://chaturbate.com/%s/)headersz9initialRoomDossier\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1dataz{}value)defaultgroupF)transform_sourcefatalZ
hls_sourcez'(\\u002[27])(?P<url>http.+?\.m3u8.*?)\1r   z"(["\'])(?P<url>http.+?\.m3u8.*?)\1Z_fast z?<span[^>]+class=(["\'])desc_span\1[^>]*>(?P<error>[^<]+)</span>zA<div[^>]+id=(["\'])defchat\1[^>]*>\s*<p><strong>(?P<error>[^<]+)<error)r   r   c             3   s   | ]}| kV  qd S )N ).0p)webpager    KC:\Users\Broad\Desktop\All-Down\binaries\youtube_dl\extractor\chaturbate.py	<genexpr>P   s    z-ChaturbateIE._real_extract.<locals>.<genexpr>Zoffline_tippingZtip_offlineT)expectedzUnable to find stream URLfastslowz_%sr
   
   )r   
preferencem3u8_idr   livez1https://roomimg.stream.highwebmedia.com/ri/%s.jpg)r   r   	thumbnailr   r   formats)r'   r(   i)	_match_id_download_webpagegeo_verification_headers_parse_json_search_regexr   r   getappendrefinditerr   replaceany_ROOM_OFFLINEr   extend_extract_m3u8_formats_sort_formats_live_title_rta_search)selfr   video_idZfound_m3u8_urlsr   m3u8_urlmZ	m3u8_urlsZfound_m3u8_urlZm3u8_fast_urlZm3u8_no_fast_urlr   r.   Zknown_idr+   r    )r#   r$   _real_extract&   st    





zChaturbateIE._real_extractN)__name__
__module____qualname__
_VALID_URL_TESTSr:   rD   r    r    r    r$   r	      s   
r	   )

__future__r   r6   commonr   utilsr   r   r   r	   r    r    r    r$   <module>   s   