]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/americastestkitchen.py
3 from .common
import InfoExtractor
13 class AmericasTestKitchenIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?americastestkitchen\.com/(?:cooks(?:country|illustrated)/)?(?P<resource_type>episode|videos)/(?P<id>\d+)'
16 'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers',
17 'md5': 'b861c3e365ac38ad319cfd509c30577f',
19 'id': '5b400b9ee338f922cb06450c',
20 'title': 'Japanese Suppers',
22 'display_id': 'weeknight-japanese-suppers',
23 'description': 'md5:64e606bfee910627efc4b5f050de92b3',
24 'timestamp': 1523304000,
25 'upload_date': '20180409',
26 'release_date': '20180409',
27 'series': 'America\'s Test Kitchen',
28 'season': 'Season 18',
29 'episode': 'Japanese Suppers',
33 'thumbnail': r
're:^https?://',
38 'skip_download': True,
41 # Metadata parsing behaves differently for newer episodes (705) as opposed to older episodes (582 above)
42 'url': 'https://www.americastestkitchen.com/episode/705-simple-chicken-dinner',
43 'md5': '06451608c57651e985a498e69cec17e5',
45 'id': '5fbe8c61bda2010001c6763b',
46 'title': 'Simple Chicken Dinner',
48 'display_id': 'atktv_2103_simple-chicken-dinner_full-episode_web-mp4',
49 'description': 'md5:eb68737cc2fd4c26ca7db30139d109e7',
50 'timestamp': 1610737200,
51 'upload_date': '20210115',
52 'release_date': '20210115',
53 'series': 'America\'s Test Kitchen',
54 'season': 'Season 21',
55 'episode': 'Simple Chicken Dinner',
59 'thumbnail': r
're:^https?://',
64 'skip_download': True,
67 'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon',
68 'only_matching': True,
70 'url': 'https://www.americastestkitchen.com/cookscountry/episode/564-when-only-chocolate-will-do',
71 'only_matching': True,
73 'url': 'https://www.americastestkitchen.com/cooksillustrated/videos/4478-beef-wellington',
74 'only_matching': True,
77 def _real_extract(self
, url
):
78 resource_type
, video_id
= self
._match
_valid
_url
(url
).groups()
79 is_episode
= resource_type
== 'episode'
81 resource_type
= 'episodes'
83 resource
= self
._download
_json
(
84 'https://www.americastestkitchen.com/api/v6/%s/%s' % (resource_type
, video_id
), video_id
)
85 video
= resource
['video'] if is_episode
else resource
86 episode
= resource
if is_episode
else resource
.get('episode') or {}
89 '_type': 'url_transparent',
90 'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video
['zypeId'],
92 'description': clean_html(video
.get('description')),
93 'timestamp': unified_timestamp(video
.get('publishDate')),
94 'release_date': unified_strdate(video
.get('publishDate')),
95 'episode_number': int_or_none(episode
.get('number')),
96 'season_number': int_or_none(episode
.get('season')),
97 'series': try_get(episode
, lambda x
: x
['show']['title']),
98 'episode': episode
.get('title'),
102 class AmericasTestKitchenSeasonIE(InfoExtractor
):
103 _VALID_URL
= r
'https?://(?:www\.)?americastestkitchen\.com(?P<show>/cookscountry)?/episodes/browse/season_(?P<id>\d+)'
106 'url': 'https://www.americastestkitchen.com/episodes/browse/season_1',
111 'playlist_count': 13,
113 # Cooks Country Season
114 'url': 'https://www.americastestkitchen.com/cookscountry/episodes/browse/season_12',
117 'title': 'Season 12',
119 'playlist_count': 13,
122 def _real_extract(self
, url
):
123 show_path
, season_number
= self
._match
_valid
_url
(url
).group('show', 'id')
124 season_number
= int(season_number
)
126 slug
= 'cco' if show_path
== '/cookscountry' else 'atk'
128 season
= 'Season %d' % season_number
130 season_search
= self
._download
_json
(
131 'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_%s_season_desc_production' % slug
,
133 'Origin': 'https://www.americastestkitchen.com',
134 'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805',
135 'X-Algolia-Application-Id': 'Y1FNZXUI30',
137 'facetFilters': json
.dumps([
138 'search_season_list:' + season
,
139 'search_document_klass:episode',
140 'search_show_slug:' + slug
,
142 'attributesToRetrieve': 'description,search_%s_episode_number,search_document_date,search_url,title' % slug
,
143 'attributesToHighlight': '',
148 for episode
in (season_search
.get('hits') or []):
149 search_url
= episode
.get('search_url') # always formatted like '/episode/123-title-of-episode'
154 'url': f
'https://www.americastestkitchen.com{show_path or ""}{search_url}',
155 'id': try_get(episode
, lambda e
: e
['objectID'].split('_')[-1]),
156 'title': episode
.get('title'),
157 'description': episode
.get('description'),
158 'timestamp': unified_timestamp(episode
.get('search_document_date')),
159 'season_number': season_number
,
160 'episode_number': int_or_none(episode
.get('search_%s_episode_number' % slug
)),
161 'ie_key': AmericasTestKitchenIE
.ie_key(),
164 return self
.playlist_result(
165 entries(), 'season_%d' % season_number
, season
)