2012-09-11 01:34:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2012-09-08 19:05:18 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
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;
|
|
|
|
|
|
2012-09-08 19:05:18 +00:00
|
|
|
|
namespace MediaBrowser.Controller.Resolvers.TV
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
2012-08-27 12:18:59 +00:00
|
|
|
|
if (args.IsDirectory)
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-08-28 16:36:31 +00:00
|
|
|
|
// Optimization to avoid running all these tests against VF's
|
2012-08-28 18:16:35 +00:00
|
|
|
|
if (args.Parent != null && args.Parent.IsRoot)
|
2012-08-28 16:36:31 +00:00
|
|
|
|
{
|
|
|
|
|
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-08-23 18:35:44 +00: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 05:45:26 +00:00
|
|
|
|
if (args.ContainsFile("series.xml") || 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;
|
|
|
|
|
}
|
2012-08-23 20:51:10 +00:00
|
|
|
|
|
|
|
|
|
protected override void SetInitialItemValues(Series item, ItemResolveEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
base.SetInitialItemValues(item, args);
|
|
|
|
|
|
|
|
|
|
SetProviderIdFromPath(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetProviderIdFromPath(Series item)
|
|
|
|
|
{
|
|
|
|
|
string srch = "[tvdbid=";
|
|
|
|
|
int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
|
|
|
|
string id = item.Path.Substring(index + srch.Length);
|
|
|
|
|
|
|
|
|
|
id = id.Substring(0, id.IndexOf(']'));
|
|
|
|
|
|
|
|
|
|
item.SetProviderId(MetadataProviders.Tvdb, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|