mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 22:17:25 -04:00
Make LyricParser a field
This commit is contained in:
parent
3ba8218e45
commit
b442c79e62
1 changed files with 11 additions and 5 deletions
|
@ -18,6 +18,8 @@ public class LrcLyricProvider : ILyricProvider
|
|||
{
|
||||
private readonly ILogger<LrcLyricProvider> _logger;
|
||||
|
||||
private readonly LyricParser _lrcLyricParser;
|
||||
|
||||
private static readonly IReadOnlyList<string> _acceptedTimeFormats = new string[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" };
|
||||
|
||||
/// <summary>
|
||||
|
@ -27,6 +29,7 @@ public class LrcLyricProvider : ILyricProvider
|
|||
public LrcLyricProvider(ILogger<LrcLyricProvider> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_lrcLyricParser = new LrcParser.Parser.Lrc.LrcParser();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -62,13 +65,11 @@ public class LrcLyricProvider : ILyricProvider
|
|||
|
||||
try
|
||||
{
|
||||
// Parse and sort lyric rows
|
||||
LyricParser lrcLyricParser = new LrcParser.Parser.Lrc.LrcParser();
|
||||
lyricData = lrcLyricParser.Decode(lrcFileContent);
|
||||
lyricData = _lrcLyricParser.Decode(lrcFileContent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error parsing lyric data from {Provider}", Name);
|
||||
_logger.LogError(ex, "Error parsing lyric file {LyricFilePath} from {Provider}", lyricFilePath, Name);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -92,7 +93,12 @@ public class LrcLyricProvider : ILyricProvider
|
|||
string metaDataFieldName = metaDataField[0][1..];
|
||||
string metaDataFieldValue = metaDataField[1][..^1];
|
||||
|
||||
fileMetaData.Add(metaDataFieldName, metaDataFieldValue);
|
||||
if (string.IsNullOrEmpty(metaDataFieldName) || string.IsNullOrEmpty(metaDataFieldValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fileMetaData[metaDataFieldName] = metaDataFieldValue;
|
||||
}
|
||||
|
||||
if (sortedLyricData.Count == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue