瀏覽代碼

Remove unneeded 2nd loops

1hitsong 2 年之前
父節點
當前提交
cecca5f715
共有 2 個文件被更改,包括 8 次插入24 次删除
  1. 0 2
      .gitignore
  2. 8 22
      Jellyfin.Api/Helpers/ItemHelper.cs

+ 0 - 2
.gitignore

@@ -281,5 +281,3 @@ apiclient/generated
 
 # Omnisharp crash logs
 mono_crash.*.json
-
-!LrcParser.dll

+ 8 - 22
Jellyfin.Api/Helpers/ItemHelper.cs

@@ -40,16 +40,11 @@ namespace Jellyfin.Api.Helpers
                 ILyricsProvider? newProvider = Activator.CreateInstance(provider) as ILyricsProvider;
                 if (newProvider is not null)
                 {
-                    providerList.Add(newProvider);
-                }
-            }
-
-            foreach (ILyricsProvider provider in providerList)
-            {
-                provider.Process(item);
-                if (provider.HasData)
-                {
-                    return provider.Data;
+                    newProvider.Process(item);
+                    if (newProvider.HasData)
+                    {
+                        return newProvider.Data;
+                    }
                 }
             }
 
@@ -86,26 +81,17 @@ namespace Jellyfin.Api.Helpers
 
                 if (foundProvider.FileExtensions.Any())
                 {
-                    // Gather distinct list of handled file extentions
                     foreach (string lyricFileExtension in foundProvider.FileExtensions)
                     {
-                        if (!supportedLyricFileExtensions.Contains(lyricFileExtension))
+                        string lyricFilePath = @Path.ChangeExtension(itemPath, lyricFileExtension);
+                        if (System.IO.File.Exists(lyricFilePath))
                         {
-                            supportedLyricFileExtensions.Add(lyricFileExtension);
+                            return lyricFilePath;
                         }
                     }
                 }
             }
 
-            foreach (string lyricFileExtension in supportedLyricFileExtensions)
-            {
-                string lyricFilePath = @Path.ChangeExtension(itemPath, lyricFileExtension);
-                if (System.IO.File.Exists(lyricFilePath))
-                {
-                    return lyricFilePath;
-                }
-            }
-
             return null;
         }