]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sprout.py
Update changelog.
[youtubedl] / youtube_dl / extractor / sprout.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .adobepass import AdobePassIE
5 from ..utils import (
6 extract_attributes,
7 update_url_query,
8 smuggle_url,
9 )
10
11
12 class SproutIE(AdobePassIE):
13 _VALID_URL = r'https?://(?:www\.)?sproutonline\.com/watch/(?P<id>[^/?#]+)'
14 _TEST = {
15 'url': 'http://www.sproutonline.com/watch/cowboy-adventure',
16 'md5': '74bf14128578d1e040c3ebc82088f45f',
17 'info_dict': {
18 'id': '9dexnwtmh8_X',
19 'ext': 'mp4',
20 'title': 'A Cowboy Adventure',
21 'description': 'Ruff-Ruff, Tweet and Dave get to be cowboys for the day at Six Cow Corral.',
22 'timestamp': 1437758640,
23 'upload_date': '20150724',
24 'uploader': 'NBCU-SPROUT-NEW',
25 }
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31 video_component = self._search_regex(
32 r'(?s)(<div[^>]+data-component="video"[^>]*?>)',
33 webpage, 'video component', default=None)
34 if video_component:
35 options = self._parse_json(extract_attributes(
36 video_component)['data-options'], video_id)
37 theplatform_url = options['video']
38 query = {
39 'mbr': 'true',
40 'manifest': 'm3u',
41 }
42 if options.get('protected'):
43 query['auth'] = self._extract_mvpd_auth(url, options['pid'], 'sprout', 'sprout')
44 theplatform_url = smuggle_url(update_url_query(
45 theplatform_url, query), {'force_smil_url': True})
46 else:
47 iframe = self._search_regex(
48 r'(<iframe[^>]+id="sproutVideoIframe"[^>]*?>)',
49 webpage, 'iframe')
50 theplatform_url = extract_attributes(iframe)['src']
51
52 return self.url_result(theplatform_url, 'ThePlatform')