diff options
| author | Niels van Velzen <git@ndat.nl> | 2023-07-01 11:16:21 +0200 |
|---|---|---|
| committer | Niels van Velzen <git@ndat.nl> | 2023-07-01 11:16:21 +0200 |
| commit | 0ae4d175a184b86ec0267b1bdb89c8c59d40c325 (patch) | |
| tree | e878208178a18520febc903e9814e0c23e2b82d7 | |
| parent | 6be45f73bc60d7b4646d7967d29634eea0b7e422 (diff) | |
Check for empty string in DefaultLyricProvider
| -rw-r--r-- | MediaBrowser.Controller/Lyrics/LyricFile.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs | 5 | ||||
| -rw-r--r-- | 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 21096797a..ede89403c 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 <see cref="LyricFile"/> class. /// </summary> /// <param name="name">The name.</param> - /// <param name="content">The content.</param> + /// <param name="content">The content, must not be empty.</param> public LyricFile(string name, string content) { Name = name; diff --git a/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs b/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs index ae6350dd7..a26f2babb 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 ed4f2cb7a..706f13dbc 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++) |
