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.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .adobepass import AdobePassIE
  4. from ..utils import (
  5. smuggle_url,
  6. update_url_query,
  7. int_or_none,
  8. )
  9. class BravoTVIE(AdobePassIE):
  10. _VALID_URL = r'https?://(?:www\.)?bravotv\.com/(?:[^/]+/)+(?P<id>[^/?#]+)'
  11. _TESTS = [{
  12. 'url': 'http://www.bravotv.com/last-chance-kitchen/season-5/videos/lck-ep-12-fishy-finale',
  13. 'md5': '9086d0b7ef0ea2aabc4781d75f4e5863',
  14. 'info_dict': {
  15. 'id': 'zHyk1_HU_mPy',
  16. 'ext': 'mp4',
  17. 'title': 'LCK Ep 12: Fishy Finale',
  18. 'description': 'S13/E12: Two eliminated chefs have just 12 minutes to cook up a delicious fish dish.',
  19. 'uploader': 'NBCU-BRAV',
  20. 'upload_date': '20160302',
  21. 'timestamp': 1456945320,
  22. }
  23. }, {
  24. 'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. display_id = self._match_id(url)
  29. webpage = self._download_webpage(url, display_id)
  30. settings = self._parse_json(self._search_regex(
  31. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'),
  32. display_id)
  33. info = {}
  34. query = {
  35. 'mbr': 'true',
  36. }
  37. account_pid, release_pid = [None] * 2
  38. tve = settings.get('sharedTVE')
  39. if tve:
  40. query['manifest'] = 'm3u'
  41. account_pid = 'HNK2IC'
  42. release_pid = tve['release_pid']
  43. if tve.get('entitlement') == 'auth':
  44. adobe_pass = settings.get('adobePass', {})
  45. resource = self._get_mvpd_resource(
  46. adobe_pass.get('adobePassResourceId', 'bravo'),
  47. tve['title'], release_pid, tve.get('rating'))
  48. query['auth'] = self._extract_mvpd_auth(
  49. url, release_pid, adobe_pass.get('adobePassRequestorId', 'bravo'), resource)
  50. else:
  51. shared_playlist = settings['shared_playlist']
  52. account_pid = shared_playlist['account_pid']
  53. metadata = shared_playlist['video_metadata'][shared_playlist['default_clip']]
  54. release_pid = metadata['release_pid']
  55. info.update({
  56. 'title': metadata['title'],
  57. 'description': metadata.get('description'),
  58. 'season_number': int_or_none(metadata.get('season_num')),
  59. 'episode_number': int_or_none(metadata.get('episode_num')),
  60. })
  61. query['switch'] = 'progressive'
  62. info.update({
  63. '_type': 'url_transparent',
  64. 'id': release_pid,
  65. 'url': smuggle_url(update_url_query(
  66. 'http://link.theplatform.com/s/%s/%s' % (account_pid, release_pid),
  67. query), {'force_smil_url': True}),
  68. 'ie_key': 'ThePlatform',
  69. })
  70. return info