logo

youtube-dl

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

bravotv.py (3775B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .adobepass import AdobePassIE
  5. from ..utils import (
  6. smuggle_url,
  7. update_url_query,
  8. int_or_none,
  9. )
  10. class BravoTVIE(AdobePassIE):
  11. _VALID_URL = r'https?://(?:www\.)?(?P<req_id>bravotv|oxygen)\.com/(?:[^/]+/)+(?P<id>[^/?#]+)'
  12. _TESTS = [{
  13. 'url': 'https://www.bravotv.com/top-chef/season-16/episode-15/videos/the-top-chef-season-16-winner-is',
  14. 'md5': 'e34684cfea2a96cd2ee1ef3a60909de9',
  15. 'info_dict': {
  16. 'id': 'epL0pmK1kQlT',
  17. 'ext': 'mp4',
  18. 'title': 'The Top Chef Season 16 Winner Is...',
  19. 'description': 'Find out who takes the title of Top Chef!',
  20. 'uploader': 'NBCU-BRAV',
  21. 'upload_date': '20190314',
  22. 'timestamp': 1552591860,
  23. }
  24. }, {
  25. 'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1',
  26. 'only_matching': True,
  27. }, {
  28. 'url': 'https://www.oxygen.com/in-ice-cold-blood/season-2/episode-16/videos/handling-the-horwitz-house-after-the-murder-season-2',
  29. 'only_matching': True,
  30. }]
  31. def _real_extract(self, url):
  32. site, display_id = re.match(self._VALID_URL, url).groups()
  33. webpage = self._download_webpage(url, display_id)
  34. settings = self._parse_json(self._search_regex(
  35. r'<script[^>]+data-drupal-selector="drupal-settings-json"[^>]*>({.+?})</script>', webpage, 'drupal settings'),
  36. display_id)
  37. info = {}
  38. query = {
  39. 'mbr': 'true',
  40. }
  41. account_pid, release_pid = [None] * 2
  42. tve = settings.get('ls_tve')
  43. if tve:
  44. query['manifest'] = 'm3u'
  45. mobj = re.search(r'<[^>]+id="pdk-player"[^>]+data-url=["\']?(?:https?:)?//player\.theplatform\.com/p/([^/]+)/(?:[^/]+/)*select/([^?#&"\']+)', webpage)
  46. if mobj:
  47. account_pid, tp_path = mobj.groups()
  48. release_pid = tp_path.strip('/').split('/')[-1]
  49. else:
  50. account_pid = 'HNK2IC'
  51. tp_path = release_pid = tve['release_pid']
  52. if tve.get('entitlement') == 'auth':
  53. adobe_pass = settings.get('tve_adobe_auth', {})
  54. if site == 'bravotv':
  55. site = 'bravo'
  56. resource = self._get_mvpd_resource(
  57. adobe_pass.get('adobePassResourceId') or site,
  58. tve['title'], release_pid, tve.get('rating'))
  59. query['auth'] = self._extract_mvpd_auth(
  60. url, release_pid,
  61. adobe_pass.get('adobePassRequestorId') or site, resource)
  62. else:
  63. shared_playlist = settings['ls_playlist']
  64. account_pid = shared_playlist['account_pid']
  65. metadata = shared_playlist['video_metadata'][shared_playlist['default_clip']]
  66. tp_path = release_pid = metadata.get('release_pid')
  67. if not release_pid:
  68. release_pid = metadata['guid']
  69. tp_path = 'media/guid/2140479951/' + release_pid
  70. info.update({
  71. 'title': metadata['title'],
  72. 'description': metadata.get('description'),
  73. 'season_number': int_or_none(metadata.get('season_num')),
  74. 'episode_number': int_or_none(metadata.get('episode_num')),
  75. })
  76. query['switch'] = 'progressive'
  77. info.update({
  78. '_type': 'url_transparent',
  79. 'id': release_pid,
  80. 'url': smuggle_url(update_url_query(
  81. 'http://link.theplatform.com/s/%s/%s' % (account_pid, tp_path),
  82. query), {'force_smil_url': True}),
  83. 'ie_key': 'ThePlatform',
  84. })
  85. return info