2012-09-08 18:37:55 +00:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.Entities.Movies;
|
|
|
|
|
using System.Collections.Generic;
|
2012-08-23 20:51:10 +00:00
|
|
|
|
using System.ComponentModel.Composition;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2012-09-08 18:37:55 +00:00
|
|
|
|
namespace MediaBrowser.Controller.Providers.Movies
|
2012-08-23 20:51:10 +00:00
|
|
|
|
{
|
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|