o
    i                     @   sp   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
mZ G dd deZG dd	 d	eZG d
d deZdS )    N   )InfoExtractor   )filter_dictfloat_or_noneint_or_noneparse_age_limitsmuggle_urltraverse_objunsmuggle_urlurl_or_nonec                   @   s$   e Zd ZddeejdZdS )CineverseBaseIEzhttps?://www\.(?P<host>{})|)zcineverse.comzasiancrush.comzdovechannel.comzscreambox.comzmidnightpulp.comz
fandor.comzretrocrush.tvN)	__name__
__module____qualname__formatjoinmapreescape_VALID_URL_BASE r   r   N/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/cineverse.pyr      s    r   c                   @   sl   e Zd Zej dZddddddg dd	d
ddddddddddg dddddddddgZdd ZdS )CineverseIEz/watch/(?P<id>[A-Z0-9]+)z<https://www.asiancrush.com/watch/DMR00018919/Women-Who-Flirtzgeo-blockedzWomen Who Flirtmp4DMR00018919l   9]9)zXun ZhouzXiaoming Huangz
Yi-Lin Siez	Sonia Sui	QunicirengԘ@z$md5:892fd62a05611d394141e8394ace0bc6   )titleextidmodified_timestampcastdurationdescription	age_limit)urlskip	info_dictzFhttps://www.retrocrush.tv/watch/1000000023016/Archenemy! Crystal BowiezArchenemy! Crystal Bowie1000000023016   r   )zNachi NozawazYoshiko SakakibarazToshiko Fujitar   z	Episode 3zSeason 1gT㥛D4@z@Cobra meets a beautiful bounty hunter by the name of Jane Royal.)Space Adventure COBRA (Original Japanese))r   r    r!   episode_numberseason_numberr#   r&   episodeseasonr$   r%   seriesc                 C   s  t |i d\}}| d|di | |}| ||}| ||d d d }|d}|dkr7|   n|d	krE| jd
|dd tdt	|ddt
hifpRd i| |d |dt	|ddddtddhfdddd hfdddddthfddthfddthfdd thfd!d"
S )#N)default	countriesgeo_countriesprops	pagePropsidetailserr_codei  i  zThis video is not available from your location due to geo restriction. You may be able to bypass it by using the /details/ page instead of the /watch/ page)r3   en)
cc_url_vttsubtitle_urlr'   )	subtitlesformatsr   )detailsitem_id)r>   r%   r$   i  )scaler>   r#   c                 S   
   |  dS Nz, splitxr   r   r   <lambda>Z      
 z+CineverseIE._real_extract.<locals>.<lambda>
updated_byr   update_timetimer0   r/   rating_code)r>   series_detailsr   )
r   r!   r%   r$   r#   r"   r.   r-   r&   r1   )r   _initialize_geo_bypassget	_match_id_download_webpage_search_nextjs_dataraise_login_requiredraise_geo_restrictedr   r
   r   _extract_m3u8_formatsr   r   r   )selfr'   smuggled_datavideo_idhtmlr7   r8   r   r   r   _real_extract>   sB   






zCineverseIE._real_extractNr   r   r   r   r   
_VALID_URL_TESTSrZ   r   r   r   r   r      s@     r   c                	   @   sN   e Zd Zej dZdddddddd	d
ddg ddddgZdd ZdS )CineverseDetailsIEz/details/(?P<id>[A-Z0-9]+)zYhttps://www.retrocrush.tv/details/1000000023012/Space-Adventure-COBRA-(Original-Japanese)   r,   1000000023012)r   r!   )r'   playlist_mincountr)   z=https://www.asiancrush.com/details/NNVG4938/Hansel-and-GretelNNVG4938r   zHansel and Gretelz$md5:e3e4c35309c2e82aee044f972c2fb05d)zJeong-myeong CheonzEun Won-jaezShim Eun-gyeongz
Ji-hee JinzHee-soon Parkz
Lydia ParkzKyeong-ik KimgZdv@)r!   r    r   r%   r#   r$   )r'   r)   c                    s    |dd\}||}||d d }t|dddd hf t|d	d
k fddt|ddddd f}|rUjfdd|D |t|ddS |d S )Nhostr!   r5   r6   itemDetailsDatageo_countryc                 S   rA   rB   rC   rE   r   r   r   rG   ~   rH   z2CineverseDetailsIE._real_extract.<locals>.<lambda>)rd   playback_err_msgz-This title is not available in your location.c                    s<   d d| d  d| d  }rt |d i}|tS )Nzhttps://www.z/watch/r?   /r   r4   )r	   
url_resultr   )itemitem_url)r4   
geoblockedrc   rV   r   r   item_result   s   z5CineverseDetailsIE._real_extract.<locals>.item_resultseasonEpisodes.episodesc                 S   s   |d o|d S )Nr?   r   r   )_vr   r   r   rG      s    c                    s   g | ]} |qS r   r   ).0ep)rl   r   r   
<listcomp>   s    z4CineverseDetailsIE._real_extract.<locals>.<listcomp>)rd   r   )playlist_idplaylist_title)_match_valid_urlgrouprQ   rR   r
   playlist_result)rV   r'   	series_idrY   	pagepropsr0   r   )r4   rk   rc   rl   rV   r   rZ   y   s   z CineverseDetailsIE._real_extractNr[   r   r   r   r   r^   d   s&    r^   )r   commonr   utilsr   r   r   r   r	   r
   r   r   r   r   r^   r   r   r   r   <module>   s    (H