aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdjnz <coletdjnz@protonmail.com>2023-03-13 01:43:37 +0000
committerGitHub <noreply@github.com>2023-03-13 01:43:37 +0000
commit607510b9f2f67bfe7d33d74031a5c1fe22a24862 (patch)
treeb0d8b7de88451f2c4e81e88997c87d494d94dbdd
parent98ac902c4979e4529b166e873473bef42baa2e3e (diff)
downloadhypervideo-pre-607510b9f2f67bfe7d33d74031a5c1fe22a24862.tar.lz
hypervideo-pre-607510b9f2f67bfe7d33d74031a5c1fe22a24862.tar.xz
hypervideo-pre-607510b9f2f67bfe7d33d74031a5c1fe22a24862.zip
[extractor/youtube] Handle incomplete initial data from watch page (#6510)
Authored by: coletdjnz
-rw-r--r--yt_dlp/extractor/youtube.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index d7cd0dc62..b024d18b7 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -4254,12 +4254,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
initial_data = None
if webpage:
initial_data = self.extract_yt_initial_data(video_id, webpage, fatal=False)
+ if not traverse_obj(initial_data, 'contents'):
+ self.report_warning('Incomplete data received in embedded initial data; re-fetching using API.')
+ initial_data = None
if not initial_data:
query = {'videoId': video_id}
query.update(self._get_checkok_params())
initial_data = self._extract_response(
item_id=video_id, ep='next', fatal=False,
- ytcfg=master_ytcfg, query=query,
+ ytcfg=master_ytcfg, query=query, check_get_keys='contents',
headers=self.generate_api_headers(ytcfg=master_ytcfg),
note='Downloading initial data API JSON')