2012-09-11 01:34:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.IO;
|
2012-09-08 18:37:55 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
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"))
|
|
|
|
|
{
|
2012-09-11 19:37:14 +00:00
|
|
|
|
var items = new List<Video>();
|
2012-08-23 20:51:10 +00:00
|
|
|
|
|
|
|
|
|
foreach (WIN32_FIND_DATA file in FileData.GetFileSystemEntries(Path.Combine(args.Path, "specials"), "*"))
|
|
|
|
|
{
|
2012-09-11 19:37:14 +00:00
|
|
|
|
var video = await Kernel.Instance.ItemController.GetItem(file.Path, fileInfo: file).ConfigureAwait(false) as Video;
|
2012-08-23 20:51:10 +00:00
|
|
|
|
|
|
|
|
|
if (video != null)
|
|
|
|
|
{
|
|
|
|
|
items.Add(video);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(item as Movie).SpecialFeatures = items;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|