2 from __future__
import unicode_literals
8 from .adobepass
import AdobePassIE
9 from .common
import InfoExtractor
10 from ..compat
import (
11 compat_etree_fromstring
,
14 compat_urllib_parse_urlparse
,
16 compat_xml_parse_error
,
40 class BrightcoveLegacyIE(InfoExtractor
):
41 IE_NAME
= 'brightcove:legacy'
42 _VALID_URL
= r
'(?:https?://.*brightcove\.com/(services|viewer).*?\?|brightcove:)(?P<query>.*)'
46 # From http://www.8tv.cat/8aldia/videos/xavier-sala-i-martin-aquesta-tarda-a-8-al-dia/
47 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1654948606001&flashID=myExperience&%40videoPlayer=2371591881001',
48 'md5': '5423e113865d26e40624dce2e4b45d95',
49 'note': 'Test Brightcove downloads and detection in GenericIE',
51 'id': '2371591881001',
53 'title': 'Xavier Sala i Martín: “Un banc que no presta és un banc zombi que no serveix per a res”',
55 'description': 'md5:a950cc4285c43e44d763d036710cd9cd',
56 'timestamp': 1368213670,
57 'upload_date': '20130510',
58 'uploader_id': '1589608506001',
60 'skip': 'The player has been deactivated by the content owner',
63 # From http://medianetwork.oracle.com/video/player/1785452137001
64 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1217746023001&flashID=myPlayer&%40videoPlayer=1785452137001',
66 'id': '1785452137001',
68 'title': 'JVMLS 2012: Arrays 2.0 - Opportunities and Challenges',
69 'description': 'John Rose speaks at the JVM Language Summit, August 1, 2012.',
71 'timestamp': 1344975024,
72 'upload_date': '20120814',
73 'uploader_id': '1460825906',
75 'skip': 'video not playable',
78 # From http://mashable.com/2013/10/26/thermoelectric-bracelet-lets-you-control-your-body-temperature/
79 'url': 'http://c.brightcove.com/services/viewer/federated_f9?&playerID=1265504713001&publisherID=AQ%7E%7E%2CAAABBzUwv1E%7E%2CxP-xFHVUstiMFlNYfvF4G9yFnNaqCw_9&videoID=2750934548001',
81 'id': '2750934548001',
83 'title': 'This Bracelet Acts as a Personal Thermostat',
84 'description': 'md5:547b78c64f4112766ccf4e151c20b6a0',
85 # 'uploader': 'Mashable',
86 'timestamp': 1382041798,
87 'upload_date': '20131017',
88 'uploader_id': '1130468786001',
92 # test that the default referer works
93 # from http://national.ballet.ca/interact/video/Lost_in_Motion_II/
94 'url': 'http://link.brightcove.com/services/player/bcpid756015033001?bckey=AQ~~,AAAApYJi_Ck~,GxhXCegT1Dp39ilhXuxMJxasUhVNZiil&bctid=2878862109001',
96 'id': '2878862109001',
98 'title': 'Lost in Motion II',
99 'description': 'md5:363109c02998fee92ec02211bd8000df',
100 'uploader': 'National Ballet of Canada',
102 'skip': 'Video gone',
105 # test flv videos served by akamaihd.net
106 # From http://www.redbull.com/en/bike/stories/1331655643987/replay-uci-dh-world-cup-2014-from-fort-william
107 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?%40videoPlayer=ref%3Aevent-stream-356&linkBaseURL=http%3A%2F%2Fwww.redbull.com%2Fen%2Fbike%2Fvideos%2F1331655630249%2Freplay-uci-fort-william-2014-dh&playerKey=AQ%7E%7E%2CAAAApYJ7UqE%7E%2Cxqr_zXk0I-zzNndy8NlHogrCb5QdyZRf&playerID=1398061561001#__youtubedl_smuggle=%7B%22Referer%22%3A+%22http%3A%2F%2Fwww.redbull.com%2Fen%2Fbike%2Fstories%2F1331655643987%2Freplay-uci-dh-world-cup-2014-from-fort-william%22%7D',
108 # The md5 checksum changes on each download
110 'id': '3750436379001',
112 'title': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
113 'uploader': 'RBTV Old (do not use)',
114 'description': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
115 'timestamp': 1409122195,
116 'upload_date': '20140827',
117 'uploader_id': '710858724001',
119 'skip': 'Video gone',
122 # playlist with 'videoList'
123 # from http://support.brightcove.com/en/video-cloud/docs/playlist-support-single-video-players
124 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=3550052898001&playerKey=AQ%7E%7E%2CAAABmA9XpXk%7E%2C-Kp7jNgisre1fG5OdqpAFUTcs0lP_ZoL',
127 'id': '3550319591001',
129 'playlist_mincount': 7,
130 'skip': 'Unsupported URL',
133 # playlist with 'playlistTab' (https://github.com/ytdl-org/youtube-dl/issues/9965)
134 'url': 'http://c.brightcove.com/services/json/experience/runtime/?command=get_programming_for_experience&playerKey=AQ%7E%7E,AAABXlLMdok%7E,NJ4EoMlZ4rZdx9eU1rkMVd8EaYPBBUlg',
136 'id': '1522758701001',
137 'title': 'Lesson 08',
139 'playlist_mincount': 10,
140 'skip': 'Unsupported URL',
143 # playerID inferred from bcpid
144 # from http://www.un.org/chinese/News/story.asp?NewsID=27724
145 'url': 'https://link.brightcove.com/services/player/bcpid1722935254001/?bctid=5360463607001&autoStart=false&secureConnections=true&width=650&height=350',
146 'only_matching': True, # Tested in GenericIE
151 def _build_brightcove_url(cls
, object_str
):
153 Build a Brightcove url from a xml string containing
154 <object class="BrightcoveExperience">{params}</object>
157 # Fix up some stupid HTML, see https://github.com/ytdl-org/youtube-dl/issues/1553
158 object_str
= re
.sub(r
'(<param(?:\s+[a-zA-Z0-9_]+="[^"]*")*)>',
159 lambda m
: m
.group(1) + '/>', object_str
)
160 # Fix up some stupid XML, see https://github.com/ytdl-org/youtube-dl/issues/1608
161 object_str
= object_str
.replace('<--', '<!--')
162 # remove namespace to simplify extraction
163 object_str
= re
.sub(r
'(<object[^>]*)(xmlns=".*?")', r
'\1', object_str
)
164 object_str
= fix_xml_ampersands(object_str
)
167 object_doc
= compat_etree_fromstring(object_str
.encode('utf-8'))
168 except compat_xml_parse_error
:
171 fv_el
= find_xpath_attr(object_doc
, './param', 'name', 'flashVars')
172 if fv_el
is not None:
175 for k
, v
in compat_parse_qs(fv_el
.attrib
['value']).items())
179 data_url
= object_doc
.attrib
.get('data', '')
180 data_url_params
= compat_parse_qs(compat_urllib_parse_urlparse(data_url
).query
)
182 def find_param(name
):
183 if name
in flashvars
:
184 return flashvars
[name
]
185 node
= find_xpath_attr(object_doc
, './param', 'name', name
)
187 return node
.attrib
['value']
188 return data_url_params
.get(name
)
192 playerID
= find_param('playerID') or find_param('playerId')
194 raise ExtractorError('Cannot find player ID')
195 params
['playerID'] = playerID
197 playerKey
= find_param('playerKey')
198 # Not all pages define this value
199 if playerKey
is not None:
200 params
['playerKey'] = playerKey
201 # These fields hold the id of the video
202 videoPlayer
= find_param('@videoPlayer') or find_param('videoId') or find_param('videoID') or find_param('@videoList')
203 if videoPlayer
is not None:
204 if isinstance(videoPlayer
, list):
205 videoPlayer
= videoPlayer
[0]
206 videoPlayer
= videoPlayer
.strip()
207 # UUID is also possible for videoPlayer (e.g.
208 # http://www.popcornflix.com/hoodies-vs-hooligans/7f2d2b87-bbf2-4623-acfb-ea942b4f01dd
209 # or http://www8.hp.com/cn/zh/home.html)
211 r
'^(?:\d+|[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{12})$',
212 videoPlayer
) or videoPlayer
.startswith('ref:')):
214 params
['@videoPlayer'] = videoPlayer
215 linkBase
= find_param('linkBaseURL')
216 if linkBase
is not None:
217 params
['linkBaseURL'] = linkBase
218 return cls
._make
_brightcove
_url
(params
)
221 def _build_brightcove_url_from_js(cls
, object_js
):
222 # The layout of JS is as follows:
223 # customBC.createVideo = function (width, height, playerID, playerKey, videoPlayer, VideoRandomID) {
224 # // build Brightcove <object /> XML
227 r
'''(?x)customBC\.createVideo\(
228 .*? # skipping width and height
229 ["\'](?P
<playerID
>\d
+)["\']\s*,\s* # playerID
230 ["\'](?P
<playerKey
>AQ
[^
"\']{48})[^"\']*["\']\s*,\s* # playerKey begins with AQ and is 50 characters
231 # in length, however it's appended to itself
232 # in places, so truncate
233 ["\'](?P
<videoID
>\d
+)["\'] # @videoPlayer
236 return cls._make_brightcove_url(m.groupdict())
239 def _make_brightcove_url(cls, params):
240 return update_url_query(
241 'http://c.brightcove.com/services/viewer/htmlFederated', params)
244 def _extract_brightcove_url(cls, webpage):
245 """Try to extract the brightcove url from the webpage, returns None
248 urls = cls._extract_brightcove_urls(webpage)
249 return urls[0] if urls else None
252 def _extract_brightcove_urls(cls, webpage):
253 """Return a list of all Brightcove URLs from the webpage """
258 (?:property|itemprop)=([\'"])(?
:og
:video|embedURL
)\
1[^
>]+
259 content
=([\'"])(?P<url>https?://(?:secure|c)\.brightcove.com/(?:(?!\2).)+)\2
262 url = unescapeHTML(url_m.group('url'))
263 # Some sites don't add it, we can't download with this url, for example:
264 # http://www.ktvu.com/videos/news/raw-video-caltrain-releases-video-of-man-almost/vCTZdY/
265 if 'playerKey' in url or 'videoId' in url or 'idVideo' in url:
268 matches = re.findall(
271 [^>]+?class=[\'"][^
>]*?BrightcoveExperience
.*?
[\'"] |
272 [^>]*?>\s*<param\s+name="movie
"\s+value="https?
://[^
/]*brightcove\
.com
/
273 ).+?
>\s
*</object>''',
276 return list(filter(None, [cls._build_brightcove_url(m) for m in matches]))
278 matches = re.findall(r'(customBC\.createVideo\(.+?\);)', webpage)
280 return list(filter(None, [
281 cls._build_brightcove_url_from_js(custom_bc)
282 for custom_bc in matches]))
283 return [src for _, src in re.findall(
284 r'<iframe[^>]+src=([\'"])((?:https?:)?//link\.brightcove\.com/services/player/(?!\1).+)\1', webpage)]
286 def _real_extract(self, url):
287 url, smuggled_data = unsmuggle_url(url, {})
289 # Change the 'videoId' and others field to '@videoPlayer'
290 url = re.sub(r'(?<=[?&])(videoI(d|D)|idVideo|bctid)', '%40videoPlayer', url)
291 # Change bckey (used by bcove.me urls) to playerKey
292 url = re.sub(r'(?<=[?&])bckey', 'playerKey', url)
293 mobj = re.match(self._VALID_URL, url)
294 query_str = mobj.group('query')
295 query = compat_urlparse.parse_qs(query_str)
297 videoPlayer = query.get('@videoPlayer')
299 # We set the original url as the default 'Referer' header
300 referer = query.get('linkBaseURL', [None])[0] or smuggled_data.get('Referer', url)
301 video_id = videoPlayer[0]
302 if 'playerID' not in query:
303 mobj = re.search(r'/bcpid(\d+)', url)
305 query['playerID'] = [mobj.group(1)]
306 publisher_id = query.get('publisherId')
307 if publisher_id and publisher_id[0].isdigit():
308 publisher_id = publisher_id[0]
310 player_key = query.get('playerKey')
311 if player_key and ',' in player_key[0]:
312 player_key = player_key[0]
314 player_id = query.get('playerID')
315 if player_id and player_id[0].isdigit():
318 headers['Referer'] = referer
319 player_page = self._download_webpage(
320 'http://link.brightcove.com/services/player/bcpid' + player_id[0],
321 video_id, headers=headers, fatal=False)
323 player_key = self._search_regex(
324 r'<param\s+name="playerKey"\s+value="([\w~,-]+)"',
325 player_page, 'player key', fatal=False)
327 enc_pub_id = player_key.split(',')[1].replace('~', '=')
328 publisher_id = struct.unpack('>Q', base64.urlsafe_b64decode(enc_pub_id))[0]
330 brightcove_new_url = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' % (publisher_id, video_id)
332 brightcove_new_url = smuggle_url(brightcove_new_url, {'referrer': referer})
333 return self.url_result(brightcove_new_url, BrightcoveNewIE.ie_key(), video_id)
334 # TODO: figure out if it's possible to extract playlistId from playerKey
335 # elif 'playerKey' in query:
336 # player_key = query['playerKey']
337 # return self._get_playlist_info(player_key[0])
338 raise UnsupportedError(url)
341 class BrightcoveNewIE(AdobePassIE):
342 IE_NAME = 'brightcove:new'
343 _VALID_URL = r'https?://players\.brightcove\.net/(?P<account_id>\d+)/(?P<player_id>[^/]+)_(?P<embed>[^/]+)/index\.html\?.*(?P<content_type>video|playlist)Id=(?P<video_id>\d+|ref:[^&]+)'
345 'url': 'http://players.brightcove.net/929656772001/e41d32dc-ec74-459e-a845-6c69f7b724ea_default/index.html?videoId=4463358922001',
346 'md5': 'c8100925723840d4b0d243f7025703be',
348 'id': '4463358922001',
350 'title': 'Meet the man behind Popcorn Time',
351 'description': 'md5:eac376a4fe366edc70279bfb681aea16',
353 'timestamp': 1441391203,
354 'upload_date': '20150904',
355 'uploader_id': '929656772001',
356 'formats': 'mincount:20',
360 'url': 'http://players.brightcove.net/4036320279001/5d112ed9-283f-485f-a7f9-33f42e8bc042_default/index.html?videoId=4279049078001',
362 'id': '4279049078001',
364 'title': 'Titansgrave: Chapter 0',
365 'description': 'Titansgrave: Chapter 0',
366 'duration': 1242.058,
367 'timestamp': 1433556729,
368 'upload_date': '20150606',
369 'uploader_id': '4036320279001',
370 'formats': 'mincount:39',
374 'skip_download': True,
378 'url': 'https://players.brightcove.net/1752604059001/S13cJdUBz_default/index.html?playlistId=5718313430001',
380 'id': '5718313430001',
381 'title': 'No Audio Playlist',
386 'skip_download': True,
389 'url': 'http://players.brightcove.net/5690807595001/HyZNerRl7_default/index.html?playlistId=5743160747001',
390 'only_matching': True,
392 # ref: prefixed video id
393 'url': 'http://players.brightcove.net/3910869709001/21519b5c-4b3b-4363-accb-bdc8f358f823_default/index.html?videoId=ref:7069442',
394 'only_matching': True,
396 # non numeric ref: prefixed video id
397 'url': 'http://players.brightcove.net/710858724001/default_default/index.html?videoId=ref:event-stream-356',
398 'only_matching': True,
400 # unavailable video without message but with error_code
401 'url': 'http://players.brightcove.net/1305187701/c832abfb-641b-44eb-9da0-2fe76786505f_default/index.html?videoId=4377407326001',
402 'only_matching': True,
406 def _extract_url(ie, webpage):
407 urls = BrightcoveNewIE._extract_urls(ie, webpage)
408 return urls[0] if urls else None
411 def _extract_urls(ie, webpage):
413 # 1. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideoiniframe
414 # 2. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#tag
415 # 3. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideousingjavascript
416 # 4. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/in-page-embed-player-implementation.html
417 # 5. https://support.brightcove.com/en/video-cloud/docs/dynamically-assigning-videos-player
421 # Look for iframe embeds [1]
422 for _, url in re.findall(
423 r'<iframe[^>]+src=(["\'])((?:https?:)?//players\.brightcove\.net/\d+/[^/]+/index\.html.+?)\1', webpage):
424 entries.append(url if url.startswith('http') else 'http:' + url)
426 # Look for <video> tags [2] and embed_in_page embeds [3]
428 for video, script_tag, account_id, player_id, embed in re.findall(
430 (<video(?
:-js
)?\s
+[^
>]*\bdata
-video
-id\s
*=\s
*['"]?[^>]+>)
433 src=["\'](?:https?:)?//players\.brightcove\.net/
434 (\d+)/([^/]+)_([^/]+)/index(?:\.min)?\.js
438 attrs = extract_attributes(video)
440 # According to examples from [4] it's unclear whether video
id
441 # may be optional and what to do when it is
442 video_id
= attrs
.get('data-video-id')
446 account_id
= account_id
or attrs
.get('data-account')
450 player_id
= player_id
or attrs
.get('data-player') or 'default'
451 embed
= embed
or attrs
.get('data-embed') or 'default'
453 bc_url
= 'http://players.brightcove.net/%s/%s_%s/index.html?videoId=%s' % (
454 account_id
, player_id
, embed
, video_id
)
456 # Some brightcove videos may be embedded with video tag only and
457 # without script tag or any mentioning of brightcove at all. Such
458 # embeds are considered ambiguous since they are matched based only
459 # on data-video-id and data-account attributes and in the wild may
460 # not be brightcove embeds at all. Let's check reconstructed
461 # brightcove URLs in case of such embeds and only process valid
462 # ones. By this we ensure there is indeed a brightcove embed.
463 if not script_tag
and not ie
._is
_valid
_url
(
464 bc_url
, video_id
, 'possible brightcove video'):
467 entries
.append(bc_url
)
471 def _parse_brightcove_metadata(self
, json_data
, video_id
, headers
={}):
472 title
= json_data
['name'].strip()
476 sources
= json_data
.get('sources') or []
477 for source
in sources
:
478 container
= source
.get('container')
479 ext
= mimetype2ext(source
.get('type'))
480 src
= source
.get('src')
481 skip_unplayable
= not self
._downloader
.params
.get('allow_unplayable_formats')
482 # https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
483 if skip_unplayable
and (container
== 'WVM' or source
.get('key_systems')):
486 elif ext
== 'ism' and skip_unplayable
:
488 elif ext
== 'm3u8' or container
== 'M2TS':
491 formats
.extend(self
._extract
_m
3u8_formats
(
492 src
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False))
496 formats
.extend(self
._extract
_mpd
_formats
(src
, video_id
, 'dash', fatal
=False))
498 streaming_src
= source
.get('streaming_src')
499 stream_name
, app_name
= source
.get('stream_name'), source
.get('app_name')
500 if not src
and not streaming_src
and (not stream_name
or not app_name
):
502 tbr
= float_or_none(source
.get('avg_bitrate'), 1000)
503 height
= int_or_none(source
.get('height'))
504 width
= int_or_none(source
.get('width'))
507 'filesize': int_or_none(source
.get('size')),
508 'container': container
,
509 'ext': ext
or container
.lower(),
511 if width
== 0 and height
== 0:
519 'vcodec': source
.get('codec'),
522 def build_format_id(kind
):
525 format_id
+= '-%dk' % int(tbr
)
527 format_id
+= '-%dp' % height
530 if src
or streaming_src
:
532 'url': src
or streaming_src
,
533 'format_id': build_format_id('http' if src
else 'http-streaming'),
534 'source_preference': 0 if src
else -1,
539 'play_path': stream_name
,
540 'format_id': build_format_id('rtmp'),
545 errors
= json_data
.get('errors')
548 self
.raise_no_formats(
549 error
.get('message') or error
.get('error_subcode') or error
['error_code'], expected
=True)
550 elif (not self
._downloader
.params
.get('allow_unplayable_formats')
551 and sources
and num_drm_sources
== len(sources
)):
552 raise ExtractorError('This video is DRM protected.', expected
=True)
554 self
._sort
_formats
(formats
)
557 f
.setdefault('http_headers', {}).update(headers
)
560 for text_track
in json_data
.get('text_tracks', []):
561 if text_track
.get('kind') != 'captions':
563 text_track_url
= url_or_none(text_track
.get('src'))
564 if not text_track_url
:
566 lang
= (str_or_none(text_track
.get('srclang'))
567 or str_or_none(text_track
.get('label')) or 'en').lower()
568 subtitles
.setdefault(lang
, []).append({
569 'url': text_track_url
,
573 duration
= float_or_none(json_data
.get('duration'), 1000)
574 if duration
is not None and duration
<= 0:
579 'title': self
._live
_title
(title
) if is_live
else title
,
580 'description': clean_html(json_data
.get('description')),
581 'thumbnail': json_data
.get('thumbnail') or json_data
.get('poster'),
582 'duration': duration
,
583 'timestamp': parse_iso8601(json_data
.get('published_at')),
584 'uploader_id': json_data
.get('account_id'),
586 'subtitles': subtitles
,
587 'tags': json_data
.get('tags', []),
591 def _real_extract(self
, url
):
592 url
, smuggled_data
= unsmuggle_url(url
, {})
593 self
._initialize
_geo
_bypass
({
594 'countries': smuggled_data
.get('geo_countries'),
595 'ip_blocks': smuggled_data
.get('geo_ip_blocks'),
598 account_id
, player_id
, embed
, content_type
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
600 policy_key_id
= '%s_%s' % (account_id
, player_id
)
601 policy_key
= self
._downloader
.cache
.load('brightcove', policy_key_id
)
602 policy_key_extracted
= False
603 store_pk
= lambda x
: self
._downloader
.cache
.store('brightcove', policy_key_id
, x
)
605 def extract_policy_key():
606 base_url
= 'http://players.brightcove.net/%s/%s_%s/' % (account_id
, player_id
, embed
)
607 config
= self
._download
_json
(
608 base_url
+ 'config.json', video_id
, fatal
=False) or {}
609 policy_key
= try_get(
610 config
, lambda x
: x
['video_cloud']['policy_key'])
612 webpage
= self
._download
_webpage
(
613 base_url
+ 'index.min.js', video_id
)
615 catalog
= self
._search
_regex
(
616 r
'catalog\(({.+?})\);', webpage
, 'catalog', default
=None)
618 catalog
= self
._parse
_json
(
619 js_to_json(catalog
), video_id
, fatal
=False)
621 policy_key
= catalog
.get('policyKey')
624 policy_key
= self
._search
_regex
(
625 r
'policyKey\s*:\s*(["\'])(?P
<pk
>.+?
)\
1',
626 webpage, 'policy key
', group='pk
')
631 api_url = 'https
://edge
.api
.brightcove
.com
/playback
/v1
/accounts
/%s/%ss/%s' % (account_id, content_type, video_id)
633 referrer = smuggled_data.get('referrer
')
637 'Origin
': re.search(r'https?
://[^
/]+', referrer).group(0),
642 policy_key = extract_policy_key()
643 policy_key_extracted = True
644 headers['Accept
'] = 'application
/json
;pk
=%s' % policy_key
646 json_data = self._download_json(api_url, video_id, headers=headers)
648 except ExtractorError as e:
649 if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 403):
650 json_data = self._parse_json(e.cause.read().decode(), video_id)[0]
651 message = json_data.get('message
') or json_data['error_code
']
652 if json_data.get('error_subcode
') == 'CLIENT_GEO
':
653 self.raise_geo_restricted(msg=message)
654 elif json_data.get('error_code
') == 'INVALID_POLICY_KEY
' and not policy_key_extracted:
658 raise ExtractorError(message, expected=True)
661 errors = json_data.get('errors
')
662 if errors and errors[0].get('error_subcode
') == 'TVE_AUTH
':
663 custom_fields = json_data['custom_fields
']
664 tve_token = self._extract_mvpd_auth(
665 smuggled_data['source_url
'], video_id,
666 custom_fields['bcadobepassrequestorid
'],
667 custom_fields['bcadobepassresourceid
'])
668 json_data = self._download_json(
669 api_url, video_id, headers={
670 'Accept
': 'application
/json
;pk
=%s' % policy_key
672 'tveToken
': tve_token,
675 if content_type == 'playlist
':
676 return self.playlist_result(
677 [self._parse_brightcove_metadata(vid, vid.get('id'), headers)
678 for vid in json_data.get('videos
', []) if vid.get('id')],
679 json_data.get('id'), json_data.get('name
'),
680 json_data.get('description
'))
682 return self._parse_brightcove_metadata(
683 json_data, video_id, headers=headers)