From f06255822920d817ea06efe28b2ba8c63237af71 Mon Sep 17 00:00:00 2001 From: yeeeha Date: Thu, 26 Mar 2020 20:38:04 +0100 Subject: [PATCH] Fix download with Token Authentication from funk.net (Nexx Player) --- youtube_dl/extractor/nexx.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/nexx.py b/youtube_dl/extractor/nexx.py index 586c1b7eb..2f543be98 100644 --- a/youtube_dl/extractor/nexx.py +++ b/youtube_dl/extractor/nexx.py @@ -247,20 +247,30 @@ class NexxIE(InfoExtractor): azure_manifest_url = '%s%s/%s_src%s.ism/Manifest' % ( azure_stream_base, azure_locator, video_id, ('_manifest' if is_ml else '')) + '%s' - protection_token = try_get( - video, lambda x: x['protectiondata']['token'], compat_str) - if protection_token: - azure_manifest_url += '?hdnts=%s' % protection_token + # the simple token value is no longer used, instead use tokenDASH and/or tokenHLS + protection_token_DASH = try_get( + video, lambda x: x['protectiondata']['tokenDASH'], compat_str) + if protection_token_DASH: + azure_manifest_url_DASH = azure_manifest_url + '?hdnts=%s' % protection_token_DASH + else: + azure_manifest_url_DASH = azure_manifest_url + + protection_token_HLS = try_get( + video, lambda x: x['protectiondata']['tokenHLS'], compat_str) + if protection_token_HLS: + azure_manifest_url_HLS = azure_manifest_url + '?hdnts=%s' % protection_token_HLS + else: + azure_manifest_url_HLS = azure_manifest_url formats = self._extract_m3u8_formats( - azure_manifest_url % '(format=m3u8-aapl)', + azure_manifest_url_HLS % '(format=m3u8-aapl)', video_id, 'mp4', 'm3u8_native', m3u8_id='%s-hls' % cdn, fatal=False) formats.extend(self._extract_mpd_formats( - azure_manifest_url % '(format=mpd-time-csf)', + azure_manifest_url_DASH % '(format=mpd-time-csf)', video_id, mpd_id='%s-dash' % cdn, fatal=False)) formats.extend(self._extract_ism_formats( - azure_manifest_url % '', video_id, ism_id='%s-mss' % cdn, fatal=False)) + azure_manifest_url_DASH % '', video_id, ism_id='%s-mss' % cdn, fatal=False)) azure_progressive_base = get_cdn_shield_base('Prog', True) azure_file_distribution = stream_data.get('azureFileDistribution') @@ -313,8 +323,16 @@ class NexxIE(InfoExtractor): if result: video = find_video(result) + if video: + # search for protection tokens -- if they're present we have to go + # through the procedure below... + tokenDASH = try_get( + video, lambda x: x['protectiondata']['tokenDASH'], compat_str) + tokenHLS = try_get( + video, lambda x: x['protectiondata']['tokenHLS'], compat_str) + # not all videos work via arc, e.g. nexx:741:1269984 - if not video: + if not video or tokenDASH or tokenHLS: # Reverse engineered from JS code (see getDeviceID function) device_id = '%d:%d:%d%d' % ( random.randint(1, 4), int(time.time()),