2 from __future__ import unicode_literals
7 from .common import InfoExtractor
17 class AmericasTestKitchenIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?P<resource_type>episode|videos)/(?P<id>\d+)'
20 'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers',
21 'md5': 'b861c3e365ac38ad319cfd509c30577f',
23 'id': '5b400b9ee338f922cb06450c',
24 'title': 'Japanese Suppers',
26 'description': 'md5:64e606bfee910627efc4b5f050de92b3',
27 'thumbnail': r're:^https?://',
28 'timestamp': 1523318400,
29 'upload_date': '20180410',
30 'release_date': '20180410',
31 'series': "America's Test Kitchen",
33 'episode': 'Japanese Suppers',
37 'skip_download': True,
40 # Metadata parsing behaves differently for newer episodes (705) as opposed to older episodes (582 above)
41 'url': 'https://www.americastestkitchen.com/episode/705-simple-chicken-dinner',
42 'md5': '06451608c57651e985a498e69cec17e5',
44 'id': '5fbe8c61bda2010001c6763b',
45 'title': 'Simple Chicken Dinner',
47 'description': 'md5:eb68737cc2fd4c26ca7db30139d109e7',
48 'thumbnail': r're:^https?://',
49 'timestamp': 1610755200,
50 'upload_date': '20210116',
51 'release_date': '20210116',
52 'series': "America's Test Kitchen",
54 'episode': 'Simple Chicken Dinner',
58 'skip_download': True,
61 'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon',
62 'only_matching': True,
64 'url': 'https://www.cookscountry.com/episode/564-when-only-chocolate-will-do',
65 'only_matching': True,
67 'url': 'https://www.cooksillustrated.com/videos/4478-beef-wellington',
68 'only_matching': True,
71 def _real_extract(self, url):
72 resource_type, video_id = re.match(self._VALID_URL, url).groups()
73 is_episode = resource_type == 'episode'
75 resource_type = 'episodes'
77 resource = self._download_json(
78 'https://www.americastestkitchen.com/api/v6/%s/%s' % (resource_type, video_id), video_id)
79 video = resource['video'] if is_episode else resource
80 episode = resource if is_episode else resource.get('episode') or {}
83 '_type': 'url_transparent',
84 'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video['zypeId'],
86 'description': clean_html(video.get('description')),
87 'timestamp': unified_timestamp(video.get('publishDate')),
88 'release_date': unified_strdate(video.get('publishDate')),
89 'episode_number': int_or_none(episode.get('number')),
90 'season_number': int_or_none(episode.get('season')),
91 'series': try_get(episode, lambda x: x['show']['title']),
92 'episode': episode.get('title'),
96 class AmericasTestKitchenSeasonIE(InfoExtractor):
97 _VALID_URL = r'https?://(?:www\.)?(?P<show>americastestkitchen|cookscountry)\.com/episodes/browse/season_(?P<id>\d+)'
100 'url': 'https://www.americastestkitchen.com/episodes/browse/season_1',
105 'playlist_count': 13,
107 # Cooks Country Season
108 'url': 'https://www.cookscountry.com/episodes/browse/season_12',
111 'title': 'Season 12',
113 'playlist_count': 13,
116 def _real_extract(self, url):
117 show_name, season_number = re.match(self._VALID_URL, url).groups()
118 season_number = int(season_number)
120 slug = 'atk' if show_name == 'americastestkitchen' else 'cco'
122 season = 'Season %d' % season_number
124 season_search = self._download_json(
125 'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_%s_season_desc_production' % slug,
127 'Origin': 'https://www.%s.com' % show_name,
128 'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805',
129 'X-Algolia-Application-Id': 'Y1FNZXUI30',
131 'facetFilters': json.dumps([
132 'search_season_list:' + season,
133 'search_document_klass:episode',
134 'search_show_slug:' + slug,
136 'attributesToRetrieve': 'description,search_%s_episode_number,search_document_date,search_url,title' % slug,
137 'attributesToHighlight': '',
142 for episode in (season_search.get('hits') or []):
143 search_url = episode.get('search_url')
148 'url': 'https://www.%s.com%s' % (show_name, search_url),
149 'id': try_get(episode, lambda e: e['objectID'].split('_')[-1]),
150 'title': episode.get('title'),
151 'description': episode.get('description'),
152 'timestamp': unified_timestamp(episode.get('search_document_date')),
153 'season_number': season_number,
154 'episode_number': int_or_none(episode.get('search_%s_episode_number' % slug)),
155 'ie_key': AmericasTestKitchenIE.ie_key(),
158 return self.playlist_result(
159 entries(), 'season_%d' % season_number, season)