2014-12-28 07:21:39 +01:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-03-03 17:53:58 +01:00
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2013-03-03 07:58:04 +01:00
|
|
|
|
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class SeriesResolver
|
|
|
|
|
/// </summary>
|
2013-03-03 07:58:04 +01:00
|
|
|
|
public class SeriesResolver : FolderResolver<Series>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The priority.</value>
|
|
|
|
|
public override ResolverPriority Priority
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return ResolverPriority.Second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the specified args.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
/// <returns>Series.</returns>
|
|
|
|
|
protected override Series Resolve(ItemResolveArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (args.IsDirectory)
|
|
|
|
|
{
|
2013-09-04 19:07:35 +02:00
|
|
|
|
var collectionType = args.GetCollectionType();
|
2013-07-27 20:24:48 +02:00
|
|
|
|
|
|
|
|
|
// If there's a collection type and it's not tv, it can't be a series
|
2014-12-28 07:21:39 +01:00
|
|
|
|
if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2014-12-28 07:21:39 +01:00
|
|
|
|
if (args.HasParent<Series>())
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-29 20:51:30 +01:00
|
|
|
|
return new Series
|
|
|
|
|
{
|
|
|
|
|
Path = args.Path,
|
2014-12-04 06:24:41 +01:00
|
|
|
|
Name = Path.GetFileName(args.Path)
|
2014-11-29 20:51:30 +01:00
|
|
|
|
};
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the initial item values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
protected override void SetInitialItemValues(Series item, ItemResolveArgs args)
|
|
|
|
|
{
|
|
|
|
|
base.SetInitialItemValues(item, args);
|
|
|
|
|
|
2013-03-03 07:58:04 +01:00
|
|
|
|
SetProviderIdFromPath(item, args.Path);
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the provider id from path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2013-04-10 18:04:13 +02:00
|
|
|
|
/// <param name="path">The path.</param>
|
2013-03-03 07:58:04 +01:00
|
|
|
|
private void SetProviderIdFromPath(Series item, string path)
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2013-03-03 07:58:04 +01:00
|
|
|
|
var justName = Path.GetFileName(path);
|
2013-02-21 02:33:05 +01:00
|
|
|
|
|
|
|
|
|
var id = justName.GetAttributeValue("tvdbid");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(id))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Tvdb, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|