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

Code before:
            'thumbnail': r're:^http.*\.jpg',
            'average_rating': int,
            'album': 'Oh!',
            'album_artist': '少女时代',
        },
        'skip': 'Blocked outside Mainland China',
    }]

    def _process_lyrics(self, lyrics_info):
        original = traverse_obj(lyrics_info, ('lrc', 'lyric', {str}))
        translated = traverse_obj(lyrics_info, ('tlyric', 'lyric', {str}))

        if not original or original == '[99:00.00]纯音乐，请欣赏\n':
            return None

        if not translated:
            return {
                'lyrics': [{'data': original, 'ext': 'lrc'}],
            }

        def _collect_lyrics(lrc):
            lyrics_expr = r'\[([0-9]{2}):([0-9]{2})[:\.]([0-9]{2,})\]([^\n]+)'
            matches = re.findall(lyrics_expr, lrc)
            return (
                (f'[{mm}:{ss}.{sss}]', text)
                for mm, ss, sss, text in matches
            )

        original_ts_texts = _collect_lyrics(original)
        translation_ts_dict = dict(_collect_lyrics(translated))

        merged = '\n'.join(
            join_nonempty(f'{timestamp}{text}', translation_ts_dict.get(timestamp, ''), delim=' / ')
            for timestamp, text in original_ts_texts)

        return {
            'lyrics_merged': [{'data': merged, 'ext': 'lrc'}],
            'lyrics': [{'data': original, 'ext': 'lrc'}],
            'lyrics_translated': [{'data': translated, 'ext': 'lrc'}],
        }

    def _real_extract(self, url):
        song_id = self._match_id(url)

        info = self._query_api(
            f'song/detail?id={song_id}&ids=%5B{song_id}%5D', song_id, 'Downloading song info')['songs'][0]

        formats = self._extract_formats(info)

        lyrics = self._process_lyrics(self._query_api(
            f'song/lyric?id={song_id}&lv=-1&tv=-1', song_id, 'Downloading lyrics data'))

Review comment (suggestion):
maybe?
```suggestion
                (f'[{min}:{sec}.{ms}]', text)
                for min, sec, ms, text in matches
```

Code after:
            'thumbnail': r're:^http.*\.jpg',
            'average_rating': int,
            'album': 'Oh!',
            'album_artist': '少女时代',
        },
        'skip': 'Blocked outside Mainland China',
    }]

    def _process_lyrics(self, lyrics_info):
        original = traverse_obj(lyrics_info, ('lrc', 'lyric', {str}))
        translated = traverse_obj(lyrics_info, ('tlyric', 'lyric', {str}))

        if not original or original == '[99:00.00]纯音乐，请欣赏\n':
            return None

        if not translated:
            return {
                'lyrics': [{'data': original, 'ext': 'lrc'}],
            }

        def collect_lyrics(lrc):
            lyrics_expr = r'\[([0-9]{2}):([0-9]{2})[:.]([0-9]{2,})\]([^\n]+)'
            matches = re.findall(lyrics_expr, lrc)
            return (
                (f'[{minute}:{sec}.{msec}]', text)
                for minute, sec, msec, text in matches
            )

        original_ts_texts = collect_lyrics(original)
        translation_ts_dict = dict(collect_lyrics(translated))

        merged = '\n'.join(
            join_nonempty(f'{timestamp}{text}', translation_ts_dict.get(timestamp, ''), delim=' / ')
            for timestamp, text in original_ts_texts)

        return {
            'lyrics_merged': [{'data': merged, 'ext': 'lrc'}],
            'lyrics': [{'data': original, 'ext': 'lrc'}],
            'lyrics_translated': [{'data': translated, 'ext': 'lrc'}],
        }

    def _real_extract(self, url):
        song_id = self._match_id(url)

        info = self._query_api(
            f'song/detail?id={song_id}&ids=%5B{song_id}%5D', song_id, 'Downloading song info')['songs'][0]

        formats = self._extract_formats(info)

        lyrics = self._process_lyrics(self._query_api(
            f'song/lyric?id={song_id}&lv=-1&tv=-1', song_id, 'Downloading lyrics data'))