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

Code before:
        },
        'playlist_mincount': 50,
    }, {
        'url': 'https://zingmp3.vn/podcast-discover',
        'info_dict': {
            'id': 'podcast-discover',
        },
        'playlist_mincount': 150,
    }]

    def _real_extract(self, url):
        url_type = self._match_id(url)
        params = {'id': url_type}
        if url_type == 'podcast-discover':
            params.update({'type': 'discover'})
        data = self._call_api(url_type, params)
        items = []
        if url_type == 'top100':
            self.IE_NAME = 'zingmp3:top100'
            items.extend(traverse_obj(data, (lambda _, v: v['items'], 'items', ...)))
        elif url_type == 'podcast-discover':
            self.IE_NAME = 'zingmp3:postcast-discover'
            items.extend(traverse_obj(data, 'items'))
        else:
            self.IE_NAME = 'zingmp3:chart-home'
            items.extend(traverse_obj(data, ('RTChart', 'items') if url_type == 'zing-chart' else 'items'))
        return self.playlist_result(self._parse_items(items), url_type)


class ZingMp3WeekChartIE(ZingMp3BaseIE):
    _VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'zing-chart-tuan'
    IE_NAME = 'zingmp3:week-chart'
    _TESTS = [{
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-Viet-Nam/IWZ9Z08I.html',
        'info_dict': {
            'id': 'IWZ9Z08I',
            'title': 'zing-chart-vn',
        },
        'playlist_mincount': 10,
    }, {
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-US-UK/IWZ9Z0BW.html',
        'info_dict': {
            'id': 'IWZ9Z0BW',
            'title': 'zing-chart-us',
        },
        'playlist_mincount': 10,
    }, {
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-KPop/IWZ9Z0BO.html',
        'info_dict': {
            'id': 'IWZ9Z0BO',
            'title': 'zing-chart-korea',

Review comment (suggestion):
Pretty sure `IE_NAME` should not be changed during runtime.
As the `podcast-discover` case is the same as the default case this can be simplified to:
(see suggestions by bashonly)

Code after:
            'id': 'top100',
        },
        'playlist_mincount': 50,
    }, {
        'url': 'https://zingmp3.vn/podcast-discover',
        'info_dict': {
            'id': 'podcast-discover',
        },
        'playlist_mincount': 4,
    }]
    IE_NAME = 'zingmp3:chart-home'

    def _real_extract(self, url):
        url_type = self._match_id(url)
        params = {'id': url_type}
        if url_type == 'podcast-discover':
            params['type'] = 'discover'
        data = self._call_api(url_type, params)
        items = []
        if url_type == 'top100':
            items.extend(traverse_obj(data, (..., 'items', ..., {dict})))
        elif url_type == 'zing-chart':
            items.extend(traverse_obj(data, ('RTChart', 'items', ..., {dict})))
        else:
            items.extend(traverse_obj(data, ('items', ..., {dict})))
        return self.playlist_result(self._parse_items(items), url_type)


class ZingMp3WeekChartIE(ZingMp3BaseIE):
    _VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'zing-chart-tuan'
    IE_NAME = 'zingmp3:week-chart'
    _TESTS = [{
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-Viet-Nam/IWZ9Z08I.html',
        'info_dict': {
            'id': 'IWZ9Z08I',
            'title': 'zing-chart-vn',
        },
        'playlist_mincount': 10,
    }, {
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-US-UK/IWZ9Z0BW.html',
        'info_dict': {
            'id': 'IWZ9Z0BW',
            'title': 'zing-chart-us',
        },
        'playlist_mincount': 10,
    }, {
        'url': 'https://zingmp3.vn/zing-chart-tuan/Bai-hat-KPop/IWZ9Z0BO.html',
        'info_dict': {
            'id': 'IWZ9Z0BO',
            'title': 'zing-chart-korea',
        },