From 803c901445bc2bbfce2e7bf970237ccf6cc00ea7 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 28 Jun 2020 18:18:04 -0700 Subject: Fix hls_manifest_url not included when there's no other formats Since there are no formats, it was retrying with the non-embedded playerResponse, which resulted in the hls_manifest_urls from the embedded player_response being overwritten with None. So use conservative_update instead --- youtube/yt_data_extract/watch_extraction.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'youtube/yt_data_extract') diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py index 5aaa318..ca2da10 100644 --- a/youtube/yt_data_extract/watch_extraction.py +++ b/youtube/yt_data_extract/watch_extraction.py @@ -340,8 +340,12 @@ def _extract_formats(info, player_response): yt_formats = streaming_data.get('formats', []) + streaming_data.get('adaptiveFormats', []) info['formats'] = [] - info['hls_manifest_url'] = streaming_data.get('hlsManifestUrl') - info['dash_manifest_url'] = streaming_data.get('dashManifestUrl') + # because we may retry the extract_formats with a different player_response + # so keep what we have + conservative_update(info, 'hls_manifest_url', + streaming_data.get('hlsManifestUrl')) + conservative_update(info, 'dash_manifest_url', + streaming_data.get('dash_manifest_url')) for yt_fmt in yt_formats: fmt = {} -- cgit v1.2.3