aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/extractor/mtv.py
diff options
context:
space:
mode:
Diffstat (limited to 'hypervideo_dl/extractor/mtv.py')
-rw-r--r--hypervideo_dl/extractor/mtv.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/hypervideo_dl/extractor/mtv.py b/hypervideo_dl/extractor/mtv.py
index e060884..be5de0a 100644
--- a/hypervideo_dl/extractor/mtv.py
+++ b/hypervideo_dl/extractor/mtv.py
@@ -15,6 +15,7 @@ from ..utils import (
float_or_none,
HEADRequest,
int_or_none,
+ join_nonempty,
RegexNotFoundError,
sanitized_Request,
strip_or_none,
@@ -99,9 +100,9 @@ class MTVServicesInfoExtractor(InfoExtractor):
formats.extend([{
'ext': 'flv' if rtmp_video_url.startswith('rtmp') else ext,
'url': rtmp_video_url,
- 'format_id': '-'.join(filter(None, [
+ 'format_id': join_nonempty(
'rtmp' if rtmp_video_url.startswith('rtmp') else None,
- rendition.get('bitrate')])),
+ rendition.get('bitrate')),
'width': int(rendition.get('width')),
'height': int(rendition.get('height')),
}])
@@ -311,11 +312,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 = try_get(video_player, lambda x: x['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 = try_get(player, lambda x: x['props']['videoDetail']['mgid'])
if not mgid:
- mgid = self._search_regex(
- r'"media":{"video":{"config":{"uri":"(mgid:.*?)"', webpage, 'mgid', default=None)
+ raise ExtractorError('Could not extract mgid')
return mgid