Support _non_-tokenized source URLs too

This commit is contained in:
nikhil 2021-08-03 00:16:23 -04:00
parent b675a6e6b9
commit ce604ae7dc

View File

@ -477,18 +477,34 @@ class NBCOlympicsIE(InfoExtractor):
class NBCOlympicsStreamIE(AdobePassIE): class NBCOlympicsStreamIE(AdobePassIE):
IE_NAME = 'nbcolympics:stream' IE_NAME = 'nbcolympics:stream'
_VALID_URL = r'https?://stream\.nbcolympics\.com/(?P<id>[0-9a-z-]+)' _VALID_URL = r'https?://stream\.nbcolympics\.com/(?P<id>[0-9a-z-]+)'
_TEST = { _TESTS = [
'url': 'https://stream.nbcolympics.com/womens-soccer-group-round-11', # "Tokenized" .m3u8 source URL
'info_dict': { {
'id': '2019740', 'url': 'https://stream.nbcolympics.com/womens-soccer-group-round-11',
'ext': 'mp4', 'info_dict': {
'title': r"re:Women's Group Stage - Netherlands vs\. Brazil [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$", 'id': '2019740',
'ext': 'mp4',
'title': r"re:Women's Group Stage - Netherlands vs\. Brazil [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$",
},
'params': {
# m3u8 download
'skip_download': True,
},
}, },
'params': { # Plain .m3u8 source URL
# m3u8 download {
'skip_download': True, 'url': 'https://stream.nbcolympics.com/gymnastics-event-finals-mens-floor-pommel-horse-womens-vault-bars',
'info_dict': {
'id': '2021729',
'ext': 'mp4',
'title': r're:Event Finals: M Floor, W Vault, M Pommel, W Uneven Bars [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
},
'params': {
# m3u8 download
'skip_download': True,
},
}, },
} ]
_DATA_URL_TEMPLATE = 'http://stream.nbcolympics.com/data/%s_%s.json' _DATA_URL_TEMPLATE = 'http://stream.nbcolympics.com/data/%s_%s.json'
_LEAP_URL_TEMPLATE = 'https://api-leap.nbcsports.com/feeds/assets/%s?application=NBCOlympics&platform=%s&format=nbc-player&env=staging' _LEAP_URL_TEMPLATE = 'https://api-leap.nbcsports.com/feeds/assets/%s?application=NBCOlympics&platform=%s&format=nbc-player&env=staging'
@ -521,29 +537,30 @@ class NBCOlympicsStreamIE(AdobePassIE):
media_token = self._extract_mvpd_auth( media_token = self._extract_mvpd_auth(
url, pid, event_config.get('requestorId', 'NBCOlympics'), ap_resource) url, pid, event_config.get('requestorId', 'NBCOlympics'), ap_resource)
tokenized_url = self._download_json( if event_config.get('cdnToken') is True:
'https://tokens.playmakerservices.com/', source_url = self._download_json(
pid, 'https://tokens.playmakerservices.com/',
'Retrieving tokenized URL', pid,
data=json.dumps({ 'Retrieving tokenized URL',
'application': 'NBCSports', data=json.dumps({
'authentication-type': 'adobe-pass', 'application': 'NBCSports',
'cdn': 'akamai', 'authentication-type': 'adobe-pass',
# Indicates that the player communicates its token not via the path 'cdn': 'akamai',
# but via a cookie? NBC's player specifies `'false'` but field just # Indicates that the player communicates its token not via the path
# doesn't seem to have an effect. # but via a cookie? NBC's player specifies `'false'` but field just
# 'inPath': 'false', # doesn't seem to have an effect.
'pid': pid, # 'inPath': 'false',
'platform': 'desktop', 'pid': pid,
'requestorId': 'NBCOlympics', 'platform': 'desktop',
'resourceId': base64.b64encode(ap_resource.encode()).decode(), 'requestorId': 'NBCOlympics',
'token': base64.b64encode(media_token.encode()).decode(), 'resourceId': base64.b64encode(ap_resource.encode()).decode(),
'url': source_url, 'token': base64.b64encode(media_token.encode()).decode(),
'version': 'v1', 'url': source_url,
}).encode(), 'version': 'v1',
)['akamai'][0]['tokenizedUrl'] }).encode(),
)['akamai'][0]['tokenizedUrl']
formats = self._extract_m3u8_formats(tokenized_url, pid, 'mp4') formats = self._extract_m3u8_formats(source_url, pid, 'mp4')
for f in formats: for f in formats:
f['_seekable'] = False f['_seekable'] = False
f['_http_seekable'] = False f['_http_seekable'] = False