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

Code before:
                **album_meta,
                'title': title,
                'track': title,
                'track_number': traverse_obj(get_element_by_class('py-xsmall', td), {int_or_none}),
                'artist': traverse_obj(td, {lambda td: get_element_by_class('d-block fs-xxsmall', td)}),
                'url': self.TRACK_API.format(release_id=ids.get('data-release-id'),
                                             song_id=ids.get('data-track-id')),
                'id': ids.get('data-track-id'),
                'ext': 'mp3'
            }

    def _real_extract(self, url):
        url_id = self._match_id(url)
        html = self._download_webpage(url, url_id)
        tracklist_table = traverse_obj(html, {lambda html: get_element_by_class('table table-small', html)})

        title = traverse_obj(get_element_text_and_html_by_tag('h1', html), 0)
        date = traverse_obj(html, ({lambda html: get_element_by_class('font-italic mb-medium d-tablet-none d-phone-block',
                            html).partition('Released ')}, 2, {strip_or_none}, {unified_strdate}))

        album_meta = {
            'title': title,
            'album': title,
            'thumbnail': url + '/cover',
            'album_artist': traverse_obj(html, {lambda html: get_element_by_class('h-normal text-uppercase mb-desktop-medium mb-smallish', html)}),
            'release_year': traverse_obj(date, ({lambda x: date[:4]}, {int_or_none})),
            'release_date': date,
        }

        return self.playlist_result(self._extract_tracks(tracklist_table, album_meta),
                                    playlist_id=url_id, **album_meta)


Review comment (suggestion):
```suggestion
            'release_year': int_or_none(date[:4]) if date else None,
```

Code after:
            track_id = ids.get('data-track-id')
            release_id = ids.get('data-release-id')

            track_number = int_or_none(try_call(lambda: get_element_by_class('py-xsmall', td)))
            if not track_id or not release_id:
                self.report_warning(f'Skipping track {track_number}, ID(s) not found')
                self.write_debug(f'release_id={repr(release_id)} track_id={repr(track_id)}')
                continue
            yield {
                **album_meta,
                'title': title,
                'track': title,
                'track_number': track_number,
                'artist': clean_html(try_call(lambda: get_element_by_class('d-block fs-xxsmall', td))),
                'url': f'https://www.monstercat.com/api/release/{release_id}/track-stream/{track_id}',
                'id': track_id,
                'ext': 'mp3'
            }

    def _real_extract(self, url):
        url_id = self._match_id(url)
        html = self._download_webpage(url, url_id)
        # wrap all `get_elements` in `try_call`, HTMLParser has problems with site's html
        tracklist_table = try_call(lambda: get_element_by_class('table table-small', html)) or ''

        title = try_call(lambda: get_element_text_and_html_by_tag('h1', html)[0])
        date = traverse_obj(html, ({lambda html: get_element_by_class('font-italic mb-medium d-tablet-none d-phone-block',
                            html).partition('Released ')}, 2, {strip_or_none}, {unified_strdate}))

        album_meta = {
            'title': title,
            'album': title,
            'thumbnail': f'https://www.monstercat.com/release/{url_id}/cover',
            'album_artist': try_call(
                lambda: get_element_by_class('h-normal text-uppercase mb-desktop-medium mb-smallish', html)),
            'release_year': int_or_none(date[:4]) if date else None,
            'release_date': date,
        }

        return self.playlist_result(
            self._extract_tracks(tracklist_table, album_meta), playlist_id=url_id, **album_meta)