SeasonResolver.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using MediaBrowser.Controller.Entities.TV;
  2. using MediaBrowser.Controller.Library;
  3. using System;
  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. /// Resolves the specified args.
  13. /// </summary>
  14. /// <param name="args">The args.</param>
  15. /// <returns>Season.</returns>
  16. protected override Season Resolve(ItemResolveArgs args)
  17. {
  18. if (args.Parent is Series && args.IsDirectory)
  19. {
  20. return new Season
  21. {
  22. IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path)
  23. };
  24. }
  25. return null;
  26. }
  27. /// <summary>
  28. /// Sets the initial item values.
  29. /// </summary>
  30. /// <param name="item">The item.</param>
  31. /// <param name="args">The args.</param>
  32. protected override void SetInitialItemValues(Season item, ItemResolveArgs args)
  33. {
  34. base.SetInitialItemValues(item, args);
  35. var series = args.Parent as Series;
  36. item.SeriesItemId = series != null ? series.Id : Guid.Empty;
  37. Season.AddMetadataFiles(args);
  38. }
  39. }
  40. }