Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/mxplayer.py (Python)

Code before:
            'skip_download': True,
        },
    }]

    def _real_extract(self, url):
        video_type, display_id, video_id = self._match_valid_url(url).group('type', 'display_id', 'id')
        if 'show' in video_type:
            video_type = 'episode'

        data_json = self._download_json(
            f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id)

        if traverse_obj(data_json, ('stream', 'provider')) == 'thirdParty':
            streams = traverse_obj(data_json, ('stream', {'m3u8': ('thirdParty', 'hlsUrl'), 'mpd': ('thirdParty', 'dashUrl')}))
        else:
            streams = {type: f'https://llvod.mxplay.com/{path}' for type, path in
                       traverse_obj(data_json, ('stream', {'m3u8': ('hls', 'high'), 'mpd': ('dash', 'high')})).items()}

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            streams["m3u8"], display_id, fatal=False)

        if 'mpd' in streams:
            dash_frmts, dash_subs = self._extract_mpd_formats_and_subtitles(
                streams["mpd"], display_id, fatal=False)
            formats.extend(dash_frmts)
            subtitles.update(dash_subs)
        self._sort_formats(formats)

        season = traverse_obj(data_json, ('container', 'title'))
        return {
            'id': video_id,
            'title': data_json.get('title'),
            'formats': formats,
            'subtitles': subtitles,
            'display_id': display_id,
            'duration': data_json.get('duration'),
            'series': traverse_obj(data_json, ('container', 'container', 'title')),
            'description': data_json.get('description'),
            'season': season,
            'season_number': int_or_none(
                self._search_regex(r'Season (\d+)', season, 'Season Number', default=None)),
            'episode_number': data_json.get('sequence') or None,
        }


class MxplayerShowIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])'
    _TESTS = [{
        'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417',
        'playlist_mincount': 440,
        'info_dict': {

Review comment (refactor):

```suggestion
        streams = traverse_obj(data_json, ('stream', {
            'm3u8': ((('thirdParty', 'hlsUrl'), ('hls', 'high')), )
            'mpd': ((('thirdParty', 'dashUrl'), ('dash', 'high')), )
        }, get_all=False)
        formats, subtitles = [], {}
        if 'm3u8' in streams:
            formats, subtitles = self._extract_m3u8_formats_and_subtitles(
                urljoin('https://llvod.mxplay.com/', streams['m3u8']), display_id, 'mp4', fatal=False)
        if 'mpd' in streams:
            fmts, subs = self._extract_mpd_formats_and_subtitles(
                urljoin('https://llvod.mxplay.com/', streams['mpd']), display_id, fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
```
OR even better imo
```suggestion
        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)
```

Code after:
    }]

    def _real_extract(self, url):
        video_type, display_id, video_id = self._match_valid_url(url).group('type', 'display_id', 'id')
        if 'show' in video_type:
            video_type = 'episode'

        data_json = self._download_json(
            f'https://api.mxplay.com/v1/web/detail/video?type={video_type}&id={video_id}', display_id)

        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': subtitles,
            'display_id': display_id,
            'duration': data_json.get('duration'),
            'series': traverse_obj(data_json, ('container', 'container', 'title')),
            'description': data_json.get('description'),
            'season': season,
            'season_number': int_or_none(
                self._search_regex(r'Season (\d+)', season, 'Season Number', default=None)),
            'episode_number': data_json.get('sequence') or None,
        }


class MxplayerShowIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?mxplayer\.in/show/(?P<display_id>[-\w]+)-(?P<id>\w+)/?(?:$|[#?])'
    _TESTS = [{
        'url': 'https://www.mxplayer.in/show/watch-chakravartin-ashoka-samrat-series-online-a8f44e3cc0814b5601d17772cedf5417',
        'playlist_mincount': 440,
        'info_dict': {
            'id': 'a8f44e3cc0814b5601d17772cedf5417',
            'title': 'Watch Chakravartin Ashoka Samrat Series Online',
        }
    }]

    _API_SHOW_URL = "https://api.mxplay.com/v1/web/detail/tab/tvshowseasons?type=tv_show&id={}&device-density=2&platform=com.mxplay.desktop&content-languages=hi,en"