1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-10-06 16:26:52 +02:00
This commit is contained in:
Clay Freeman 2024-07-27 23:05:34 +09:00 committed by GitHub
commit cd993a7e34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 4 deletions

View File

@ -11,6 +11,8 @@ from ..compat import (
compat_etree_fromstring, compat_etree_fromstring,
compat_HTTPError, compat_HTTPError,
compat_parse_qs, compat_parse_qs,
compat_str,
compat_urllib_parse_urlencode,
compat_urllib_parse_urlparse, compat_urllib_parse_urlparse,
compat_urlparse, compat_urlparse,
compat_xml_parse_error, compat_xml_parse_error,
@ -468,7 +470,7 @@ class BrightcoveNewIE(AdobePassIE):
return entries return entries
def _parse_brightcove_metadata(self, json_data, video_id, headers={}): def _parse_brightcove_metadata(self, json_data, video_id, headers={}, options={}):
title = json_data['name'].strip() title = json_data['name'].strip()
num_drm_sources = 0 num_drm_sources = 0
@ -477,7 +479,7 @@ class BrightcoveNewIE(AdobePassIE):
for source in sources: for source in sources:
container = source.get('container') container = source.get('container')
ext = mimetype2ext(source.get('type')) ext = mimetype2ext(source.get('type'))
src = source.get('src') src = self._preprocess_metadata_url(source.get('src'), options)
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object # https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
if container == 'WVM' or source.get('key_systems'): if container == 'WVM' or source.get('key_systems'):
num_drm_sources += 1 num_drm_sources += 1
@ -586,6 +588,17 @@ class BrightcoveNewIE(AdobePassIE):
'is_live': is_live, 'is_live': is_live,
} }
def _preprocess_metadata_url(self, url, options={}):
url = compat_urllib_parse_urlparse(url)._asdict()
query = dict(compat_parse_qs(url['query']))
if options.get('akamai_token') is not None:
query['hdnts'] = options.get('akamai_token')
url['query'] = compat_urllib_parse_urlencode(query)
return compat_urlparse.urlunparse(tuple(url.values()))
def _real_extract(self, url): def _real_extract(self, url):
url, smuggled_data = unsmuggle_url(url, {}) url, smuggled_data = unsmuggle_url(url, {})
self._initialize_geo_bypass({ self._initialize_geo_bypass({
@ -670,12 +683,16 @@ class BrightcoveNewIE(AdobePassIE):
'tveToken': tve_token, 'tveToken': tve_token,
}) })
options = {
'akamai_token': smuggled_data.get('akamai_token')
}
if content_type == 'playlist': if content_type == 'playlist':
return self.playlist_result( return self.playlist_result(
[self._parse_brightcove_metadata(vid, vid.get('id'), headers) [self._parse_brightcove_metadata(vid, vid.get('id'), headers=headers, options=options)
for vid in json_data.get('videos', []) if vid.get('id')], for vid in json_data.get('videos', []) if vid.get('id')],
json_data.get('id'), json_data.get('name'), json_data.get('id'), json_data.get('name'),
json_data.get('description')) json_data.get('description'))
return self._parse_brightcove_metadata( return self._parse_brightcove_metadata(
json_data, video_id, headers=headers) json_data, video_id, headers=headers, options=options)

View File

@ -0,0 +1,26 @@
# coding: utf-8
from __future__ import unicode_literals
from .brightcove import BrightcoveNewIE
from .common import InfoExtractor
from ..utils import smuggle_url
class CSpanLiveIE(InfoExtractor):
IE_NAME = 'cspanlive'
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/3162030207001/2B2qWQJYYM_default/index.html?videoId=%s'
_VALID_URL = r'^https?://(?:www\.)?c-span\.org/networks'
def _real_extract(self, url):
webpage = self._download_webpage(url, 'stream')
akamai_token = self._html_search_regex(r'data-akamaitoken="([^"]+)"', webpage, 'akamai_token')
video_id = self._html_search_regex(r'data-bcid="([^"]+)"', webpage, 'video_id')
brightcove_url = smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {
'akamai_token': akamai_token,
'source_url': url
})
return self.url_result(brightcove_url, ie=BrightcoveNewIE.ie_key(), video_id=video_id)

View File

@ -272,6 +272,7 @@ from .crunchyroll import (
CrunchyrollShowPlaylistIE CrunchyrollShowPlaylistIE
) )
from .cspan import CSpanIE from .cspan import CSpanIE
from .cspanlive import CSpanLiveIE
from .ctsnews import CtsNewsIE from .ctsnews import CtsNewsIE
from .ctv import CTVIE from .ctv import CTVIE
from .ctvnews import CTVNewsIE from .ctvnews import CTVNewsIE