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