diff --git a/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs b/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs index 3657cf8943..3177abb963 100644 --- a/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs +++ b/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs @@ -18,6 +18,8 @@ public class LrcLyricProvider : ILyricProvider { private readonly ILogger _logger; + private readonly LyricParser _lrcLyricParser; + private static readonly IReadOnlyList _acceptedTimeFormats = new string[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" }; /// @@ -27,6 +29,7 @@ public class LrcLyricProvider : ILyricProvider public LrcLyricProvider(ILogger logger) { _logger = logger; + _lrcLyricParser = new LrcParser.Parser.Lrc.LrcParser(); } /// @@ -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)