BoxSetXmlSaver.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.IO;
  2. using System.Threading.Tasks;
  3. using System.Xml;
  4. using MediaBrowser.Controller.Configuration;
  5. using MediaBrowser.Controller.Entities;
  6. using MediaBrowser.Controller.Entities.Movies;
  7. using MediaBrowser.Controller.Library;
  8. using MediaBrowser.Model.IO;
  9. using Microsoft.Extensions.Logging;
  10. namespace MediaBrowser.LocalMetadata.Savers
  11. {
  12. /// <summary>
  13. /// Box set xml saver.
  14. /// </summary>
  15. public class BoxSetXmlSaver : BaseXmlSaver
  16. {
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="BoxSetXmlSaver"/> class.
  19. /// </summary>
  20. /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
  21. /// <param name="configurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
  22. /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
  23. /// <param name="logger">Instance of the <see cref="ILogger{BoxSetXmlSaver}"/> interface.</param>
  24. public BoxSetXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ILogger<BoxSetXmlSaver> logger)
  25. : base(fileSystem, configurationManager, libraryManager, logger)
  26. {
  27. }
  28. /// <inheritdoc />
  29. public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
  30. {
  31. if (!item.SupportsLocalMetadata)
  32. {
  33. return false;
  34. }
  35. return item is BoxSet && updateType >= ItemUpdateType.MetadataDownload;
  36. }
  37. /// <inheritdoc />
  38. protected override Task WriteCustomElementsAsync(BaseItem item, XmlWriter writer)
  39. => Task.CompletedTask;
  40. /// <inheritdoc />
  41. protected override string GetLocalSavePath(BaseItem item)
  42. {
  43. return Path.Combine(item.Path, "collection.xml");
  44. }
  45. }
  46. }