jellyfin-server/MediaBrowser.Controller/Providers/ItemIdentifier.cs

36 lines
1.0 KiB
C#
Raw Normal View History

2015-09-19 21:25:19 +00:00
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
2015-09-19 21:25:19 +00:00
public static class ItemIdentifier<TLookupInfo>
where TLookupInfo : ItemLookupInfo
{
2015-09-19 21:25:19 +00:00
public static async Task FindIdentities(TLookupInfo item, IProviderManager providerManager, CancellationToken cancellationToken)
{
2015-09-19 21:25:19 +00:00
var providers = providerManager.GetItemIdentityProviders<TLookupInfo>();
var converters = providerManager.GetItemIdentityConverters<TLookupInfo>().ToList();
foreach (var provider in providers)
{
2015-09-19 21:25:19 +00:00
await provider.Identify(item);
}
2015-09-19 21:25:19 +00:00
bool changesMade = true;
2015-09-19 21:25:19 +00:00
while (changesMade)
{
changesMade = false;
2015-09-19 21:25:19 +00:00
foreach (var converter in converters)
{
2015-09-19 21:25:19 +00:00
if (await converter.Convert(item))
{
2015-09-19 21:25:19 +00:00
changesMade = true;
}
}
2015-09-19 21:25:19 +00:00
}
}
}
}