]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | ||
3 | ||
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 | ||
21 | def _real_extract(self, url): | |
22 | display_id = self._match_id(url) | |
23 | ||
24 | webpage = self._download_webpage(url, display_id) | |
25 | ||
26 | config = self._parse_json( | |
27 | self._search_regex( | |
28 | r'(?s)data-(?:deferred-)?module=["\']video["\'][^>]*>.*?<script[^>]+type=["\']text/x-config["\'][^>]*>(.+?)</script', | |
29 | webpage, 'video config'), | |
30 | display_id)['channels'][0] | |
31 | ||
32 | entries = [ | |
33 | self.url_result(video['releaseUrl']) | |
34 | for video in config['videos'] if video.get('releaseUrl')] | |
35 | ||
36 | return self.playlist_result( | |
37 | entries, display_id, config.get('title'), config.get('description')) |