aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2020-12-24 12:38:04 +0100
committerRemita Amine <remitamine@gmail.com>2020-12-24 13:10:20 +0100
commitbd3844c9c25e8bbe7d7fd3e89f61088a7c163ad1 (patch)
treeb909d3bf629eaa5f9f2454596983cae38cae39ff /youtube_dl
parent7bf5e3a84aca972fe4c34135c98394ca592211ef (diff)
[brightcove] add another method to extract policyKey
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/brightcove.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/youtube_dl/extractor/brightcove.py b/youtube_dl/extractor/brightcove.py
index 000eac71c..300d75458 100644
--- a/youtube_dl/extractor/brightcove.py
+++ b/youtube_dl/extractor/brightcove.py
@@ -28,6 +28,7 @@ from ..utils import (
parse_iso8601,
smuggle_url,
str_or_none,
+ try_get,
unescapeHTML,
unsmuggle_url,
UnsupportedError,
@@ -600,24 +601,27 @@ class BrightcoveNewIE(AdobePassIE):
store_pk = lambda x: self._downloader.cache.store('brightcove', policy_key_id, x)
def extract_policy_key():
- webpage = self._download_webpage(
- 'http://players.brightcove.net/%s/%s_%s/index.min.js'
- % (account_id, player_id, embed), video_id)
-
- policy_key = None
+ base_url = 'http://players.brightcove.net/%s/%s_%s/' % (account_id, player_id, embed)
+ config = self._download_json(
+ base_url + 'config.json', video_id, fatal=False) or {}
+ policy_key = try_get(
+ config, lambda x: x['video_cloud']['policy_key'])
+ if not policy_key:
+ webpage = self._download_webpage(
+ base_url + 'index.min.js', video_id)
- catalog = self._search_regex(
- r'catalog\(({.+?})\);', webpage, 'catalog', default=None)
- if catalog:
- catalog = self._parse_json(
- js_to_json(catalog), video_id, fatal=False)
+ catalog = self._search_regex(
+ r'catalog\(({.+?})\);', webpage, 'catalog', default=None)
if catalog:
- policy_key = catalog.get('policyKey')
-
- if not policy_key:
- policy_key = self._search_regex(
- r'policyKey\s*:\s*(["\'])(?P<pk>.+?)\1',
- webpage, 'policy key', group='pk')
+ catalog = self._parse_json(
+ js_to_json(catalog), video_id, fatal=False)
+ if catalog:
+ policy_key = catalog.get('policyKey')
+
+ if not policy_key:
+ policy_key = self._search_regex(
+ r'policyKey\s*:\s*(["\'])(?P<pk>.+?)\1',
+ webpage, 'policy key', group='pk')
store_pk(policy_key)
return policy_key