From 9b383177c99185d66efb5dd1c1bee2eb025a6386 Mon Sep 17 00:00:00 2001 From: m4tu4g <71326926+m4tu4g@users.noreply.github.com> Date: Mon, 7 Nov 2022 21:29:53 +0530 Subject: [PATCH] [extractor/mxplayer] Improve extractor (#5303) Closes #5276 Authored by: m4tu4g --- yt_dlp/extractor/mxplayer.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/mxplayer.py b/yt_dlp/extractor/mxplayer.py index affdba10c8..1fdb08edfe 100644 --- a/yt_dlp/extractor/mxplayer.py +++ b/yt_dlp/extractor/mxplayer.py @@ -4,6 +4,7 @@ int_or_none, traverse_obj, try_get, + urljoin, ) @@ -147,6 +148,17 @@ class MxplayerIE(InfoExtractor): 'format': 'bv', '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): @@ -157,21 +169,24 @@ def _real_extract(self, url): data_json = self._download_json( 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, dash_subs = self._extract_mpd_formats_and_subtitles( - f'https://llvod.mxplay.com/{streams["mpd"]}', display_id, fatal=False) - hls_frmts, hls_subs = self._extract_m3u8_formats_and_subtitles( - f'https://llvod.mxplay.com/{streams["m3u8"]}', display_id, fatal=False) - - formats.extend(hls_frmts) - self._sort_formats(formats) + formats, subtitles = [], {} + m3u8_url = urljoin('https://llvod.mxplay.com/', traverse_obj( + data_json, ('stream', (('thirdParty', 'hlsUrl'), ('hls', 'high'))), get_all=False)) + if m3u8_url: + formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, display_id, 'mp4', fatal=False) + mpd_url = urljoin('https://llvod.mxplay.com/', traverse_obj( + data_json, ('stream', (('thirdParty', 'dashUrl'), ('dash', 'high'))), get_all=False)) + 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')) return { 'id': video_id, 'title': data_json.get('title'), 'formats': formats, - 'subtitles': self._merge_subtitles(dash_subs, hls_subs), + 'subtitles': subtitles, 'display_id': display_id, 'duration': data_json.get('duration'), 'series': traverse_obj(data_json, ('container', 'container', 'title')),