From 76f2b63a26a5dd416b2760d9b3e23155f7f27f92 Mon Sep 17 00:00:00 2001 From: kikuyan Date: Mon, 25 Oct 2021 10:38:32 +0900 Subject: [PATCH] [extractor/mtv] fix mgid extraction Fixes: #29814, #30139 --- youtube_dl/extractor/mtv.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/mtv.py b/youtube_dl/extractor/mtv.py index 5a5205c0e..142945b09 100644 --- a/youtube_dl/extractor/mtv.py +++ b/youtube_dl/extractor/mtv.py @@ -290,7 +290,17 @@ class MTVServicesInfoExtractor(InfoExtractor): main_container = self._extract_child_with_type(data, 'MainContainer') ab_testing = self._extract_child_with_type(main_container, 'ABTesting') video_player = self._extract_child_with_type(ab_testing or main_container, 'VideoPlayer') - mgid = video_player['props']['media']['video']['config']['uri'] + if video_player: + mgid = video_player['props']['media']['video']['config']['uri'] + else: + flex_wrapper = self._extract_child_with_type(ab_testing or main_container, 'FlexWrapper') + auth_suite_wrapper = self._extract_child_with_type(flex_wrapper, 'AuthSuiteWrapper') + player = self._extract_child_with_type(auth_suite_wrapper or flex_wrapper, 'Player') + if player: + mgid = player['props']['videoDetail']['mgid'] + + if not mgid: + raise ExtractorError('Could not extract mgid') return mgid