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.

74 lines
2.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. NO_DEFAULT,
  6. smuggle_url,
  7. update_url_query,
  8. )
  9. class USANetworkIE(AdobePassIE):
  10. _VALID_URL = r'https?://(?:www\.)?usanetwork\.com/(?:[^/]+/videos|movies)/(?P<id>[^/?#]+)'
  11. _TEST = {
  12. 'url': 'http://www.usanetwork.com/mrrobot/videos/hpe-cybersecurity',
  13. 'md5': '33c0d2ba381571b414024440d08d57fd',
  14. 'info_dict': {
  15. 'id': '3086229',
  16. 'ext': 'mp4',
  17. 'title': 'HPE Cybersecurity',
  18. 'description': 'The more we digitize our world, the more vulnerable we are.',
  19. 'upload_date': '20160818',
  20. 'timestamp': 1471535460,
  21. 'uploader': 'NBCU-USA',
  22. },
  23. }
  24. def _real_extract(self, url):
  25. display_id = self._match_id(url)
  26. webpage = self._download_webpage(url, display_id)
  27. def _x(name, default=NO_DEFAULT):
  28. return self._search_regex(
  29. r'data-%s\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % name,
  30. webpage, name, default=default, group='value')
  31. video_id = _x('mpx-guid')
  32. title = _x('episode-title')
  33. mpx_account_id = _x('mpx-account-id', '2304992029')
  34. query = {
  35. 'mbr': 'true',
  36. }
  37. if _x('is-full-episode', None) == '1':
  38. query['manifest'] = 'm3u'
  39. if _x('is-entitlement', None) == '1':
  40. adobe_pass = {}
  41. drupal_settings = self._search_regex(
  42. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
  43. webpage, 'drupal settings', fatal=False)
  44. if drupal_settings:
  45. drupal_settings = self._parse_json(drupal_settings, video_id, fatal=False)
  46. if drupal_settings:
  47. adobe_pass = drupal_settings.get('adobePass', {})
  48. resource = self._get_mvpd_resource(
  49. adobe_pass.get('adobePassResourceId', 'usa'),
  50. title, video_id, _x('episode-rating', 'TV-14'))
  51. query['auth'] = self._extract_mvpd_auth(
  52. url, video_id, adobe_pass.get('adobePassRequestorId', 'usa'), resource)
  53. info = self._search_json_ld(webpage, video_id, default={})
  54. info.update({
  55. '_type': 'url_transparent',
  56. 'url': smuggle_url(update_url_query(
  57. 'http://link.theplatform.com/s/HNK2IC/media/guid/%s/%s' % (mpx_account_id, video_id),
  58. query), {'force_smil_url': True}),
  59. 'id': video_id,
  60. 'title': title,
  61. 'series': _x('show-title', None),
  62. 'episode': title,
  63. 'ie_key': 'ThePlatform',
  64. })
  65. return info