From 0ae4d175a184b86ec0267b1bdb89c8c59d40c325 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Sat, 1 Jul 2023 11:16:21 +0200 Subject: [PATCH] Check for empty string in DefaultLyricProvider --- MediaBrowser.Controller/Lyrics/LyricFile.cs | 2 +- MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs | 5 ++++- MediaBrowser.Providers/Lyric/TxtLyricParser.cs | 6 ------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Controller/Lyrics/LyricFile.cs b/MediaBrowser.Controller/Lyrics/LyricFile.cs index 21096797ac..ede89403c6 100644 --- a/MediaBrowser.Controller/Lyrics/LyricFile.cs +++ b/MediaBrowser.Controller/Lyrics/LyricFile.cs @@ -9,7 +9,7 @@ public class LyricFile /// Initializes a new instance of the class. /// /// The name. - /// The content. + /// The content, must not be empty. public LyricFile(string name, string content) { Name = name; diff --git a/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs b/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs index ae6350dd7d..a26f2babbf 100644 --- a/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs +++ b/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs @@ -32,7 +32,10 @@ public class DefaultLyricProvider : ILyricProvider if (path is not null) { var content = await File.ReadAllTextAsync(path).ConfigureAwait(false); - return new LyricFile(path, content); + if (content.Length != 0) + { + return new LyricFile(path, content); + } } return null; diff --git a/MediaBrowser.Providers/Lyric/TxtLyricParser.cs b/MediaBrowser.Providers/Lyric/TxtLyricParser.cs index ed4f2cb7a6..706f13dbcd 100644 --- a/MediaBrowser.Providers/Lyric/TxtLyricParser.cs +++ b/MediaBrowser.Providers/Lyric/TxtLyricParser.cs @@ -32,12 +32,6 @@ public class TxtLyricParser : ILyricParser } string[] lyricTextLines = lyrics.Content.Split(_lineBreakCharacters, StringSplitOptions.None); - - if (lyricTextLines.Length == 0) - { - return null; - } - LyricLine[] lyricList = new LyricLine[lyricTextLines.Length]; for (int lyricLineIndex = 0; lyricLineIndex < lyricTextLines.Length; lyricLineIndex++)