U
    g
"                     @   sT   d dl Z ddlmZ ddlmZmZmZmZmZ G dd deZ	G dd	 d	eZ
dS )
    N   )InfoExtractor   )
clean_htmlint_or_nonetry_getunified_strdateunified_timestampc                   @   s   e Zd ZdZdddddddd	d
d
ddddddddedddidddddddddddddddd d!dedd"ddidd#dd$d%dd$d&dd$d'dd$d(dd$gZd)d* Zd+S ),AmericasTestKitchenIEzhttps?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?:cooks(?:country|illustrated)/)?(?P<resource_type>episode|videos)/(?P<id>\d+)zJhttps://www.americastestkitchen.com/episode/582-weeknight-japanese-suppersZ b861c3e365ac38ad319cfd509c30577fZ5b400b9ee338f922cb06450czJapanese SuppersZmp4zweeknight-japanese-suppersz$md5:64e606bfee910627efc4b5f050de92b3i@ZZ20180409America's Test Kitchenz	Season 18      i`  zre:^https?://r   )idtitleext
display_iddescription	timestampupload_daterelease_dateseriesseasonepisodeseason_numberepisode_numberduration	thumbnailaverage_rating
view_countZskip_downloadT)urlmd5	info_dictparamszEhttps://www.americastestkitchen.com/episode/705-simple-chicken-dinnerZ 06451608c57651e985a498e69cec17e5Z5fbe8c61bda2010001c6763bzSimple Chicken Dinnerz5atktv_2103_simple-chicken-dinner_full-episode_web-mp4z$md5:eb68737cc2fd4c26ca7db30139d109e7i0`Z20210115z	Season 21      iu  )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zAhttps://www.americastestkitchen.com/videos/3420-pan-seared-salmonr   Zonly_matchingzXhttps://www.americastestkitchen.com/cookscountry/episode/564-when-only-chocolate-will-dozPhttps://www.americastestkitchen.com/cooksillustrated/videos/4478-beef-wellingtonzDhttps://www.cookscountry.com/episode/564-when-only-chocolate-will-doz<https://www.cooksillustrated.com/videos/4478-beef-wellingtonc                 C   s   |  | \}}|dk}|r"d}| d| d| |}|rF|d n|}|rR|n|dp^i }dd|d d	t|d
t|dt|dt|dt|dt	|dd |dd
S )Nr   Zepisodesz+https://www.americastestkitchen.com/api/v6//videoZurl_transparentzlhttps://player.zype.com/embed/{}.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQZzypeIdZZyper   ZpublishDatenumberr   c                 S   s   | d d S )Nshowr    )xr*   r*   H/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/americastestkitchen.py<lambda>g       z5AmericasTestKitchenIE._real_extract.<locals>.<lambda>r   )
_typer   ie_keyr   r   r   r   r   r   r   )
_match_valid_urlgroups_download_jsongetformatr   r	   r   r   r   )selfr   Zresource_typeZvideo_idZ
is_episoderesourcer'   r   r*   r*   r,   _real_extractS   s*     z#AmericasTestKitchenIE._real_extractN)__name__
__module____qualname__
_VALID_URLint_TESTSr8   r*   r*   r*   r,   r
      s     Dr
   c                   @   s   e Zd ZdZdddddddd	d
ddddddddddddddddddddddddddddddg	Zdd ZdS )AmericasTestKitchenSeasonIEzhttps?://(?:www\.)?(?P<show>americastestkitchen|(?P<cooks>cooks(?:country|illustrated)))\.com(?:(?:/(?P<show2>cooks(?:country|illustrated)))?(?:/?$|(?<!ated)(?<!ated\.com)/episodes/browse/season_(?P<season>\d+)))z<https://www.americastestkitchen.com/episodes/browse/season_1Zseason_1zSeason 1)r   r      )r   r!   Zplaylist_countzJhttps://www.americastestkitchen.com/cookscountry/episodes/browse/season_12Z	season_12z	Season 12z$https://www.americastestkitchen.com/americastestkitchenr   i.  z0https://www.americastestkitchen.com/cookscountrycookscountryCook's Country   z1https://www.americastestkitchen.com/cookscountry/Tr%   z6https://www.cookscountry.com/episodes/browse/season_12zhttps://www.cookscountry.comz5https://www.americastestkitchen.com/cooksillustrated/z https://www.cooksillustrated.comc           	   	      s   |  |ddd\ }}|r&d| nd|p0|}t  dddd	| \}d
d g} rd  }d  }|d|  n|}|}| jd d|ddddt|d ddddd fdd}| | ||S )Nr   r)   Zshow2r&    )Zatkr   )ZccorC   )ZciozCook's Illustrated)rA   rB   Zcooksillustratedzsearch_document_klass:episodezsearch_show_slug:Zseason_zSeason zsearch_season_list:z<https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_Z_season_desc_production#https://www.americastestkitchen.comZ 8d504d0099ed27c1b73708d22871d805Z
Y1FNZXUI30)ZOriginzX-Algolia-API-KeyzX-Algolia-Application-Idzdescription,search_zO_episode_number,search_document_date,search_url,title,search_atk_episode_seasoni  )ZfacetFiltersZattributesToRetrieveZattributesToHighlightZhitsPerPage)headersqueryc                  3   s    dpg D ]r} |  d}|s"qddp,d | t| dd |  d|  d	t|  d
 t|  d dt d	V  qd S )Nhits
search_urlr   rF   rE   c                 S   s   | d  dd S )NZobjectID_)split)er*   r*   r,   r-      r.   zLAmericasTestKitchenSeasonIE._real_extract.<locals>.entries.<locals>.<lambda>r   r   Zsearch_document_dateZsearch_Z_episode_number)	r/   r   r   r   r   r   r   r   r0   )r4   r   r	   r   r
   r0   )r   rJ   r   Zseason_searchZ	show_pathZslugr*   r,   entries   s    
z:AmericasTestKitchenSeasonIE._real_extract.<locals>.entries)r1   groupr   appendr3   jsondumpsZplaylist_result)	r6   r   Zshow1r)   r   Zfacet_filtersZplaylist_idZplaylist_titlerP   r*   rO   r,   r8      sL    



  z)AmericasTestKitchenSeasonIE._real_extractN)r9   r:   r;   r<   r>   r8   r*   r*   r*   r,   r?   l   sT   


	1r?   )rS   commonr   utilsr   r   r   r   r	   r
   r?   r*   r*   r*   r,   <module>   s   	_