You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class ThisOldHouseIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?thisoldhouse\.com/(?:watch|how-to|tv-episode)/(?P<id>[^/?#]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.thisoldhouse.com/how-to/how-to-build-storage-bench',
  8. 'md5': '946f05bbaa12a33f9ae35580d2dfcfe3',
  9. 'info_dict': {
  10. 'id': '2REGtUDQ',
  11. 'ext': 'mp4',
  12. 'title': 'How to Build a Storage Bench',
  13. 'description': 'In the workshop, Tom Silva and Kevin O\'Connor build a storage bench for an entryway.',
  14. 'timestamp': 1442548800,
  15. 'upload_date': '20150918',
  16. }
  17. }, {
  18. 'url': 'https://www.thisoldhouse.com/watch/arlington-arts-crafts-arts-and-crafts-class-begins',
  19. 'only_matching': True,
  20. }, {
  21. 'url': 'https://www.thisoldhouse.com/tv-episode/ask-toh-shelf-rough-electric',
  22. 'only_matching': True,
  23. }]
  24. def _real_extract(self, url):
  25. display_id = self._match_id(url)
  26. webpage = self._download_webpage(url, display_id)
  27. drupal_settings = self._parse_json(self._search_regex(
  28. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
  29. webpage, 'drupal settings'), display_id)
  30. video_id = drupal_settings['jwplatform']['video_id']
  31. return self.url_result('jwplatform:' + video_id, 'JWPlatform', video_id)