2012-07-12 08:55:27 +02:00
|
|
|
|
using System;
|
2012-07-26 04:33:11 +02:00
|
|
|
|
using System.ComponentModel.Composition;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using MediaBrowser.Controller;
|
|
|
|
|
using MediaBrowser.Controller.Events;
|
2012-08-21 01:53:32 +02:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Movies.Entities;
|
2012-08-23 07:45:26 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Movies.Resolvers
|
|
|
|
|
{
|
2012-07-26 04:33:11 +02:00
|
|
|
|
[Export(typeof(IBaseItemResolver))]
|
2012-07-12 08:55:27 +02:00
|
|
|
|
public class MovieResolver : BaseVideoResolver<Movie>
|
|
|
|
|
{
|
|
|
|
|
protected override Movie Resolve(ItemResolveEventArgs args)
|
|
|
|
|
{
|
2012-08-21 16:42:40 +02:00
|
|
|
|
if ((args.VirtualFolderCollectionType ?? string.Empty).Equals("Movies", StringComparison.OrdinalIgnoreCase) && args.IsDirectory)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
if (args.ContainsFile("movie.xml") || Path.GetFileName(args.Path).IndexOf("[tmdbid=", StringComparison.OrdinalIgnoreCase) != -1)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-13 05:50:50 +02:00
|
|
|
|
return GetMovie(args) ?? new Movie();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If it's not a boxset, the only other allowed parent type is Folder
|
|
|
|
|
if (!(args.Parent is BoxSet))
|
|
|
|
|
{
|
|
|
|
|
if (args.Parent != null && args.Parent.GetType() != typeof(Folder))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
2012-07-12 19:09:35 +02:00
|
|
|
|
|
|
|
|
|
// There's no metadata or [tmdb in the path, now we will have to work some magic to see if this is a Movie
|
2012-07-13 05:50:50 +02:00
|
|
|
|
if (args.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
return GetMovie(args);
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Movie GetMovie(ItemResolveEventArgs args)
|
|
|
|
|
{
|
2012-08-21 03:51:00 +02:00
|
|
|
|
for (var i = 0; i < args.FileSystemChildren.Length; i++)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-21 03:51:00 +02:00
|
|
|
|
var child = args.FileSystemChildren[i];
|
|
|
|
|
|
2012-07-12 08:55:27 +02:00
|
|
|
|
ItemResolveEventArgs childArgs = new ItemResolveEventArgs()
|
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
FileInfo = child,
|
|
|
|
|
FileSystemChildren = new WIN32_FIND_DATA[] { },
|
|
|
|
|
Path = child.Path
|
2012-07-12 08:55:27 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var item = base.Resolve(childArgs);
|
|
|
|
|
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
return new Movie()
|
|
|
|
|
{
|
|
|
|
|
Path = item.Path,
|
|
|
|
|
VideoType = item.VideoType
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 05:50:50 +02:00
|
|
|
|
return null;
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
/*private void PopulateBonusFeatures(Movie item, ItemResolveEventArgs args)
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
if (args.ContainsFolder("specials"))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-08-23 07:45:26 +02:00
|
|
|
|
List<Video> items = new List<Video>();
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-23 07:45:26 +02: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 08:55:27 +02:00
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
if (video != null)
|
|
|
|
|
{
|
|
|
|
|
items.Add(video);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 08:55:27 +02:00
|
|
|
|
|
2012-08-23 07:45:26 +02:00
|
|
|
|
(item as BaseItem).LocalTrailers = items;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
2012-07-12 08:55:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|