SeasonResolver.cs 2.0 KB

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