2017-09-13 04:52:54 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2021-01-21 16:46:29 +01:00
|
|
|
import json
|
2020-12-06 23:37:16 +01:00
|
|
|
import re
|
|
|
|
|
2017-09-13 04:52:54 +02:00
|
|
|
from .common import InfoExtractor
|
2017-09-23 01:28:46 +02:00
|
|
|
from ..utils import (
|
|
|
|
clean_html,
|
2021-01-18 15:47:06 +01:00
|
|
|
int_or_none,
|
2017-09-23 01:28:46 +02:00
|
|
|
try_get,
|
|
|
|
unified_strdate,
|
2021-01-18 15:47:06 +01:00
|
|
|
unified_timestamp,
|
2017-09-23 01:28:46 +02:00
|
|
|
)
|
2017-09-13 04:52:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
class AmericasTestKitchenIE(InfoExtractor):
|
2020-12-06 23:37:16 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?(?:americastestkitchen|cooks(?:country|illustrated))\.com/(?P<resource_type>episode|videos)/(?P<id>\d+)'
|
2017-09-13 04:52:54 +02:00
|
|
|
_TESTS = [{
|
2020-01-15 14:16:58 +01:00
|
|
|
'url': 'https://www.americastestkitchen.com/episode/582-weeknight-japanese-suppers',
|
2017-09-13 04:52:54 +02:00
|
|
|
'md5': 'b861c3e365ac38ad319cfd509c30577f',
|
|
|
|
'info_dict': {
|
2020-01-15 14:16:58 +01:00
|
|
|
'id': '5b400b9ee338f922cb06450c',
|
2020-12-06 23:37:16 +01:00
|
|
|
'title': 'Japanese Suppers',
|
2017-09-13 04:52:54 +02:00
|
|
|
'ext': 'mp4',
|
2020-12-06 23:37:16 +01:00
|
|
|
'description': 'md5:64e606bfee910627efc4b5f050de92b3',
|
2020-01-15 14:16:58 +01:00
|
|
|
'thumbnail': r're:^https?://',
|
2021-01-18 15:47:06 +01:00
|
|
|
'timestamp': 1523318400,
|
|
|
|
'upload_date': '20180410',
|
2020-12-06 23:37:16 +01:00
|
|
|
'release_date': '20180410',
|
2017-09-23 01:28:46 +02:00
|
|
|
'series': "America's Test Kitchen",
|
2020-01-15 14:16:58 +01:00
|
|
|
'season_number': 18,
|
2020-12-06 23:37:16 +01:00
|
|
|
'episode': 'Japanese Suppers',
|
2020-01-15 14:16:58 +01:00
|
|
|
'episode_number': 15,
|
2017-09-13 04:52:54 +02:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2021-01-18 15:47:06 +01:00
|
|
|
}, {
|
|
|
|
# Metadata parsing behaves differently for newer episodes (705) as opposed to older episodes (582 above)
|
|
|
|
'url': 'https://www.americastestkitchen.com/episode/705-simple-chicken-dinner',
|
|
|
|
'md5': '06451608c57651e985a498e69cec17e5',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '5fbe8c61bda2010001c6763b',
|
|
|
|
'title': 'Simple Chicken Dinner',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'description': 'md5:eb68737cc2fd4c26ca7db30139d109e7',
|
|
|
|
'thumbnail': r're:^https?://',
|
|
|
|
'timestamp': 1610755200,
|
|
|
|
'upload_date': '20210116',
|
|
|
|
'release_date': '20210116',
|
|
|
|
'series': "America's Test Kitchen",
|
|
|
|
'season_number': 21,
|
|
|
|
'episode': 'Simple Chicken Dinner',
|
|
|
|
'episode_number': 3,
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2017-09-13 04:52:54 +02:00
|
|
|
}, {
|
2017-09-23 01:28:46 +02:00
|
|
|
'url': 'https://www.americastestkitchen.com/videos/3420-pan-seared-salmon',
|
|
|
|
'only_matching': True,
|
2020-12-06 23:37:16 +01: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 04:52:54 +02:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2020-12-06 23:37:16 +01: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 04:52:54 +02:00
|
|
|
|
2020-12-06 23:37:16 +01: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 04:52:54 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
2020-12-06 23:37:16 +01:00
|
|
|
'url': 'https://player.zype.com/embed/%s.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ' % video['zypeId'],
|
2020-01-15 14:16:58 +01:00
|
|
|
'ie_key': 'Zype',
|
2020-12-06 23:37:16 +01:00
|
|
|
'description': clean_html(video.get('description')),
|
2021-01-18 15:47:06 +01:00
|
|
|
'timestamp': unified_timestamp(video.get('publishDate')),
|
2020-12-06 23:37:16 +01:00
|
|
|
'release_date': unified_strdate(video.get('publishDate')),
|
2021-01-18 15:47:06 +01:00
|
|
|
'episode_number': int_or_none(episode.get('number')),
|
|
|
|
'season_number': int_or_none(episode.get('season')),
|
2020-12-06 23:37:16 +01:00
|
|
|
'series': try_get(episode, lambda x: x['show']['title']),
|
|
|
|
'episode': episode.get('title'),
|
2017-09-13 04:52:54 +02:00
|
|
|
}
|
2021-01-21 16:46:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
class AmericasTestKitchenSeasonIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?(?P<show>americastestkitchen|cookscountry)\.com/episodes/browse/season_(?P<id>\d+)'
|
|
|
|
_TESTS = [{
|
|
|
|
# ATK Season
|
|
|
|
'url': 'https://www.americastestkitchen.com/episodes/browse/season_1',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'season-1',
|
|
|
|
'title': 'Season 1',
|
|
|
|
},
|
|
|
|
'playlist_count': 13,
|
|
|
|
}, {
|
|
|
|
# Cooks Country Season
|
|
|
|
'url': 'https://www.cookscountry.com/episodes/browse/season_12',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'season-12',
|
|
|
|
'title': 'Season 12',
|
|
|
|
},
|
|
|
|
'playlist_count': 13,
|
|
|
|
}, {
|
|
|
|
# Multi-digit season
|
|
|
|
'url': 'https://www.americastestkitchen.com/episodes/browse/season_20',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
show_name, season = re.match(self._VALID_URL, url).groups()
|
|
|
|
|
|
|
|
slug = 'atk' if show_name == 'americastestkitchen' else 'cco'
|
|
|
|
|
|
|
|
filters = [
|
|
|
|
'search_season_list:Season %s' % season,
|
|
|
|
'search_document_klass:episode',
|
|
|
|
'search_show_slug:%s' % slug,
|
|
|
|
]
|
|
|
|
|
|
|
|
season_search = self._download_json(
|
|
|
|
'https://y1fnzxui30-dsn.algolia.net/1/indexes/everest_search_atk_season_desc_production',
|
|
|
|
season, headers={
|
|
|
|
'Origin': 'https://www.%s.com' % show_name,
|
|
|
|
'X-Algolia-API-Key': '8d504d0099ed27c1b73708d22871d805',
|
|
|
|
'X-Algolia-Application-Id': 'Y1FNZXUI30',
|
|
|
|
}, query={
|
|
|
|
'facetFilters': json.dumps(filters),
|
|
|
|
'attributesToRetrieve': 'search_url',
|
|
|
|
'attributesToHighlight': '',
|
|
|
|
# ATK and CCO generally have less than 26 episodes per season
|
|
|
|
'hitsPerPage': '100',
|
|
|
|
})
|
|
|
|
|
|
|
|
entries = [
|
|
|
|
self.url_result(
|
|
|
|
'https://www.%s.com%s' % (show_name, episode['search_url']),
|
|
|
|
'AmericasTestKitchen',
|
|
|
|
try_get(episode, lambda e: e['objectID'].split('_')[-1]))
|
|
|
|
for episode in season_search['hits']
|
|
|
|
if 'search_url' in episode and episode['search_url']
|
|
|
|
]
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'playlist',
|
|
|
|
'id': 'season-%s' % season,
|
|
|
|
'title': 'Season %s' % season,
|
|
|
|
'entries': sorted(entries, key=lambda e: e.get('id')),
|
|
|
|
}
|