diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 11:58:35 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 11:58:35 -0400 |
| commit | d794eecec4f4b9a46df422b28c86e136bfd92abf (patch) | |
| tree | a0a063c127106ea064525d72426bcdb1052ff8da /MediaBrowser.Controller/Providers/LocalTrailerProvider.cs | |
| parent | 803ce0968e95232c7cdc72fc7af44d134590d6c7 (diff) | |
Added initial implementation of the metadata provider network, along with the first few providers
Diffstat (limited to 'MediaBrowser.Controller/Providers/LocalTrailerProvider.cs')
| -rw-r--r-- | MediaBrowser.Controller/Providers/LocalTrailerProvider.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs b/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs new file mode 100644 index 000000000..027c2f75d --- /dev/null +++ b/MediaBrowser.Controller/Providers/LocalTrailerProvider.cs @@ -0,0 +1,39 @@ +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;
+ }
+ }
+ }
+}
|
