[extractor/mxplayer] Improve extractor (#5303)

Closes #5276
Authored by: m4tu4g
This commit is contained in:
m4tu4g 2022-11-07 21:29:53 +05:30 committed by GitHub
parent fbb0ee7747
commit 9b383177c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
int_or_none, int_or_none,
traverse_obj, traverse_obj,
try_get, try_get,
urljoin,
) )
@ -147,6 +148,17 @@ class MxplayerIE(InfoExtractor):
'format': 'bv', 'format': 'bv',
'skip_download': True, 'skip_download': True,
}, },
}, {
'url': 'https://www.mxplayer.in/movie/watch-deewane-huye-paagal-movie-online-4f9175c40a11c3994182a65afdd37ec6?watch=true',
'info_dict': {
'id': '4f9175c40a11c3994182a65afdd37ec6',
'display_id': 'watch-deewane-huye-paagal-movie-online',
'title': 'Deewane Huye Paagal',
'duration': 9037,
'ext': 'mp4',
'description': 'md5:d17bd5c651016c4ed2e6f8a4ace15534',
},
'params': {'skip_download': 'm3u8'},
}] }]
def _real_extract(self, url): def _real_extract(self, url):
@ -157,21 +169,24 @@ def _real_extract(self, url):
data_json = self._download_json( data_json = self._download_json(
f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id) f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id)
streams = traverse_obj(data_json, ('stream', {'m3u8': ('hls', 'high'), 'mpd': ('dash', 'high')})) formats, subtitles = [], {}
formats, dash_subs = self._extract_mpd_formats_and_subtitles( m3u8_url = urljoin('https://llvod.mxplay.com/', traverse_obj(
f'https://llvod.mxplay.com/{streams["mpd"]}', display_id, fatal=False) data_json, ('stream', (('thirdParty', 'hlsUrl'), ('hls', 'high'))), get_all=False))
hls_frmts, hls_subs = self._extract_m3u8_formats_and_subtitles( if m3u8_url:
f'https://llvod.mxplay.com/{streams["m3u8"]}', display_id, fatal=False) formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, display_id, 'mp4', fatal=False)
mpd_url = urljoin('https://llvod.mxplay.com/', traverse_obj(
formats.extend(hls_frmts) data_json, ('stream', (('thirdParty', 'dashUrl'), ('dash', 'high'))), get_all=False))
self._sort_formats(formats) if mpd_url:
fmts, subs = self._extract_mpd_formats_and_subtitles(mpd_url, display_id, fatal=False)
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
season = traverse_obj(data_json, ('container', 'title')) season = traverse_obj(data_json, ('container', 'title'))
return { return {
'id': video_id, 'id': video_id,
'title': data_json.get('title'), 'title': data_json.get('title'),
'formats': formats, 'formats': formats,
'subtitles': self._merge_subtitles(dash_subs, hls_subs), 'subtitles': subtitles,
'display_id': display_id, 'display_id': display_id,
'duration': data_json.get('duration'), 'duration': data_json.get('duration'),
'series': traverse_obj(data_json, ('container', 'container', 'title')), 'series': traverse_obj(data_json, ('container', 'container', 'title')),