jellyfin/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs

59 lines
1.9 KiB
C#
Raw Normal View History

using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
2013-02-21 01:33:05 +00:00
using MediaBrowser.Controller.Library;
2014-12-19 04:20:07 +00:00
using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.TV;
2013-02-21 01:33:05 +00:00
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
2013-02-21 01:33:05 +00:00
{
2013-02-23 07:57:11 +00:00
/// <summary>
/// Class SeasonResolver
/// </summary>
public class SeasonResolver : FolderResolver<Season>
2013-02-21 01:33:05 +00:00
{
/// <summary>
/// The _config
/// </summary>
private readonly IServerConfigurationManager _config;
2015-01-10 05:53:35 +00:00
private readonly ILibraryManager _libraryManager;
/// <summary>
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
/// </summary>
/// <param name="config">The config.</param>
2015-01-10 05:53:35 +00:00
public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager)
{
_config = config;
2015-01-10 05:53:35 +00:00
_libraryManager = libraryManager;
}
2013-02-23 07:57:11 +00:00
/// <summary>
/// Resolves the specified args.
/// </summary>
/// <param name="args">The args.</param>
/// <returns>Season.</returns>
2013-02-21 01:33:05 +00:00
protected override Season Resolve(ItemResolveArgs args)
{
if (args.Parent is Series && args.IsDirectory)
{
2015-01-10 05:53:35 +00:00
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
var season = new Season
2013-02-21 01:33:05 +00:00
{
2015-01-10 05:53:35 +00:00
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber
2013-02-21 01:33:05 +00:00
};
2014-11-16 20:44:08 +00:00
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
{
season.Name = _config.Configuration.SeasonZeroDisplayName;
}
return season;
2013-02-21 01:33:05 +00:00
}
return null;
}
}
}