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 MediaBrowser.Controller.Events;
|
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
|
|
|
|
using MediaBrowser.TV.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.TV.Resolvers
|
|
|
|
|
{
|
2012-07-26 04:33:11 +02:00
|
|
|
|
[Export(typeof(IBaseItemResolver))]
|
|
|
|
|
public class SeriesResolver : BaseFolderResolver<Series>
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
protected override Series Resolve(ItemResolveEventArgs args)
|
|
|
|
|
{
|
2012-08-21 16:42:40 +02:00
|
|
|
|
if (args.IsDirectory && (args.VirtualFolderCollectionType ?? string.Empty).Equals("TV", StringComparison.OrdinalIgnoreCase))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
2012-07-12 19:09:35 +02:00
|
|
|
|
// Optimization to avoid running these tests against Seasons
|
|
|
|
|
if (args.Parent is Series)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 20:35:44 +02:00
|
|
|
|
// It's a Series if any of the following conditions are met:
|
|
|
|
|
// series.xml exists
|
|
|
|
|
// [tvdbid= is present in the path
|
|
|
|
|
// TVUtils.IsSeriesFolder returns true
|
2012-08-23 07:45:26 +02:00
|
|
|
|
if (args.ContainsFile("series.xml") || Path.GetFileName(args.Path).IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1 || TVUtils.IsSeriesFolder(args.Path, args.FileSystemChildren))
|
2012-07-12 08:55:27 +02:00
|
|
|
|
{
|
|
|
|
|
return new Series();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|