2017-09-13 02:52:54 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2021-01-01 12:26:37 +00:00
|
|
|
import re
|
|
|
|
|
2017-09-13 02:52:54 +00:00
|
|
|
from .common import InfoExtractor
|
2017-09-22 23:28:46 +00:00
|
|
|
from ..utils import (
|
|
|
|
clean_html,
|
|
|
|
try_get,
|
|
|
|
unified_strdate,
|
|
|
|
)
|
2017-09-13 02:52:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AmericasTestKitchenIE(InfoExtractor):
|
2021-01-01 12:26:37 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?P<resource_type>episode|videos)/(?P<id>\d+)'
|
2017-09-13 02:52:54 +00:00
|
|
|
_TESTS = [{
|
2020-01-15 13:16:58 +00:00
|
|
|
'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers',
|
2017-09-13 02:52:54 +00:00
|
|
|
'md5': 'b861c3e365ac38ad319cfd509c30577f',
|
|
|
|
'info_dict': {
|
2020-01-15 13:16:58 +00:00
|
|
|
'id': '5b400b9ee338f922cb06450c',
|
2021-01-01 12:26:37 +00:00
|
|
|
'title': 'Japanese Suppers',
|
2017-09-13 02:52:54 +00:00
|
|
|
'ext': 'mp4',
|
2021-01-01 12:26:37 +00:00
|
|
|
'description': 'md5:64e606bfee910627efc4b5f050de92b3',
|
2020-01-15 13:16:58 +00:00
|
|
|
'thumbnail': r're:^https?://',
|
|
|
|
'timestamp': 1523664000,
|
|
|
|
'upload_date': '20180414',
|
2021-01-01 12:26:37 +00:00
|
|
|
'release_date': '20180410',
|
2017-09-22 23:28:46 +00:00
|
|
|
'series': "America's Test Kitchen",
|
2020-01-15 13:16:58 +00:00
|
|
|
'season_number': 18,
|
2021-01-01 12:26:37 +00:00
|
|
|
'episode': 'Japanese Suppers',
|
2020-01-15 13:16:58 +00:00
|
|
|
'episode_number': 15,
|
2017-09-13 02:52:54 +00:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}, {
|
2017-09-22 23:28:46 +00:00
|
|
|
'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon',
|
|
|
|
'only_matching': True,
|
2021-01-01 12:26:37 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.cookscountry.com/episode/564-when-only-chocolate-will-do',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.cooksillustrated.com/videos/4478-beef-wellington',
|
|
|
|
'only_matching': True,
|
2017-09-13 02:52:54 +00:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-01-01 12:26:37 +00:00
|
|
|
resource_type, video_id = re.match(self._VALID_URL, url).groups()
|
|
|
|
is_episode = resource_type == 'episode'
|
|
|
|
if is_episode:
|
|
|
|
resource_type = 'episodes'
|
2017-09-13 02:52:54 +00:00
|
|
|
|
2021-01-01 12:26:37 +00:00
|
|
|
resource = self._download_json(
|
|
|
|
'https://www.americastestkitchen.com/api/v6/%s/%s' % (resource_type, video_id), video_id)
|
|
|
|
video = resource['video'] if is_episode else resource
|
|
|
|
episode = resource if is_episode else resource.get('episode') or {}
|
2017-09-13 02:52:54 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
2021-01-01 12:26:37 +00:00
|
|
|
'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video['zypeId'],
|
2020-01-15 13:16:58 +00:00
|
|
|
'ie_key': 'Zype',
|
2021-01-01 12:26:37 +00:00
|
|
|
'description': clean_html(video.get('description')),
|
|
|
|
'release_date': unified_strdate(video.get('publishDate')),
|
|
|
|
'series': try_get(episode, lambda x: x['show']['title']),
|
|
|
|
'episode': episode.get('title'),
|
2017-09-13 02:52:54 +00:00
|
|
|
}
|