SeasonResolver.cs 1.9 KB

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