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

Code before:
            msg = item.get('msg')
            if msg == 'Sorry, this content is not available in your country.':
                self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
            self.raise_no_formats(msg, expected=True)
        self._sort_formats(formats)

        lyric = item.get('lyric')
        if not lyric:
            api = self.get_api_with_signature(name_api=self._SLUG_API.get("lyric"), param={'id': item_id})
            info_lyric = self._download_json(api, video_id=item_id)
            lyric = traverse_obj(info_lyric, ('data', 'file'))
        subtitles = {
            'origin': [{
                'url': lyric,
            }],
        } if lyric else None

        album = item.get('album') or {}

        return {
            'id': item_id,
            'title': title,
            'formats': formats,
            'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
            'subtitles': subtitles,
            'duration': int_or_none(try_get(item, lambda x: x['duration'])),
            'track': title,
            'artist': traverse_obj(item, 'artistsNames', 'artists_names'),
            'album': traverse_obj(album, 'name', 'title'),
            'album_artist': traverse_obj(album, 'artistsNames', 'artists_names'),
        }

    def _real_initialize(self):
        # Check the cookie file, if cookie file doesn't exist, create a dummy request to update the cookie
        if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
            self._download_webpage(self._DOMAIN, None, note='Dummy request to update cookie')

    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):
        sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in param.items()).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,

Review comment (suggestion):
```suggestion
            'duration': int_or_none(item.get('duration'))),
```

Code after:
            msg = item.get('msg')
            if msg == 'Sorry, this content is not available in your country.':
                self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
            self.raise_no_formats(msg, expected=True)
        self._sort_formats(formats)

        lyric = item.get('lyric')
        if not lyric:
            api = self.get_api_with_signature(name_api=self._SLUG_API.get("lyric"), param={'id': item_id})
            info_lyric = self._download_json(api, video_id=item_id)
            lyric = traverse_obj(info_lyric, ('data', 'file'))
        subtitles = {
            'origin': [{
                'url': lyric,
            }],
        } if lyric else None

        album = item.get('album') or {}

        return {
            'id': item_id,
            'title': title,
            'formats': formats,
            'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
            'subtitles': subtitles,
            'duration': int_or_none(item.get('duration')),
            'track': title,
            'artist': traverse_obj(item, 'artistsNames', 'artists_names'),
            '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(HEADRequest(self._DOMAIN), 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):
        sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in param.items()).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,
        }