Jelajahi Sumber

Check for empty string in DefaultLyricProvider

Niels van Velzen 2 tahun lalu
induk
melakukan
0ae4d175a1

+ 1 - 1
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;

+ 4 - 1
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;

+ 0 - 6
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++)