If you are unfamiliar with Genius headers, you can read up on them here.
As an example I'll use "Hey You" by "Pink Floyd":
[Acoustic Guitar Intro]
[Verse 1: David Gilmour]
Hey, you
In short: Genius headers contain extra information about who's singing, the verse number etc..
A problem can arise when you sync such lyrics and save them as an .lrc file or in the LYRICS tag:
[Acoustic Guitar Intro]
[Verse 1: David Gilmour]
[00:35.485]Hey you
Many audioplayers will no longer display the headers. The reason being that they have a very similar syntax to lrc tags that can be found at the beginning of .lrc files:
[ar:Pink Floyd]
[al:The Wall (2011 Remaster)]
[ti:Hey You]
[au:Roger Waters]
[length:04:40]
Lrc tags should not be displayed as part of the lyrics by audioplayers, but the regex they use to filter such tags is often not very specific so it also removes the Genius headers.
As a workaround I have written a relatively complex and fun regular expression and turned it into an Mp3tag action.
$regexp(%LYRICS%,\'['(?<header>(?!(?:ti|ar|al|au|lr|length|by|offset|re|tool|ve|#|\d{1,2}):.*\']')'['^\r\n']'+?)\']'(?<newline>\r?\n)(?<timestamp>\'['\d{1,2}:\d{1,2}\.\d{2,3}\']')(?<lrcline>'['^\r\n']'*),$+{timestamp}($+{header})$+{newline}$+{timestamp}$+{lrcline})
What does it do?
It turns:
[ar:Pink Floyd]
[al:The Wall (2011 Remaster)]
[ti:Hey You]
[au:Roger Waters]
[length:04:40]
[Acoustic Guitar Intro]
[Verse 1: David Gilmour]
[00:35.485]Hey you
into
[ar:Pink Floyd]
[al:The Wall (2011 Remaster)]
[ti:Hey You]
[au:Roger Waters]
[length:04:40]
[Acoustic Guitar Intro]
[00:35.485](Verse 1: David Gilmour)
[00:35.485]Hey you
It ignores the lrc tags, replaces the square brackets around the headers with round ones and prepends the timestamp of the following line to the header.
This way, the header is no longer filtered out by audioplayers and instead displayed at the same time as the line directly after it.
Notice how the [Acoustic Guitar Intro] is unchanged. I chose to only target the headers and not instrumental passages/solos etc. that are better dealt with while syncing the lyrics by placing a timestamp in front of them (and replacing the square brackets with round ones) or removing them in favor of a line with only a timestamp.
Here's a visualization of the regex:
Regex breakdown:
\'[' the opening bracket of the header
(?<header> named capturing group for the header content
(?!(?:ti|ar|al|au|lr|length|by|offset|re|tool|ve|#|\d{1,2}):.*\']') negative lookahead to avoid matching known lrc tags or timestamp lines
'['^\r\n']'+?) matches everything except for newline characters non-greedily to capture the content of the header
\']' the closing bracket of the header
(?<newline>\r?\n) named capturing group for the line-break between header and timestamp line, both Windows (CR LF) and Unix (LF) line-breaks are captured
(?<timestamp>\'['\d{1,2}:\d{1,2}\.\d{2,3}\']') named capturing group for the timestamp
(?<lrcline>'['^\r\n']'*) named capturing group for the text of the lyrics line
Replacement:
$+{timestamp}($+{header})$+{newline}$+{timestamp}$+{lrcline}
Line 1: timestamp, then the header content in round brackets, then a new line
Line 2: timestamp and the text of the line (unchanged)
The regex changes all such headers in the LYRICS.
Mp3tag Action:
As an action, this can be used to mass change such synced lyrics in-place.
Action type: Format value
Field:
LYRICS
Format string:
$regexp(%LYRICS%,\'['(?<header>(?!(?:ti|ar|al|au|lr|length|by|offset|re|tool|ve|#|\d{1,2}):.*\']')'['^\r\n']'+?)\']'(?<newline>\r?\n)(?<timestamp>\'['\d{1,2}:\d{1,2}\.\d{2,3}\']')(?<lrcline>'['^\r\n']'*),$+{timestamp}($+{header})$+{newline}$+{timestamp}$+{lrcline})
If you want to check out the original regex before I heavily edited it to make it work in Mp3tag (escaping [, no multi-line flag support, so no ^$), you can check it out here. This should also be a good starting point if you want to turn it into a batch file or bash/python script to target external .lrc files in the same manner.
I'd be curious if there are other existing approaches/workarounds to solve the issue of retaining/displaying Genius headers in synchronized lyrics.

