11// Copyright (c) karaoke.dev <contact@karaoke.dev>. Licensed under the MIT Licence.
22// See the LICENCE file in the repository root for full licence text.
33
4+ using LrcParser . Model ;
45using LrcParser . Parser . Lines ;
56using LrcParser . Parser . Lrc . Metadata ;
67using LrcParser . Parser . Lrc . Utils ;
@@ -14,8 +15,28 @@ public override bool CanDecode(string text)
1415
1516 public override LrcLyric Decode ( string text )
1617 {
17- var ( startTimes , lyricText ) = LrcStartTimeUtils . SplitLyricAndTimeTag ( text ) ;
18- var ( lyric , timeTags ) = LrcTimedTextUtils . TimedTextToObject ( lyricText ) ;
18+ var ( startTimes , rawLyric ) = LrcStartTimeUtils . SplitLyricAndTimeTag ( text ) ;
19+
20+ // If there are multiple start times, it is possible that the given word time tags are incompatible with one or more start times.
21+ // For example, if a line starts at both [01:00.00] and [02:00.00],
22+ // word time tags with the values <01:10.00> and <01:20.00> would be incompatible with the second start time.
23+ // As there isn't an official LRC spec, this isn't clearly defined.
24+ // While the format is technically valid, we chose a reasonable behavior of ignoring the word time tags in this case
25+ // and returning the line as-is without parsing the word time tags.
26+ // The same applies to lines that have no start times:
27+ // As there might be lines like `Every <00:07.56> night`, the first word would not have a start time,
28+ // so we chose the same approach of ignoring the word time tags in this case.
29+ if ( startTimes . Length is 0 or > 1 )
30+ {
31+ return new LrcLyric
32+ {
33+ Text = rawLyric ,
34+ StartTimes = startTimes ,
35+ TimeTags = new SortedDictionary < TextIndex , int > ( )
36+ } ;
37+ }
38+
39+ var ( lyric , timeTags ) = LrcTimedTextUtils . TimedTextToObject ( rawLyric ) ;
1940
2041 return new LrcLyric
2142 {
0 commit comments