33269705f48fd0f458699840bc711d7de017b6df
[youtube-dl] / youtube_dl / extractor / thisoldhouse.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class ThisOldHouseIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?thisoldhouse\.com/(?:watch|how-to|tv-episode|(?:[^/]+/)?\d+)/(?P<id>[^/?#]+)'
9     _TESTS = [{
10         'url': 'https://www.thisoldhouse.com/how-to/how-to-build-storage-bench',
11         'info_dict': {
12             'id': '5dcdddf673c3f956ef5db202',
13             'ext': 'mp4',
14             'title': 'How to Build a Storage Bench',
15             'description': 'In the workshop, Tom Silva and Kevin O\'Connor build a storage bench for an entryway.',
16             'timestamp': 1442548800,
17             'upload_date': '20150918',
18         },
19         'params': {
20             'skip_download': True,
21         },
22     }, {
23         'url': 'https://www.thisoldhouse.com/21083431/seaside-transformation-the-westerly-project',
24         'note': 'test for updated video URL',
25         'info_dict': {
26             'id': '5e2b70e95216cc0001615120',
27             'ext': 'mp4',
28             'title': 'E12 | The Westerly Project | Seaside Transformation',
29             'description': 'Kevin and Tommy take the tour with the homeowners and Jeff. Norm presents his pine coffee table. Jenn gives Tommy the garden tour. Everyone meets at the flagpole to raise the flags.',
30             'timestamp': 1579755600,
31             'upload_date': '20200123',
32         },
33         'params': {
34             'skip_download': True,
35         },
36     }, {
37         'url': 'https://www.thisoldhouse.com/watch/arlington-arts-crafts-arts-and-crafts-class-begins',
38         'only_matching': True,
39     }, {
40         'url': 'https://www.thisoldhouse.com/tv-episode/ask-toh-shelf-rough-electric',
41         'only_matching': True,
42     }, {
43         'url': 'https://www.thisoldhouse.com/furniture/21017078/how-to-build-a-storage-bench',
44         'only_matching': True,
45     }, {
46         'url': 'https://www.thisoldhouse.com/21113884/s41-e13-paradise-lost',
47         'only_matching': True,
48     }]
49     _ZYPE_TMPL = 'https://player.zype.com/embed/%s.html?api_key=hsOk_yMSPYNrT22e9pu8hihLXjaZf0JW5jsOWv4ZqyHJFvkJn6rtToHl09tbbsbe'
50
51     def _real_extract(self, url):
52         display_id = self._match_id(url)
53         webpage = self._download_webpage(url, display_id)
54         video_id = self._search_regex(
55             r'<iframe[^>]+src=[\'"](?:https?:)?//(?:www\.|)thisoldhouse(?:\.chorus\.build|\.com)/videos/zype/([0-9a-f]{24})',
56             webpage, 'video id')
57         return self.url_result(self._ZYPE_TMPL % video_id, 'Zype', video_id)