]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hgtv.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / hgtv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class HGTVComShowIE(InfoExtractor):
8 IE_NAME = 'hgtv.com:show'
9 _VALID_URL = r'https?://(?:www\.)?hgtv\.com/shows/[^/]+/(?P<id>[^/?#&]+)'
10 _TEST = {
11 'url': 'http://www.hgtv.com/shows/flip-or-flop/flip-or-flop-full-episodes-videos',
12 'info_dict': {
13 'id': 'flip-or-flop-full-episodes-videos',
14 'title': 'Flip or Flop Full Episodes',
15 },
16 'playlist_mincount': 15,
17 }
18
19 def _real_extract(self, url):
20 display_id = self._match_id(url)
21
22 webpage = self._download_webpage(url, display_id)
23
24 config = self._parse_json(
25 self._search_regex(
26 r'(?s)data-module=["\']video["\'][^>]*>.*?<script[^>]+type=["\']text/x-config["\'][^>]*>(.+?)</script',
27 webpage, 'video config'),
28 display_id)['channels'][0]
29
30 entries = [
31 self.url_result(video['releaseUrl'])
32 for video in config['videos'] if video.get('releaseUrl')]
33
34 return self.playlist_result(
35 entries, display_id, config.get('title'), config.get('description'))