jellyfin/MediaBrowser.Providers/Lyric/LyricManager.cs

56 lines
1.3 KiB
C#
Raw Normal View History

2022-09-15 17:49:25 -07:00
#nullable disable
#pragma warning disable CS1591
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Lyrics;
namespace MediaBrowser.Providers.Lyric
{
public class LyricManager : ILyricManager
{
2022-09-17 05:46:09 -07:00
private readonly ILyricProvider[] _lyricProviders;
2022-09-15 17:49:25 -07:00
2022-09-17 05:46:09 -07:00
public LyricManager(IEnumerable<ILyricProvider> lyricProviders)
2022-09-15 17:49:25 -07:00
{
2022-09-17 05:46:09 -07:00
_lyricProviders = lyricProviders.ToArray();
2022-09-15 17:49:25 -07:00
}
/// <inheritdoc />
public LyricResponse GetLyrics(BaseItem item)
2022-09-15 17:49:25 -07:00
{
foreach (ILyricProvider provider in _lyricProviders)
{
var results = provider.GetLyrics(item);
if (results is not null)
{
return results;
}
}
return null;
}
/// <inheritdoc />
public bool HasLyricFile(BaseItem item)
{
foreach (ILyricProvider provider in _lyricProviders)
{
if (item is null)
{
continue;
}
if (LyricInfo.GetLyricFilePath(provider, item.Path) is not null)
{
return true;
}
}
return false;
}
}
}