jellyfin/MediaBrowser.Movies/Resolvers/MovieResolver.cs

75 lines
2.5 KiB
C#
Raw Normal View History

2012-07-12 06:55:27 +00:00
using System;
using System.ComponentModel.Composition;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.IO;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Movies.Entities;
namespace MediaBrowser.Movies.Resolvers
{
[Export(typeof(IBaseItemResolver))]
2012-07-12 06:55:27 +00:00
public class MovieResolver : BaseVideoResolver<Movie>
{
protected override Movie Resolve(ItemResolveEventArgs args)
{
// Must be a directory and under a 'Movies' VF
2012-08-21 14:42:40 +00:00
if ((args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase) && args.IsDirectory)
2012-07-12 06:55:27 +00:00
{
// Return a movie if the video resolver finds something in the folder
return GetMovie(args);
2012-07-12 06:55:27 +00:00
}
return null;
}
private Movie GetMovie(ItemResolveEventArgs args)
{
// Loop through each child file/folder and see if we find a video
for (var i = 0; i < args.FileSystemChildren.Length; i++)
2012-07-12 06:55:27 +00:00
{
var child = args.FileSystemChildren[i];
2012-07-12 06:55:27 +00:00
ItemResolveEventArgs childArgs = new ItemResolveEventArgs()
{
FileInfo = child,
FileSystemChildren = new WIN32_FIND_DATA[] { },
Path = child.Path
2012-07-12 06:55:27 +00:00
};
var item = base.Resolve(childArgs);
if (item != null)
{
return new Movie()
{
Path = item.Path,
VideoType = item.VideoType
};
}
}
return null;
2012-07-12 06:55:27 +00:00
}
/*private void PopulateBonusFeatures(Movie item, ItemResolveEventArgs args)
2012-07-12 06:55:27 +00:00
{
if (args.ContainsFolder("specials"))
2012-07-12 06:55:27 +00:00
{
List<Video> items = new List<Video>();
2012-07-12 06:55:27 +00:00
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;
2012-07-12 06:55:27 +00:00
if (video != null)
{
items.Add(video);
}
}
2012-07-12 06:55:27 +00:00
(item as BaseItem).LocalTrailers = items;
}
}*/
2012-07-12 06:55:27 +00:00
}
}