MetadataRefreshOptions.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Linq;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Model.Providers;
  5. namespace MediaBrowser.Controller.Providers
  6. {
  7. public class MetadataRefreshOptions : ImageRefreshOptions
  8. {
  9. /// <summary>
  10. /// When paired with MetadataRefreshMode=FullRefresh, all existing data will be overwritten with new data from the providers.
  11. /// </summary>
  12. public bool ReplaceAllMetadata { get; set; }
  13. public MetadataRefreshMode MetadataRefreshMode { get; set; }
  14. public RemoteSearchResult SearchResult { get; set; }
  15. public string[] RefreshPaths { get; set; }
  16. public bool ForceSave { get; set; }
  17. public bool EnableRemoteContentProbe { get; set; }
  18. public MetadataRefreshOptions(IDirectoryService directoryService)
  19. : base(directoryService)
  20. {
  21. MetadataRefreshMode = MetadataRefreshMode.Default;
  22. }
  23. public MetadataRefreshOptions(MetadataRefreshOptions copy)
  24. : base(copy.DirectoryService)
  25. {
  26. MetadataRefreshMode = copy.MetadataRefreshMode;
  27. ForceSave = copy.ForceSave;
  28. ReplaceAllMetadata = copy.ReplaceAllMetadata;
  29. EnableRemoteContentProbe = copy.EnableRemoteContentProbe;
  30. ImageRefreshMode = copy.ImageRefreshMode;
  31. ReplaceAllImages = copy.ReplaceAllImages;
  32. ReplaceImages = copy.ReplaceImages;
  33. SearchResult = copy.SearchResult;
  34. if (copy.RefreshPaths != null && copy.RefreshPaths.Length > 0)
  35. {
  36. if (RefreshPaths == null)
  37. {
  38. RefreshPaths = Array.Empty<string>();
  39. }
  40. RefreshPaths = copy.RefreshPaths.ToArray();
  41. }
  42. }
  43. public bool RefreshItem(BaseItem item)
  44. {
  45. if (RefreshPaths != null && RefreshPaths.Length > 0)
  46. {
  47. return RefreshPaths.Contains(item.Path ?? string.Empty, StringComparer.OrdinalIgnoreCase);
  48. }
  49. return true;
  50. }
  51. }
  52. }