]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/scrippsnetworks.py
Prepare to release.
[youtubedl] / youtube_dl / extractor / scrippsnetworks.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .adobepass import AdobePassIE
5 from ..utils import (
6 int_or_none,
7 smuggle_url,
8 update_url_query,
9 )
10
11
12 class ScrippsNetworksWatchIE(AdobePassIE):
13 IE_NAME = 'scrippsnetworks:watch'
14 _VALID_URL = r'https?://watch\.(?:hgtv|foodnetwork|travelchannel|diynetwork|cookingchanneltv)\.com/player\.[A-Z0-9]+\.html#(?P<id>\d+)'
15 _TEST = {
16 'url': 'http://watch.hgtv.com/player.HNT.html#0256538',
17 'md5': '26545fd676d939954c6808274bdb905a',
18 'info_dict': {
19 'id': '0256538',
20 'ext': 'mp4',
21 'title': 'Seeking a Wow House',
22 'description': 'Buyers retiring in Palm Springs, California, want a modern house with major wow factor. They\'re also looking for a pool and a large, open floorplan with tall windows looking out at the views.',
23 'uploader': 'SCNI',
24 'upload_date': '20170207',
25 'timestamp': 1486450493,
26 },
27 'skip': 'requires TV provider authentication',
28 }
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 webpage = self._download_webpage(url, video_id)
33 channel = self._parse_json(self._search_regex(
34 r'"channels"\s*:\s*(\[.+\])',
35 webpage, 'channels'), video_id)[0]
36 video_data = next(v for v in channel['videos'] if v.get('nlvid') == video_id)
37 title = video_data['title']
38 release_url = video_data['releaseUrl']
39 if video_data.get('restricted'):
40 requestor_id = self._search_regex(
41 r'requestorId\s*=\s*"([^"]+)";', webpage, 'requestor id')
42 resource = self._get_mvpd_resource(
43 requestor_id, title, video_id,
44 video_data.get('ratings', [{}])[0].get('rating'))
45 auth = self._extract_mvpd_auth(
46 url, video_id, requestor_id, resource)
47 release_url = update_url_query(release_url, {'auth': auth})
48
49 return {
50 '_type': 'url_transparent',
51 'id': video_id,
52 'title': title,
53 'url': smuggle_url(release_url, {'force_smil_url': True}),
54 'description': video_data.get('description'),
55 'thumbnail': video_data.get('thumbnailUrl'),
56 'series': video_data.get('showTitle'),
57 'season_number': int_or_none(video_data.get('season')),
58 'episode_number': int_or_none(video_data.get('episodeNumber')),
59 'ie_key': 'ThePlatform',
60 }