2016-10-03 16:27:09 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2022-01-18 08:40:55 +01:00
|
|
|
from ..utils import HEADRequest
|
2016-10-03 16:27:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ThisOldHouseIE(InfoExtractor):
|
2020-02-03 13:20:20 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?thisoldhouse\.com/(?:watch|how-to|tv-episode|(?:[^/]+/)?\d+)/(?P<id>[^/?#]+)'
|
2016-10-03 16:27:09 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.thisoldhouse.com/how-to/how-to-build-storage-bench',
|
|
|
|
'info_dict': {
|
2020-02-03 13:20:20 +01:00
|
|
|
'id': '5dcdddf673c3f956ef5db202',
|
2016-10-03 16:27:09 +02:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'How to Build a Storage Bench',
|
|
|
|
'description': 'In the workshop, Tom Silva and Kevin O\'Connor build a storage bench for an entryway.',
|
|
|
|
'timestamp': 1442548800,
|
|
|
|
'upload_date': '20150918',
|
2022-01-18 08:40:55 +01:00
|
|
|
'duration': 674,
|
|
|
|
'view_count': int,
|
|
|
|
'average_rating': 0,
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg\?\d+$',
|
|
|
|
'display_id': 'how-to-build-a-storage-bench',
|
2020-02-03 13:20:20 +01:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2016-10-03 16:27:09 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.thisoldhouse.com/watch/arlington-arts-crafts-arts-and-crafts-class-begins',
|
|
|
|
'only_matching': True,
|
2016-12-01 07:56:52 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.thisoldhouse.com/tv-episode/ask-toh-shelf-rough-electric',
|
|
|
|
'only_matching': True,
|
2020-02-03 13:20:20 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.thisoldhouse.com/furniture/21017078/how-to-build-a-storage-bench',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.thisoldhouse.com/21113884/s41-e13-paradise-lost',
|
|
|
|
'only_matching': True,
|
2020-04-11 15:07:12 +02:00
|
|
|
}, {
|
|
|
|
# iframe www.thisoldhouse.com
|
|
|
|
'url': 'https://www.thisoldhouse.com/21083431/seaside-transformation-the-westerly-project',
|
|
|
|
'only_matching': True,
|
2016-10-03 16:27:09 +02:00
|
|
|
}]
|
2020-02-03 13:20:20 +01:00
|
|
|
_ZYPE_TMPL = 'https://player.zype.com/embed/%s.html?api_key=hsOk_yMSPYNrT22e9pu8hihLXjaZf0JW5jsOWv4ZqyHJFvkJn6rtToHl09tbbsbe'
|
2016-10-03 16:27:09 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
2022-01-18 08:40:55 +01:00
|
|
|
if 'To Unlock This content' in webpage:
|
|
|
|
self.raise_login_required(method='cookies')
|
|
|
|
video_url = self._search_regex(
|
|
|
|
r'<iframe[^>]+src=[\'"]((?:https?:)?//(?:www\.)?thisoldhouse\.(?:chorus\.build|com)/videos/zype/([0-9a-f]{24})[^\'"]*)[\'"]',
|
|
|
|
webpage, 'video url')
|
|
|
|
if 'subscription_required=true' in video_url:
|
|
|
|
return self.url_result(self._request_webpage(HEADRequest(video_url), display_id).geturl(), 'Zype', display_id)
|
|
|
|
video_id = self._search_regex(r'(?:https?:)?//(?:www\.)?thisoldhouse\.(?:chorus\.build|com)/videos/zype/([0-9a-f]{24})', video_url, 'video id')
|
2020-02-03 13:20:20 +01:00
|
|
|
return self.url_result(self._ZYPE_TMPL % video_id, 'Zype', video_id)
|