aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-20 08:48:08 -0400
committer1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-20 08:48:08 -0400
commit0d5bd85d6d292b0876f60bf0654e243f595ec9f9 (patch)
tree6962709bcb05338888bb8aeaaa161c7a70dacc57
parent6f0d33b1caafdf5c8c0413bf3fdcddc822a08f51 (diff)
Resolve Azure build error
-rw-r--r--MediaBrowser.Controller/Lyrics/LyricInfo.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/Lyrics/LyricInfo.cs b/MediaBrowser.Controller/Lyrics/LyricInfo.cs
index a063a4cc5..57964eee5 100644
--- a/MediaBrowser.Controller/Lyrics/LyricInfo.cs
+++ b/MediaBrowser.Controller/Lyrics/LyricInfo.cs
@@ -18,18 +18,29 @@ public static class LyricInfo
/// <returns>Lyric file path if passed lyric provider's supported media type is found; otherwise, null.</returns>
public static string? GetLyricFilePath(this ILyricProvider lyricProvider, string itemPath)
{
+ // Ensure we have a provider
if (lyricProvider is null)
{
return null;
}
- if (!Directory.Exists(Path.GetDirectoryName(itemPath)))
+ // Ensure the path to the item is not null
+ string? itemDirectoryPath = Path.GetDirectoryName(itemPath);
+ if (itemDirectoryPath is null)
{
return null;
}
- foreach (var lyricFilePath in Directory.GetFiles(Path.GetDirectoryName(itemPath), $"{Path.GetFileNameWithoutExtension(itemPath)}.*"))
+ // Ensure the directory path exists
+ if (!Directory.Exists(itemDirectoryPath))
{
+ return null;
+ }
+
+ foreach (var lyricFilePath in Directory.GetFiles(itemDirectoryPath, $"{Path.GetFileNameWithoutExtension(itemPath)}.*"))
+ {
+ if (lyricFilePath is null) { continue; }
+
if (lyricProvider.SupportedMediaTypes.Contains(Path.GetExtension(lyricFilePath)[1..]))
{
return lyricFilePath;