]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hgtv.py
Update changelog
[youtubedl] / youtube_dl / extractor / hgtv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 int_or_none,
7 js_to_json,
8 smuggle_url,
9 )
10
11
12 class HGTVIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?hgtv\.ca/[^/]+/video/(?P<id>[^/]+)/video.html'
14 _TEST = {
15 'url': 'http://www.hgtv.ca/homefree/video/overnight-success/video.html?v=738081859718&p=1&s=da#video',
16 'md5': '',
17 'info_dict': {
18 'id': 'aFH__I_5FBOX',
19 'ext': 'mp4',
20 'title': 'Overnight Success',
21 'description': 'After weeks of hard work, high stakes, breakdowns and pep talks, the final 2 contestants compete to win the ultimate dream.',
22 'uploader': 'SHWM-NEW',
23 'timestamp': 1470320034,
24 'upload_date': '20160804',
25 },
26 'params': {
27 # m3u8 download
28 'skip_download': True,
29 },
30 }
31
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
34 webpage = self._download_webpage(url, display_id)
35 embed_vars = self._parse_json(self._search_regex(
36 r'(?s)embed_vars\s*=\s*({.*?});',
37 webpage, 'embed vars'), display_id, js_to_json)
38 return {
39 '_type': 'url_transparent',
40 'url': smuggle_url(
41 'http://link.theplatform.com/s/dtjsEC/%s?mbr=true&manifest=m3u' % embed_vars['pid'], {
42 'force_smil_url': True
43 }),
44 'series': embed_vars.get('show'),
45 'season_number': int_or_none(embed_vars.get('season')),
46 'episode_number': int_or_none(embed_vars.get('episode')),
47 'ie_key': 'ThePlatform',
48 }
49
50
51 class HGTVComShowIE(InfoExtractor):
52 IE_NAME = 'hgtv.com:show'
53 _VALID_URL = r'https?://(?:www\.)?hgtv\.com/shows/[^/]+/(?P<id>[^/?#&]+)'
54 _TEST = {
55 'url': 'http://www.hgtv.com/shows/flip-or-flop/flip-or-flop-full-episodes-videos',
56 'info_dict': {
57 'id': 'flip-or-flop-full-episodes-videos',
58 'title': 'Flip or Flop Full Episodes',
59 },
60 'playlist_mincount': 15,
61 }
62
63 def _real_extract(self, url):
64 display_id = self._match_id(url)
65
66 webpage = self._download_webpage(url, display_id)
67
68 config = self._parse_json(
69 self._search_regex(
70 r'(?s)data-module=["\']video["\'][^>]*>.*?<script[^>]+type=["\']text/x-config["\'][^>]*>(.+?)</script',
71 webpage, 'video config'),
72 display_id)['channels'][0]
73
74 entries = [
75 self.url_result(video['releaseUrl'])
76 for video in config['videos'] if video.get('releaseUrl')]
77
78 return self.playlist_result(
79 entries, display_id, config.get('title'), config.get('description'))