]>
Commit | Line | Data |
---|---|---|
13de91c9 DW |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
29f7c58a | 4 | import re |
5 | ||
13de91c9 | 6 | from .common import InfoExtractor |
4bb58fa1 S |
7 | from ..utils import ( |
8 | clean_html, | |
4bb58fa1 S |
9 | try_get, |
10 | unified_strdate, | |
11 | ) | |
13de91c9 DW |
12 | |
13 | ||
14 | class AmericasTestKitchenIE(InfoExtractor): | |
29f7c58a | 15 | _VALID_URL = r'https?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?P<resource_type>episode|videos)/(?P<id>\d+)' |
13de91c9 | 16 | _TESTS = [{ |
2c482bff | 17 | 'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers', |
13de91c9 DW |
18 | 'md5': 'b861c3e365ac38ad319cfd509c30577f', |
19 | 'info_dict': { | |
2c482bff | 20 | 'id': '5b400b9ee338f922cb06450c', |
29f7c58a | 21 | 'title': 'Japanese Suppers', |
13de91c9 | 22 | 'ext': 'mp4', |
29f7c58a | 23 | 'description': 'md5:64e606bfee910627efc4b5f050de92b3', |
2c482bff RA |
24 | 'thumbnail': r're:^https?://', |
25 | 'timestamp': 1523664000, | |
26 | 'upload_date': '20180414', | |
29f7c58a | 27 | 'release_date': '20180410', |
4bb58fa1 | 28 | 'series': "America's Test Kitchen", |
2c482bff | 29 | 'season_number': 18, |
29f7c58a | 30 | 'episode': 'Japanese Suppers', |
2c482bff | 31 | 'episode_number': 15, |
13de91c9 DW |
32 | }, |
33 | 'params': { | |
13de91c9 DW |
34 | 'skip_download': True, |
35 | }, | |
36 | }, { | |
4bb58fa1 S |
37 | 'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon', |
38 | 'only_matching': True, | |
29f7c58a | 39 | }, { |
40 | 'url': 'https://www.cookscountry.com/episode/564-when-only-chocolate-will-do', | |
41 | 'only_matching': True, | |
42 | }, { | |
43 | 'url': 'https://www.cooksillustrated.com/videos/4478-beef-wellington', | |
44 | 'only_matching': True, | |
13de91c9 DW |
45 | }] |
46 | ||
47 | def _real_extract(self, url): | |
29f7c58a | 48 | resource_type, video_id = re.match(self._VALID_URL, url).groups() |
49 | is_episode = resource_type == 'episode' | |
50 | if is_episode: | |
51 | resource_type = 'episodes' | |
13de91c9 | 52 | |
29f7c58a | 53 | resource = self._download_json( |
54 | 'https://www.americastestkitchen.com/api/v6/%s/%s' % (resource_type, video_id), video_id) | |
55 | video = resource['video'] if is_episode else resource | |
56 | episode = resource if is_episode else resource.get('episode') or {} | |
13de91c9 DW |
57 | |
58 | return { | |
59 | '_type': 'url_transparent', | |
29f7c58a | 60 | 'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video['zypeId'], |
2c482bff | 61 | 'ie_key': 'Zype', |
29f7c58a | 62 | 'description': clean_html(video.get('description')), |
63 | 'release_date': unified_strdate(video.get('publishDate')), | |
64 | 'series': try_get(episode, lambda x: x['show']['title']), | |
65 | 'episode': episode.get('title'), | |
13de91c9 | 66 | } |