logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

sprout.py (2326B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. int_or_none,
  6. smuggle_url,
  7. update_url_query,
  8. )
  9. class SproutIE(AdobePassIE):
  10. _VALID_URL = r'https?://(?:www\.)?(?:sproutonline|universalkids)\.com/(?:watch|(?:[^/]+/)*videos)/(?P<id>[^/?#]+)'
  11. _TESTS = [{
  12. 'url': 'https://www.universalkids.com/shows/remy-and-boo/season/1/videos/robot-bike-race',
  13. 'info_dict': {
  14. 'id': 'bm0foJFaTKqb',
  15. 'ext': 'mp4',
  16. 'title': 'Robot Bike Race',
  17. 'description': 'md5:436b1d97117cc437f54c383f4debc66d',
  18. 'timestamp': 1606148940,
  19. 'upload_date': '20201123',
  20. 'uploader': 'NBCU-MPAT',
  21. },
  22. 'params': {
  23. 'skip_download': True,
  24. },
  25. }, {
  26. 'url': 'http://www.sproutonline.com/watch/cowboy-adventure',
  27. 'only_matching': True,
  28. }, {
  29. 'url': 'https://www.universalkids.com/watch/robot-bike-race',
  30. 'only_matching': True,
  31. }]
  32. _GEO_COUNTRIES = ['US']
  33. def _real_extract(self, url):
  34. display_id = self._match_id(url)
  35. mpx_metadata = self._download_json(
  36. # http://nbcuunikidsprod.apps.nbcuni.com/networks/universalkids/content/videos/
  37. 'https://www.universalkids.com/_api/videos/' + display_id,
  38. display_id)['mpxMetadata']
  39. media_pid = mpx_metadata['mediaPid']
  40. theplatform_url = 'https://link.theplatform.com/s/HNK2IC/' + media_pid
  41. query = {
  42. 'mbr': 'true',
  43. 'manifest': 'm3u',
  44. }
  45. if mpx_metadata.get('entitlement') == 'auth':
  46. query['auth'] = self._extract_mvpd_auth(url, media_pid, 'sprout', 'sprout')
  47. theplatform_url = smuggle_url(
  48. update_url_query(theplatform_url, query), {
  49. 'force_smil_url': True,
  50. 'geo_countries': self._GEO_COUNTRIES,
  51. })
  52. return {
  53. '_type': 'url_transparent',
  54. 'id': media_pid,
  55. 'url': theplatform_url,
  56. 'series': mpx_metadata.get('seriesName'),
  57. 'season_number': int_or_none(mpx_metadata.get('seasonNumber')),
  58. 'episode_number': int_or_none(mpx_metadata.get('episodeNumber')),
  59. 'ie_key': 'ThePlatform',
  60. }