SeasonResolver.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using MediaBrowser.Controller.Configuration;
  2. using MediaBrowser.Controller.Entities.TV;
  3. using MediaBrowser.Controller.Library;
  4. using MediaBrowser.Naming.Common;
  5. using MediaBrowser.Naming.TV;
  6. namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
  7. {
  8. /// <summary>
  9. /// Class SeasonResolver
  10. /// </summary>
  11. public class SeasonResolver : FolderResolver<Season>
  12. {
  13. /// <summary>
  14. /// The _config
  15. /// </summary>
  16. private readonly IServerConfigurationManager _config;
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="SeasonResolver"/> class.
  19. /// </summary>
  20. /// <param name="config">The config.</param>
  21. public SeasonResolver(IServerConfigurationManager config)
  22. {
  23. _config = config;
  24. }
  25. /// <summary>
  26. /// Resolves the specified args.
  27. /// </summary>
  28. /// <param name="args">The args.</param>
  29. /// <returns>Season.</returns>
  30. protected override Season Resolve(ItemResolveArgs args)
  31. {
  32. if (args.Parent is Series && args.IsDirectory)
  33. {
  34. var season = new Season
  35. {
  36. IndexNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(args.Path, true).SeasonNumber
  37. };
  38. if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
  39. {
  40. season.Name = _config.Configuration.SeasonZeroDisplayName;
  41. }
  42. return season;
  43. }
  44. return null;
  45. }
  46. }
  47. }