You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.9 KiB

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