]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/brightcove.py
4 import xml
.etree
.ElementTree
6 from .adobepass
import AdobePassIE
7 from .common
import InfoExtractor
9 compat_etree_fromstring
,
38 class BrightcoveLegacyIE(InfoExtractor
):
39 IE_NAME
= 'brightcove:legacy'
40 _VALID_URL
= r
'(?:https?://.*brightcove\.com/(services|viewer).*?\?|brightcove:)(?P<query>.*)'
44 # From http://www.8tv.cat/8aldia/videos/xavier-sala-i-martin-aquesta-tarda-a-8-al-dia/
45 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1654948606001&flashID=myExperience&%40videoPlayer=2371591881001',
46 'md5': '5423e113865d26e40624dce2e4b45d95',
47 'note': 'Test Brightcove downloads and detection in GenericIE',
49 'id': '2371591881001',
51 'title': 'Xavier Sala i Martín: “Un banc que no presta és un banc zombi que no serveix per a res”',
53 'description': 'md5:a950cc4285c43e44d763d036710cd9cd',
54 'timestamp': 1368213670,
55 'upload_date': '20130510',
56 'uploader_id': '1589608506001',
58 'skip': 'The player has been deactivated by the content owner',
61 # From http://medianetwork.oracle.com/video/player/1785452137001
62 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1217746023001&flashID=myPlayer&%40videoPlayer=1785452137001',
64 'id': '1785452137001',
66 'title': 'JVMLS 2012: Arrays 2.0 - Opportunities and Challenges',
67 'description': 'John Rose speaks at the JVM Language Summit, August 1, 2012.',
69 'timestamp': 1344975024,
70 'upload_date': '20120814',
71 'uploader_id': '1460825906',
73 'skip': 'video not playable',
76 # From http://mashable.com/2013/10/26/thermoelectric-bracelet-lets-you-control-your-body-temperature/
77 'url': 'http://c.brightcove.com/services/viewer/federated_f9?&playerID=1265504713001&publisherID=AQ%7E%7E%2CAAABBzUwv1E%7E%2CxP-xFHVUstiMFlNYfvF4G9yFnNaqCw_9&videoID=2750934548001',
79 'id': '2750934548001',
81 'title': 'This Bracelet Acts as a Personal Thermostat',
82 'description': 'md5:547b78c64f4112766ccf4e151c20b6a0',
83 # 'uploader': 'Mashable',
84 'timestamp': 1382041798,
85 'upload_date': '20131017',
86 'uploader_id': '1130468786001',
90 # test that the default referer works
91 # from http://national.ballet.ca/interact/video/Lost_in_Motion_II/
92 'url': 'http://link.brightcove.com/services/player/bcpid756015033001?bckey=AQ~~,AAAApYJi_Ck~,GxhXCegT1Dp39ilhXuxMJxasUhVNZiil&bctid=2878862109001',
94 'id': '2878862109001',
96 'title': 'Lost in Motion II',
97 'description': 'md5:363109c02998fee92ec02211bd8000df',
98 'uploader': 'National Ballet of Canada',
100 'skip': 'Video gone',
103 # test flv videos served by akamaihd.net
104 # From http://www.redbull.com/en/bike/stories/1331655643987/replay-uci-dh-world-cup-2014-from-fort-william
105 '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',
106 # The md5 checksum changes on each download
108 'id': '3750436379001',
110 'title': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
111 'uploader': 'RBTV Old (do not use)',
112 'description': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
113 'timestamp': 1409122195,
114 'upload_date': '20140827',
115 'uploader_id': '710858724001',
117 'skip': 'Video gone',
120 # playlist with 'videoList'
121 # from http://support.brightcove.com/en/video-cloud/docs/playlist-support-single-video-players
122 'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=3550052898001&playerKey=AQ%7E%7E%2CAAABmA9XpXk%7E%2C-Kp7jNgisre1fG5OdqpAFUTcs0lP_ZoL',
125 'id': '3550319591001',
127 'playlist_mincount': 7,
128 'skip': 'Unsupported URL',
131 # playlist with 'playlistTab' (https://github.com/ytdl-org/youtube-dl/issues/9965)
132 'url': 'http://c.brightcove.com/services/json/experience/runtime/?command=get_programming_for_experience&playerKey=AQ%7E%7E,AAABXlLMdok%7E,NJ4EoMlZ4rZdx9eU1rkMVd8EaYPBBUlg',
134 'id': '1522758701001',
135 'title': 'Lesson 08',
137 'playlist_mincount': 10,
138 'skip': 'Unsupported URL',
141 # playerID inferred from bcpid
142 # from http://www.un.org/chinese/News/story.asp?NewsID=27724
143 'url': 'https://link.brightcove.com/services/player/bcpid1722935254001/?bctid=5360463607001&autoStart=false&secureConnections=true&width=650&height=350',
144 'only_matching': True, # Tested in GenericIE
149 def _build_brightcove_url(cls
, object_str
):
151 Build a Brightcove url from a xml string containing
152 <object class="BrightcoveExperience">{params}</object>
155 # Fix up some stupid HTML, see https://github.com/ytdl-org/youtube-dl/issues/1553
156 object_str
= re
.sub(r
'(<param(?:\s+[a-zA-Z0-9_]+="[^"]*")*)>',
157 lambda m
: m
.group(1) + '/>', object_str
)
158 # Fix up some stupid XML, see https://github.com/ytdl-org/youtube-dl/issues/1608
159 object_str
= object_str
.replace('<--', '<!--')
160 # remove namespace to simplify extraction
161 object_str
= re
.sub(r
'(<object[^>]*)(xmlns=".*?")', r
'\1', object_str
)
162 object_str
= fix_xml_ampersands(object_str
)
165 object_doc
= compat_etree_fromstring(object_str
.encode('utf-8'))
166 except xml
.etree
.ElementTree
.ParseError
:
169 fv_el
= find_xpath_attr(object_doc
, './param', 'name', 'flashVars')
170 if fv_el
is not None:
173 for k
, v
in compat_parse_qs(fv_el
.attrib
['value']).items())
177 data_url
= object_doc
.attrib
.get('data', '')
178 data_url_params
= parse_qs(data_url
)
180 def find_param(name
):
181 if name
in flashvars
:
182 return flashvars
[name
]
183 node
= find_xpath_attr(object_doc
, './param', 'name', name
)
185 return node
.attrib
['value']
186 return data_url_params
.get(name
)
190 playerID
= find_param('playerID') or find_param('playerId')
192 raise ExtractorError('Cannot find player ID')
193 params
['playerID'] = playerID
195 playerKey
= find_param('playerKey')
196 # Not all pages define this value
197 if playerKey
is not None:
198 params
['playerKey'] = playerKey
199 # These fields hold the id of the video
200 videoPlayer
= find_param('@videoPlayer') or find_param('videoId') or find_param('videoID') or find_param('@videoList')
201 if videoPlayer
is not None:
202 if isinstance(videoPlayer
, list):
203 videoPlayer
= videoPlayer
[0]
204 videoPlayer
= videoPlayer
.strip()
205 # UUID is also possible for videoPlayer (e.g.
206 # http://www.popcornflix.com/hoodies-vs-hooligans/7f2d2b87-bbf2-4623-acfb-ea942b4f01dd
207 # or http://www8.hp.com/cn/zh/home.html)
209 r
'^(?:\d+|[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{12})$',
210 videoPlayer
) or videoPlayer
.startswith('ref:')):
212 params
['@videoPlayer'] = videoPlayer
213 linkBase
= find_param('linkBaseURL')
214 if linkBase
is not None:
215 params
['linkBaseURL'] = linkBase
216 return cls
._make
_brightcove
_url
(params
)
219 def _build_brightcove_url_from_js(cls
, object_js
):
220 # The layout of JS is as follows:
221 # customBC.createVideo = function (width, height, playerID, playerKey, videoPlayer, VideoRandomID) {
222 # // build Brightcove <object /> XML
225 r
'''(?x)customBC\.createVideo\(
226 .*? # skipping width and height
227 ["\'](?P
<playerID
>\d
+)["\']\s*,\s* # playerID
228 ["\'](?P
<playerKey
>AQ
[^
"\']{48})[^"\']*["\']\s*,\s* # playerKey begins with AQ and is 50 characters
229 # in length, however it's appended to itself
230 # in places, so truncate
231 ["\'](?P
<videoID
>\d
+)["\'] # @videoPlayer
234 return cls._make_brightcove_url(m.groupdict())
237 def _make_brightcove_url(cls, params):
238 return update_url_query(
239 'http://c.brightcove.com/services/viewer/htmlFederated', params)
242 def _extract_brightcove_url(cls, webpage):
243 """Try to extract the brightcove url from the webpage, returns None
246 urls = cls._extract_brightcove_urls(webpage)
247 return urls[0] if urls else None
250 def _extract_brightcove_urls(cls, webpage):
251 """Return a list of all Brightcove URLs from the webpage """
256 (?:property|itemprop)=([\'"])(?
:og
:video|embedURL
)\
1[^
>]+
257 content
=([\'"])(?P<url>https?://(?:secure|c)\.brightcove.com/(?:(?!\2).)+)\2
260 url = unescapeHTML(url_m.group('url'))
261 # Some sites don't add it, we can't download with this url, for example:
262 # http://www.ktvu.com/videos/news/raw-video-caltrain-releases-video-of-man-almost/vCTZdY/
263 if 'playerKey' in url or 'videoId' in url or 'idVideo' in url:
266 matches = re.findall(
269 [^>]+?class=[\'"][^
>]*?BrightcoveExperience
.*?
[\'"] |
270 [^>]*?>\s*<param\s+name="movie
"\s+value="https?
://[^
/]*brightcove\
.com
/
271 ).+?
>\s
*</object>''',
274 return list(filter(None, [cls._build_brightcove_url(m) for m in matches]))
276 matches = re.findall(r'(customBC\.createVideo\(.+?\);)', webpage)
278 return list(filter(None, [
279 cls._build_brightcove_url_from_js(custom_bc)
280 for custom_bc in matches]))
281 return [src for _, src in re.findall(
282 r'<iframe[^>]+src=([\'"])((?:https?:)?//link\.brightcove\.com/services/player/(?!\1).+)\1', webpage)]
284 def _real_extract(self, url):
285 url, smuggled_data = unsmuggle_url(url, {})
287 # Change the 'videoId' and others field to '@videoPlayer'
288 url = re.sub(r'(?<=[?&])(videoI(d|D)|idVideo|bctid)', '%40videoPlayer', url)
289 # Change bckey (used by bcove.me urls) to playerKey
290 url = re.sub(r'(?<=[?&])bckey', 'playerKey', url)
291 mobj = self._match_valid_url(url)
292 query_str = mobj.group('query')
293 query = compat_urlparse.parse_qs(query_str)
295 videoPlayer = query.get('@videoPlayer')
297 # We set the original url as the default 'Referer' header
298 referer = query.get('linkBaseURL', [None])[0] or smuggled_data.get('Referer', url)
299 video_id = videoPlayer[0]
300 if 'playerID' not in query:
301 mobj = re.search(r'/bcpid(\d+)', url)
303 query['playerID'] = [mobj.group(1)]
304 publisher_id = query.get('publisherId')
305 if publisher_id and publisher_id[0].isdigit():
306 publisher_id = publisher_id[0]
308 player_key = query.get('playerKey')
309 if player_key and ',' in player_key[0]:
310 player_key = player_key[0]
312 player_id = query.get('playerID')
313 if player_id and player_id[0].isdigit():
316 headers['Referer'] = referer
317 player_page = self._download_webpage(
318 'http://link.brightcove.com/services/player/bcpid' + player_id[0],
319 video_id, headers=headers, fatal=False)
321 player_key = self._search_regex(
322 r'<param\s+name="playerKey"\s+value="([\w~,-]+)"',
323 player_page, 'player key', fatal=False)
325 enc_pub_id = player_key.split(',')[1].replace('~', '=')
326 publisher_id = struct.unpack('>Q', base64.urlsafe_b64decode(enc_pub_id))[0]
328 brightcove_new_url = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' % (publisher_id, video_id)
330 brightcove_new_url = smuggle_url(brightcove_new_url, {'referrer': referer})
331 return self.url_result(brightcove_new_url, BrightcoveNewIE.ie_key(), video_id)
332 # TODO: figure out if it's possible to extract playlistId from playerKey
333 # elif 'playerKey' in query:
334 # player_key = query['playerKey']
335 # return self._get_playlist_info(player_key[0])
336 raise UnsupportedError(url)
339 class BrightcoveNewIE(AdobePassIE):
340 IE_NAME = 'brightcove:new'
341 _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:[^&]+)'
343 'url': 'http://players.brightcove.net/929656772001/e41d32dc-ec74-459e-a845-6c69f7b724ea_default/index.html?videoId=4463358922001',
344 'md5': 'c8100925723840d4b0d243f7025703be',
346 'id': '4463358922001',
348 'title': 'Meet the man behind Popcorn Time',
349 'description': 'md5:eac376a4fe366edc70279bfb681aea16',
351 'timestamp': 1441391203,
352 'upload_date': '20150904',
353 'uploader_id': '929656772001',
354 'formats': 'mincount:20',
358 'url': 'http://players.brightcove.net/4036320279001/5d112ed9-283f-485f-a7f9-33f42e8bc042_default/index.html?videoId=4279049078001',
360 'id': '4279049078001',
362 'title': 'Titansgrave: Chapter 0',
363 'description': 'Titansgrave: Chapter 0',
364 'duration': 1242.058,
365 'timestamp': 1433556729,
366 'upload_date': '20150606',
367 'uploader_id': '4036320279001',
368 'formats': 'mincount:39',
372 'skip_download': True,
376 'url': 'https://players.brightcove.net/1752604059001/S13cJdUBz_default/index.html?playlistId=5718313430001',
378 'id': '5718313430001',
379 'title': 'No Audio Playlist',
384 'skip_download': True,
387 'url': 'http://players.brightcove.net/5690807595001/HyZNerRl7_default/index.html?playlistId=5743160747001',
388 'only_matching': True,
390 # ref: prefixed video id
391 'url': 'http://players.brightcove.net/3910869709001/21519b5c-4b3b-4363-accb-bdc8f358f823_default/index.html?videoId=ref:7069442',
392 'only_matching': True,
394 # non numeric ref: prefixed video id
395 'url': 'http://players.brightcove.net/710858724001/default_default/index.html?videoId=ref:event-stream-356',
396 'only_matching': True,
398 # unavailable video without message but with error_code
399 'url': 'http://players.brightcove.net/1305187701/c832abfb-641b-44eb-9da0-2fe76786505f_default/index.html?videoId=4377407326001',
400 'only_matching': True,
404 def _extract_url(ie, webpage):
405 urls = BrightcoveNewIE._extract_urls(ie, webpage)
406 return urls[0] if urls else None
409 def _extract_urls(ie, webpage):
411 # 1. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideoiniframe
412 # 2. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#tag
413 # 3. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideousingjavascript
414 # 4. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/in-page-embed-player-implementation.html
415 # 5. https://support.brightcove.com/en/video-cloud/docs/dynamically-assigning-videos-player
419 # Look for iframe embeds [1]
420 for _, url in re.findall(
421 r'<iframe[^>]+src=(["\'])((?:https?:)?//players\.brightcove\.net/\d+/[^/]+/index\.html.+?)\1', webpage):
422 entries.append(url if url.startswith('http') else 'http:' + url)
424 # Look for <video> tags [2] and embed_in_page embeds [3]
426 for video, script_tag, account_id, player_id, embed in re.findall(
428 (<video(?
:-js
)?\s
+[^
>]*\bdata
-video
-id\s
*=\s
*['"]?[^>]+>)
431 src=["\'](?:https?:)?//players\.brightcove\.net/
432 (\d+)/([^/]+)_([^/]+)/index(?:\.min)?\.js
436 attrs = extract_attributes(video)
438 # According to examples from [4] it's unclear whether video
id
439 # may be optional and what to do when it is
440 video_id
= attrs
.get('data-video-id')
444 account_id
= account_id
or attrs
.get('data-account')
448 player_id
= player_id
or attrs
.get('data-player') or 'default'
449 embed
= embed
or attrs
.get('data-embed') or 'default'
451 bc_url
= 'http://players.brightcove.net/%s/%s_%s/index.html?videoId=%s' % (
452 account_id
, player_id
, embed
, video_id
)
454 # Some brightcove videos may be embedded with video tag only and
455 # without script tag or any mentioning of brightcove at all. Such
456 # embeds are considered ambiguous since they are matched based only
457 # on data-video-id and data-account attributes and in the wild may
458 # not be brightcove embeds at all. Let's check reconstructed
459 # brightcove URLs in case of such embeds and only process valid
460 # ones. By this we ensure there is indeed a brightcove embed.
461 if not script_tag
and not ie
._is
_valid
_url
(
462 bc_url
, video_id
, 'possible brightcove video'):
465 entries
.append(bc_url
)
469 def _parse_brightcove_metadata(self
, json_data
, video_id
, headers
={}):
470 title
= json_data
['name'].strip()
472 formats
, subtitles
= [], {}
473 sources
= json_data
.get('sources') or []
474 for source
in sources
:
475 container
= source
.get('container')
476 ext
= mimetype2ext(source
.get('type'))
477 src
= source
.get('src')
478 if ext
== 'm3u8' or container
== 'M2TS':
481 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
482 src
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False)
483 subtitles
= self
._merge
_subtitles
(subtitles
, subs
)
487 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(src
, video_id
, 'dash', fatal
=False)
488 subtitles
= self
._merge
_subtitles
(subtitles
, subs
)
490 streaming_src
= source
.get('streaming_src')
491 stream_name
, app_name
= source
.get('stream_name'), source
.get('app_name')
492 if not src
and not streaming_src
and (not stream_name
or not app_name
):
494 tbr
= float_or_none(source
.get('avg_bitrate'), 1000)
495 height
= int_or_none(source
.get('height'))
496 width
= int_or_none(source
.get('width'))
499 'filesize': int_or_none(source
.get('size')),
500 'container': container
,
501 'ext': ext
or container
.lower(),
503 if width
== 0 and height
== 0:
511 'vcodec': source
.get('codec'),
514 def build_format_id(kind
):
517 format_id
+= '-%dk' % int(tbr
)
519 format_id
+= '-%dp' % height
522 if src
or streaming_src
:
524 'url': src
or streaming_src
,
525 'format_id': build_format_id('http' if src
else 'http-streaming'),
526 'source_preference': 0 if src
else -1,
531 'play_path': stream_name
,
532 'format_id': build_format_id('rtmp'),
536 # https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
537 if container
== 'WVM' or source
.get('key_systems') or ext
== 'ism':
543 errors
= json_data
.get('errors')
546 self
.raise_no_formats(
547 error
.get('message') or error
.get('error_subcode') or error
['error_code'], expected
=True)
549 self
._sort
_formats
(formats
)
552 f
.setdefault('http_headers', {}).update(headers
)
554 for text_track
in json_data
.get('text_tracks', []):
555 if text_track
.get('kind') != 'captions':
557 text_track_url
= url_or_none(text_track
.get('src'))
558 if not text_track_url
:
560 lang
= (str_or_none(text_track
.get('srclang'))
561 or str_or_none(text_track
.get('label')) or 'en').lower()
562 subtitles
.setdefault(lang
, []).append({
563 'url': text_track_url
,
567 duration
= float_or_none(json_data
.get('duration'), 1000)
568 if duration
is not None and duration
<= 0:
571 common_res
= [(160, 90), (320, 180), (480, 720), (640, 360), (768, 432), (1024, 576), (1280, 720), (1366, 768), (1920, 1080)]
572 thumb_base_url
= dict_get(json_data
, ('poster', 'thumbnail'))
574 'url': re
.sub(r
'\d+x\d+', f
'{w}x{h}', thumb_base_url
),
577 } for w
, h
in common_res
] if thumb_base_url
else None
582 'description': clean_html(json_data
.get('description')),
583 'thumbnails': thumbnails
,
584 'duration': duration
,
585 'timestamp': parse_iso8601(json_data
.get('published_at')),
586 'uploader_id': json_data
.get('account_id'),
588 'subtitles': subtitles
,
589 'tags': json_data
.get('tags', []),
593 def _real_extract(self
, url
):
594 url
, smuggled_data
= unsmuggle_url(url
, {})
595 self
._initialize
_geo
_bypass
({
596 'countries': smuggled_data
.get('geo_countries'),
597 'ip_blocks': smuggled_data
.get('geo_ip_blocks'),
600 account_id
, player_id
, embed
, content_type
, video_id
= self
._match
_valid
_url
(url
).groups()
602 policy_key_id
= '%s_%s' % (account_id
, player_id
)
603 policy_key
= self
._downloader
.cache
.load('brightcove', policy_key_id
)
604 policy_key_extracted
= False
605 store_pk
= lambda x
: self
._downloader
.cache
.store('brightcove', policy_key_id
, x
)
607 def extract_policy_key():
608 base_url
= 'http://players.brightcove.net/%s/%s_%s/' % (account_id
, player_id
, embed
)
609 config
= self
._download
_json
(
610 base_url
+ 'config.json', video_id
, fatal
=False) or {}
611 policy_key
= try_get(
612 config
, lambda x
: x
['video_cloud']['policy_key'])
614 webpage
= self
._download
_webpage
(
615 base_url
+ 'index.min.js', video_id
)
617 catalog
= self
._search
_regex
(
618 r
'catalog\(({.+?})\);', webpage
, 'catalog', default
=None)
620 catalog
= self
._parse
_json
(
621 js_to_json(catalog
), video_id
, fatal
=False)
623 policy_key
= catalog
.get('policyKey')
626 policy_key
= self
._search
_regex
(
627 r
'policyKey\s*:\s*(["\'])(?P
<pk
>.+?
)\
1',
628 webpage, 'policy key
', group='pk
')
633 api_url = 'https
://edge
.api
.brightcove
.com
/playback
/v1
/accounts
/%s/%ss/%s' % (account_id, content_type, video_id)
635 referrer = smuggled_data.get('referrer
')
639 'Origin
': re.search(r'https?
://[^
/]+', referrer).group(0),
644 policy_key = extract_policy_key()
645 policy_key_extracted = True
646 headers['Accept
'] = 'application
/json
;pk
=%s' % policy_key
648 json_data = self._download_json(api_url, video_id, headers=headers)
650 except ExtractorError as e:
651 if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 403):
652 json_data = self._parse_json(e.cause.read().decode(), video_id)[0]
653 message = json_data.get('message
') or json_data['error_code
']
654 if json_data.get('error_subcode
') == 'CLIENT_GEO
':
655 self.raise_geo_restricted(msg=message)
656 elif json_data.get('error_code
') == 'INVALID_POLICY_KEY
' and not policy_key_extracted:
660 raise ExtractorError(message, expected=True)
663 errors = json_data.get('errors
')
664 if errors and errors[0].get('error_subcode
') == 'TVE_AUTH
':
665 custom_fields = json_data['custom_fields
']
666 tve_token = self._extract_mvpd_auth(
667 smuggled_data['source_url
'], video_id,
668 custom_fields['bcadobepassrequestorid
'],
669 custom_fields['bcadobepassresourceid
'])
670 json_data = self._download_json(
671 api_url, video_id, headers={
672 'Accept
': 'application
/json
;pk
=%s' % policy_key
674 'tveToken
': tve_token,
677 if content_type == 'playlist
':
678 return self.playlist_result(
679 [self._parse_brightcove_metadata(vid, vid.get('id'), headers)
680 for vid in json_data.get('videos
', []) if vid.get('id')],
681 json_data.get('id'), json_data.get('name
'),
682 json_data.get('description
'))
684 return self._parse_brightcove_metadata(
685 json_data, video_id, headers=headers)