jellyfin-server/MediaBrowser.Controller/Providers/Movies/MovieSpecialFeaturesProvider.cs
LukePulverenti Luke Pulverenti luke pulverenti 2884df296c Moved Movies into the main project
2012-09-08 14:37:55 -04:00

46 lines
1.4 KiB
C#

using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Entities.Movies;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers.Movies
{
[Export(typeof(BaseMetadataProvider))]
public class MovieSpecialFeaturesProvider : BaseMetadataProvider
{
public override bool Supports(BaseEntity item)
{
return item is Movie;
}
public override MetadataProviderPriority Priority
{
get { return MetadataProviderPriority.First; }
}
public async override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
{
if (args.ContainsFolder("specials"))
{
List<Video> items = new List<Video>();
foreach (WIN32_FIND_DATA file in FileData.GetFileSystemEntries(Path.Combine(args.Path, "specials"), "*"))
{
Video video = await Kernel.Instance.ItemController.GetItem(file.Path, fileInfo: file).ConfigureAwait(false) as Video;
if (video != null)
{
items.Add(video);
}
}
(item as Movie).SpecialFeatures = items;
}
}
}
}