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 'url': 'https://www.americastestkitchen.com/episodes/browse/season_20',
117 'only_matching': True,
120 def _real_extract(self, url):
121 show_name, season = re.match(self._VALID_URL, url).groups()
123 slug = 'atk' if show_name == 'americastestkitchen' else 'cco'
126 'search_season_list:Season %s' % season,
127 'search_document_klass:episode',
128 'search_show_slug:%s' % slug,
131 season_search = self._download_json(
132 'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_atk_season_desc_production',
134 'Origin': 'https://www.%s.com' % show_name,
135 'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805',
136 'X-Algolia-Application-Id': 'Y1FNZXUI30',
138 'facetFilters': json.dumps(filters),
139 'attributesToRetrieve': 'search_url',
140 'attributesToHighlight': '',
141 # ATK and CCO generally have less than 26 episodes per season
142 'hitsPerPage': '100',
147 'https://www.%s.com%s' % (show_name, episode['search_url']),
148 'AmericasTestKitchen',
149 try_get(episode, lambda e: e['objectID'].split('_')[-1]))
150 for episode in season_search['hits']
151 if 'search_url' in episode and episode['search_url']
156 'id': 'season-%s' % season,
157 'title': 'Season %s' % season,
158 'entries': sorted(entries, key=lambda e: e.get('id')),