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.

40 lines
1.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class HGTVComShowIE(InfoExtractor):
  5. IE_NAME = 'hgtv.com:show'
  6. _VALID_URL = r'https?://(?:www\.)?hgtv\.com/shows/[^/]+/(?P<id>[^/?#&]+)'
  7. _TESTS = [{
  8. # data-module="video"
  9. 'url': 'http://www.hgtv.com/shows/flip-or-flop/flip-or-flop-full-episodes-season-4-videos',
  10. 'info_dict': {
  11. 'id': 'flip-or-flop-full-episodes-season-4-videos',
  12. 'title': 'Flip or Flop Full Episodes',
  13. },
  14. 'playlist_mincount': 15,
  15. }, {
  16. # data-deferred-module="video"
  17. 'url': 'http://www.hgtv.com/shows/good-bones/episodes/an-old-victorian-house-gets-a-new-facelift',
  18. 'only_matching': True,
  19. }]
  20. def _real_extract(self, url):
  21. display_id = self._match_id(url)
  22. webpage = self._download_webpage(url, display_id)
  23. config = self._parse_json(
  24. self._search_regex(
  25. r'(?s)data-(?:deferred-)?module=["\']video["\'][^>]*>.*?<script[^>]+type=["\']text/x-config["\'][^>]*>(.+?)</script',
  26. webpage, 'video config'),
  27. display_id)['channels'][0]
  28. entries = [
  29. self.url_result(video['releaseUrl'])
  30. for video in config['videos'] if video.get('releaseUrl')]
  31. return self.playlist_result(
  32. entries, display_id, config.get('title'), config.get('description'))