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

Code before:
            'album': traverse_obj(album, 'name', 'title'),
            'album_artist': traverse_obj(album, 'artistsNames', 'artists_names'),
        }

    def _real_initialize(self):
        if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
            self._request_webpage(self.get_api_with_signature(name_api=self._SLUG_API['bai-hat'], param={'id': ''}),
                                  None, note='Updating cookies')

    def _real_extract(self, url):
        song_id, type_url = self._match_valid_url(url).group('id', 'type')
        api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
        return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)

    def get_api_with_signature(self, name_api, param):
        param.update({'ctime': '1'})
        sha256 = hashlib.sha256(''.join(f'{i}={param[i]}' for i in sorted(param)).encode('utf-8')).hexdigest()
        data = {
            'apiKey': self._API_KEY,
            'sig': hmac.new(self._SECRET_KEY, f'{name_api}{sha256}'.encode('utf-8'), hashlib.sha512).hexdigest(),
            **param,
        }
        return f'{self._DOMAIN}{name_api}?{urllib.parse.urlencode(data)}'

    def _entries(self, items):
        for item in items:
            if item:
                yield self.url_result(urljoin(self._DOMAIN, item.get('link')))


class ZingMp3IE(ZingMp3BaseIE):
    _VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'bai-hat|video-clip|embed'
    _TESTS = [{
        'url': 'https://mp3.zing.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
        'md5': 'ead7ae13693b3205cbc89536a077daed',
        'info_dict': {
            'id': 'ZWZB9WAB',
            'title': 'Xa Mãi Xa',
            'ext': 'mp3',
            'thumbnail': r're:^https?://.+\.jpg',
            'subtitles': {
                'origin': [{
                    'ext': 'lrc',
                }]
            },
            'duration': 255,
            'track': 'Xa Mãi Xa',
            'artist': 'Bảo Thy',
            'album': 'Special Album',
            'album_artist': 'Bảo Thy',
        },

Review comment (suggestion):
```suggestion
        for item in items or []:
```
see below comment

Code after:
            'album': traverse_obj(album, 'name', 'title'),
            'album_artist': traverse_obj(album, 'artistsNames', 'artists_names'),
        }

    def _real_initialize(self):
        if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
            self._request_webpage(self.get_api_with_signature(name_api=self._SLUG_API['bai-hat'], param={'id': ''}),
                                  None, note='Updating cookies')

    def _real_extract(self, url):
        song_id, type_url = self._match_valid_url(url).group('id', 'type')
        api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
        return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)

    def get_api_with_signature(self, name_api, param):
        param.update({'ctime': '1'})
        sha256 = hashlib.sha256(''.join(f'{i}={param[i]}' for i in sorted(param)).encode('utf-8')).hexdigest()
        data = {
            'apiKey': self._API_KEY,
            'sig': hmac.new(self._SECRET_KEY, f'{name_api}{sha256}'.encode('utf-8'), hashlib.sha512).hexdigest(),
            **param,
        }
        return f'{self._DOMAIN}{name_api}?{urllib.parse.urlencode(data)}'

    def _entries(self, items):
        for item in items or []:
            if item and item.get('link'):
                yield self.url_result(urljoin(self._DOMAIN, item['link']))


class ZingMp3IE(ZingMp3BaseIE):
    _VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'bai-hat|video-clip|embed'
    _TESTS = [{
        'url': 'https://mp3.zing.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
        'md5': 'ead7ae13693b3205cbc89536a077daed',
        'info_dict': {
            'id': 'ZWZB9WAB',
            'title': 'Xa Mãi Xa',
            'ext': 'mp3',
            'thumbnail': r're:^https?://.+\.jpg',
            'subtitles': {
                'origin': [{
                    'ext': 'lrc',
                }]
            },
            'duration': 255,
            'track': 'Xa Mãi Xa',
            'artist': 'Bảo Thy',
            'album': 'Special Album',
            'album_artist': 'Bảo Thy',
        },