2022-09-15 23:45:26 +00:00
|
|
|
using System.IO;
|
|
|
|
|
2022-09-17 21:37:38 +00:00
|
|
|
namespace MediaBrowser.Controller.Lyrics;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Lyric helper methods.
|
|
|
|
/// </summary>
|
|
|
|
public static class LyricInfo
|
2022-09-15 23:45:26 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2022-09-17 21:37:38 +00:00
|
|
|
/// Gets matching lyric file for a requested item.
|
2022-09-15 23:45:26 +00:00
|
|
|
/// </summary>
|
2022-09-17 21:37:38 +00:00
|
|
|
/// <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)
|
2022-09-15 23:45:26 +00:00
|
|
|
{
|
2022-09-17 21:37:38 +00:00
|
|
|
foreach (string lyricFileExtension in lyricProvider.SupportedMediaTypes)
|
2022-09-15 23:45:26 +00:00
|
|
|
{
|
2022-09-17 21:37:38 +00:00
|
|
|
var lyricFilePath = Path.ChangeExtension(itemPath, lyricFileExtension);
|
|
|
|
if (File.Exists(lyricFilePath))
|
2022-09-15 23:45:26 +00:00
|
|
|
{
|
2022-09-17 21:37:38 +00:00
|
|
|
return lyricFilePath;
|
2022-09-15 23:45:26 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-17 21:37:38 +00:00
|
|
|
|
|
|
|
return null;
|
2022-09-15 23:45:26 +00:00
|
|
|
}
|
|
|
|
}
|