mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.7 KiB
Python
91 lines
3.7 KiB
Python
9 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
6 years ago
|
import re
|
||
|
|
||
8 years ago
|
from .adobepass import AdobePassIE
|
||
|
from ..utils import (
|
||
|
smuggle_url,
|
||
|
update_url_query,
|
||
|
int_or_none,
|
||
|
)
|
||
9 years ago
|
|
||
|
|
||
8 years ago
|
class BravoTVIE(AdobePassIE):
|
||
4 years ago
|
_VALID_URL = r'https?://(?:www\.)?(?P<req_id>bravotv|oxygen)\.com/(?:[^/]+/)+(?P<id>[^/?#]+)'
|
||
8 years ago
|
_TESTS = [{
|
||
6 years ago
|
'url': 'https://www.bravotv.com/top-chef/season-16/episode-15/videos/the-top-chef-season-16-winner-is',
|
||
|
'md5': 'e34684cfea2a96cd2ee1ef3a60909de9',
|
||
9 years ago
|
'info_dict': {
|
||
6 years ago
|
'id': 'epL0pmK1kQlT',
|
||
9 years ago
|
'ext': 'mp4',
|
||
6 years ago
|
'title': 'The Top Chef Season 16 Winner Is...',
|
||
|
'description': 'Find out who takes the title of Top Chef!',
|
||
9 years ago
|
'uploader': 'NBCU-BRAV',
|
||
6 years ago
|
'upload_date': '20190314',
|
||
|
'timestamp': 1552591860,
|
||
9 years ago
|
}
|
||
8 years ago
|
}, {
|
||
|
'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1',
|
||
|
'only_matching': True,
|
||
4 years ago
|
}, {
|
||
|
'url': 'https://www.oxygen.com/in-ice-cold-blood/season-2/episode-16/videos/handling-the-horwitz-house-after-the-murder-season-2',
|
||
|
'only_matching': True,
|
||
8 years ago
|
}]
|
||
9 years ago
|
|
||
|
def _real_extract(self, url):
|
||
4 years ago
|
site, display_id = re.match(self._VALID_URL, url).groups()
|
||
8 years ago
|
webpage = self._download_webpage(url, display_id)
|
||
|
settings = self._parse_json(self._search_regex(
|
||
6 years ago
|
r'<script[^>]+data-drupal-selector="drupal-settings-json"[^>]*>({.+?})</script>', webpage, 'drupal settings'),
|
||
8 years ago
|
display_id)
|
||
|
info = {}
|
||
|
query = {
|
||
|
'mbr': 'true',
|
||
|
}
|
||
|
account_pid, release_pid = [None] * 2
|
||
6 years ago
|
tve = settings.get('ls_tve')
|
||
8 years ago
|
if tve:
|
||
|
query['manifest'] = 'm3u'
|
||
6 years ago
|
mobj = re.search(r'<[^>]+id="pdk-player"[^>]+data-url=["\']?(?:https?:)?//player\.theplatform\.com/p/([^/]+)/(?:[^/]+/)*select/([^?#&"\']+)', webpage)
|
||
|
if mobj:
|
||
|
account_pid, tp_path = mobj.groups()
|
||
|
release_pid = tp_path.strip('/').split('/')[-1]
|
||
|
else:
|
||
|
account_pid = 'HNK2IC'
|
||
|
tp_path = release_pid = tve['release_pid']
|
||
8 years ago
|
if tve.get('entitlement') == 'auth':
|
||
6 years ago
|
adobe_pass = settings.get('tve_adobe_auth', {})
|
||
4 years ago
|
if site == 'bravotv':
|
||
|
site = 'bravo'
|
||
8 years ago
|
resource = self._get_mvpd_resource(
|
||
4 years ago
|
adobe_pass.get('adobePassResourceId') or site,
|
||
8 years ago
|
tve['title'], release_pid, tve.get('rating'))
|
||
|
query['auth'] = self._extract_mvpd_auth(
|
||
4 years ago
|
url, release_pid,
|
||
|
adobe_pass.get('adobePassRequestorId') or site, resource)
|
||
8 years ago
|
else:
|
||
6 years ago
|
shared_playlist = settings['ls_playlist']
|
||
8 years ago
|
account_pid = shared_playlist['account_pid']
|
||
|
metadata = shared_playlist['video_metadata'][shared_playlist['default_clip']]
|
||
6 years ago
|
tp_path = release_pid = metadata.get('release_pid')
|
||
|
if not release_pid:
|
||
|
release_pid = metadata['guid']
|
||
|
tp_path = 'media/guid/2140479951/' + release_pid
|
||
8 years ago
|
info.update({
|
||
|
'title': metadata['title'],
|
||
|
'description': metadata.get('description'),
|
||
|
'season_number': int_or_none(metadata.get('season_num')),
|
||
|
'episode_number': int_or_none(metadata.get('episode_num')),
|
||
|
})
|
||
|
query['switch'] = 'progressive'
|
||
|
info.update({
|
||
|
'_type': 'url_transparent',
|
||
|
'id': release_pid,
|
||
|
'url': smuggle_url(update_url_query(
|
||
6 years ago
|
'http://link.theplatform.com/s/%s/%s' % (account_pid, tp_path),
|
||
8 years ago
|
query), {'force_smil_url': True}),
|
||
|
'ie_key': 'ThePlatform',
|
||
|
})
|
||
|
return info
|