2012-07-12 06:55:27 +00:00
|
|
|
|
using System;
|
2012-07-26 02:33:11 +00:00
|
|
|
|
using System.ComponentModel.Composition;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using MediaBrowser.Controller.Events;
|
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
|
|
|
|
using MediaBrowser.TV.Entities;
|
|
|
|
|
using MediaBrowser.TV.Metadata;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.TV.Resolvers
|
|
|
|
|
{
|
2012-07-26 02:33:11 +00:00
|
|
|
|
[Export(typeof(IBaseItemResolver))]
|
|
|
|
|
public class SeriesResolver : BaseFolderResolver<Series>
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
|
|
|
|
protected override Series Resolve(ItemResolveEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (args.IsFolder)
|
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
// Optimization to avoid running these tests against VF's
|
|
|
|
|
if (args.Parent != null && args.Parent.IsRoot)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 17:09:35 +00:00
|
|
|
|
// Optimization to avoid running these tests against Seasons
|
|
|
|
|
if (args.Parent is Series)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-12 06:55:27 +00:00
|
|
|
|
var metadataFile = args.GetFileByName("series.xml");
|
|
|
|
|
|
2012-07-12 17:09:35 +00:00
|
|
|
|
if (metadataFile.HasValue || Path.GetFileName(args.Path).IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1 || TVUtils.IsSeriesFolder(args.Path, args.FileSystemChildren))
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
|
|
|
|
return new Series();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetItemValues(Series item, ItemResolveEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
base.SetItemValues(item, args);
|
|
|
|
|
|
|
|
|
|
var metadataFile = args.GetFileByName("series.xml");
|
|
|
|
|
|
|
|
|
|
if (metadataFile.HasValue)
|
|
|
|
|
{
|
|
|
|
|
new SeriesXmlParser().Fetch(item, metadataFile.Value.Key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|