mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix: Parse LRC format into individual lines for Feishin compatibility
Feishin expects lyrics as an array of {Start, Text} objects with timestamps
in ticks, not as a single LRC-formatted text block
This commit is contained in:
@@ -1006,9 +1006,45 @@ public class JellyfinController : ControllerBase
|
|||||||
var lyricsText = lyrics.SyncedLyrics ?? lyrics.PlainLyrics ?? "";
|
var lyricsText = lyrics.SyncedLyrics ?? lyrics.PlainLyrics ?? "";
|
||||||
var isSynced = !string.IsNullOrEmpty(lyrics.SyncedLyrics);
|
var isSynced = !string.IsNullOrEmpty(lyrics.SyncedLyrics);
|
||||||
|
|
||||||
// Return in Jellyfin lyrics format
|
// Parse LRC format into individual lines for Jellyfin
|
||||||
// For synced lyrics, return the LRC format directly
|
var lyricLines = new List<object>();
|
||||||
// For plain lyrics, return as a single block
|
|
||||||
|
if (isSynced && !string.IsNullOrEmpty(lyrics.SyncedLyrics))
|
||||||
|
{
|
||||||
|
// Parse LRC format: [mm:ss.xx] text
|
||||||
|
var lines = lyrics.SyncedLyrics.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
var match = System.Text.RegularExpressions.Regex.Match(line, @"^\[(\d+):(\d+)\.(\d+)\]\s*(.*)$");
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
var minutes = int.Parse(match.Groups[1].Value);
|
||||||
|
var seconds = int.Parse(match.Groups[2].Value);
|
||||||
|
var centiseconds = int.Parse(match.Groups[3].Value);
|
||||||
|
var text = match.Groups[4].Value;
|
||||||
|
|
||||||
|
// Convert to ticks (100 nanoseconds)
|
||||||
|
var totalMilliseconds = (minutes * 60 + seconds) * 1000 + centiseconds * 10;
|
||||||
|
var ticks = totalMilliseconds * 10000L;
|
||||||
|
|
||||||
|
lyricLines.Add(new
|
||||||
|
{
|
||||||
|
Start = ticks,
|
||||||
|
Text = text
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Plain lyrics - return as single block
|
||||||
|
lyricLines.Add(new
|
||||||
|
{
|
||||||
|
Start = (long?)null,
|
||||||
|
Text = lyricsText
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var response = new
|
var response = new
|
||||||
{
|
{
|
||||||
Metadata = new
|
Metadata = new
|
||||||
@@ -1019,14 +1055,7 @@ public class JellyfinController : ControllerBase
|
|||||||
Length = lyrics.Duration,
|
Length = lyrics.Duration,
|
||||||
IsSynced = isSynced
|
IsSynced = isSynced
|
||||||
},
|
},
|
||||||
Lyrics = new[]
|
Lyrics = lyricLines
|
||||||
{
|
|
||||||
new
|
|
||||||
{
|
|
||||||
Start = (long?)null,
|
|
||||||
Text = lyricsText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
|
|||||||
Reference in New Issue
Block a user