VirtualItemImageValidator.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using MediaBrowser.Controller.Configuration;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Controller.Entities.TV;
  4. using MediaBrowser.Controller.Providers;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.Logging;
  7. using System;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace MediaBrowser.Providers
  11. {
  12. public class VirtualItemImageValidator : BaseMetadataProvider
  13. {
  14. public VirtualItemImageValidator(ILogManager logManager, IServerConfigurationManager configurationManager)
  15. : base(logManager, configurationManager)
  16. {
  17. }
  18. public override bool Supports(BaseItem item)
  19. {
  20. var locationType = item.LocationType;
  21. // The regular provider will get virtual seasons
  22. if (item.LocationType == LocationType.Virtual)
  23. {
  24. var season = item as Season;
  25. if (season != null)
  26. {
  27. var series = season.Series;
  28. if (series != null && series.LocationType == LocationType.FileSystem)
  29. {
  30. return false;
  31. }
  32. }
  33. }
  34. return locationType == LocationType.Virtual ||
  35. locationType == LocationType.Remote;
  36. }
  37. public override Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
  38. {
  39. item.ValidateImages();
  40. item.ValidateBackdrops();
  41. var hasScreenshots = item as IHasScreenshots;
  42. if (hasScreenshots != null)
  43. {
  44. hasScreenshots.ValidateScreenshots();
  45. }
  46. SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
  47. return TrueTaskResult;
  48. }
  49. public override MetadataProviderPriority Priority
  50. {
  51. get { return MetadataProviderPriority.First; }
  52. }
  53. }
  54. }