diff options
Diffstat (limited to 'MediaBrowser.Controller/Lyrics/LyricInfo.cs')
| -rw-r--r-- | MediaBrowser.Controller/Lyrics/LyricInfo.cs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/MediaBrowser.Controller/Lyrics/LyricInfo.cs b/MediaBrowser.Controller/Lyrics/LyricInfo.cs index 61e205b6c..a063a4cc5 100644 --- a/MediaBrowser.Controller/Lyrics/LyricInfo.cs +++ b/MediaBrowser.Controller/Lyrics/LyricInfo.cs @@ -1,4 +1,7 @@ +using System.Collections.Generic; using System.IO; +using System.Linq; +using Jellyfin.Extensions; namespace MediaBrowser.Controller.Lyrics; @@ -13,12 +16,21 @@ public static class LyricInfo /// <param name="lyricProvider">The lyricProvider interface to use.</param> /// <param name="itemPath">Path of requested item.</param> /// <returns>Lyric file path if passed lyric provider's supported media type is found; otherwise, null.</returns> - public static string? GetLyricFilePath(ILyricProvider lyricProvider, string itemPath) + public static string? GetLyricFilePath(this ILyricProvider lyricProvider, string itemPath) { - foreach (string lyricFileExtension in lyricProvider.SupportedMediaTypes) + if (lyricProvider is null) { - var lyricFilePath = Path.ChangeExtension(itemPath, lyricFileExtension); - if (File.Exists(lyricFilePath)) + return null; + } + + if (!Directory.Exists(Path.GetDirectoryName(itemPath))) + { + return null; + } + + foreach (var lyricFilePath in Directory.GetFiles(Path.GetDirectoryName(itemPath), $"{Path.GetFileNameWithoutExtension(itemPath)}.*")) + { + if (lyricProvider.SupportedMediaTypes.Contains(Path.GetExtension(lyricFilePath)[1..])) { return lyricFilePath; } |
