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.

76 lines
2.8 KiB

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