You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using System.Collections.Generic;
|
|
using System.ComponentModel.Composition;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using MediaBrowser.Controller.Events;
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
namespace MediaBrowser.Controller.Providers
|
|
{
|
|
[Export(typeof(BaseMetadataProvider))]
|
|
public class LocalTrailerProvider : BaseMetadataProvider
|
|
{
|
|
public async override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
|
{
|
|
var trailerPath = args.GetFolderByName("trailers");
|
|
|
|
if (trailerPath.HasValue)
|
|
{
|
|
string[] allFiles = Directory.GetFileSystemEntries(trailerPath.Value.Key, "*", SearchOption.TopDirectoryOnly);
|
|
|
|
List<Video> localTrailers = new List<Video>();
|
|
|
|
foreach (string file in allFiles)
|
|
{
|
|
BaseItem child = await Kernel.Instance.ItemController.GetItem(null, file);
|
|
|
|
Video video = child as Video;
|
|
|
|
if (video != null)
|
|
{
|
|
localTrailers.Add(video);
|
|
}
|
|
}
|
|
|
|
item.LocalTrailers = localTrailers;
|
|
}
|
|
}
|
|
}
|
|
}
|