jellyfin/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs

112 lines
3.0 KiB
C#
Raw Normal View History

using MediaBrowser.Model.Entities;
2014-06-13 14:24:14 +00:00
using System.Collections.Generic;
2014-08-26 02:30:52 +00:00
using System.Linq;
namespace MediaBrowser.Controller.Providers
{
public class MetadataRefreshOptions : ImageRefreshOptions
{
/// <summary>
/// When paired with MetadataRefreshMode=FullRefresh, all existing data will be overwritten with new data from the providers.
/// </summary>
public bool ReplaceAllMetadata { get; set; }
public MetadataRefreshMode MetadataRefreshMode { get; set; }
public bool ForceSave { get; set; }
public MetadataRefreshOptions()
2014-10-25 18:32:58 +00:00
: this(new DirectoryService())
{
}
public MetadataRefreshOptions(IDirectoryService directoryService)
: base(directoryService)
{
MetadataRefreshMode = MetadataRefreshMode.Default;
}
2014-08-26 02:30:52 +00:00
2014-10-25 18:32:58 +00:00
public MetadataRefreshOptions( MetadataRefreshOptions copy)
: base(copy.DirectoryService)
2014-08-26 02:30:52 +00:00
{
MetadataRefreshMode = copy.MetadataRefreshMode;
ForceSave = copy.ForceSave;
ReplaceAllMetadata = copy.ReplaceAllMetadata;
ImageRefreshMode = copy.ImageRefreshMode;
ReplaceAllImages = copy.ReplaceAllImages;
ReplaceImages = copy.ReplaceImages.ToList();
}
}
public class ImageRefreshOptions
{
2014-01-31 04:50:09 +00:00
public ImageRefreshMode ImageRefreshMode { get; set; }
2014-10-25 18:32:58 +00:00
public IDirectoryService DirectoryService { get; private set; }
2014-01-31 04:50:09 +00:00
2014-06-13 14:24:14 +00:00
public bool ReplaceAllImages { get; set; }
public List<ImageType> ReplaceImages { get; set; }
2014-10-25 18:32:58 +00:00
public ImageRefreshOptions(IDirectoryService directoryService)
2014-01-31 04:50:09 +00:00
{
ImageRefreshMode = ImageRefreshMode.Default;
2014-10-25 18:32:58 +00:00
DirectoryService = directoryService;
2014-06-13 14:24:14 +00:00
ReplaceImages = new List<ImageType>();
}
public bool IsReplacingImage(ImageType type)
{
return ImageRefreshMode == ImageRefreshMode.FullRefresh &&
(ReplaceAllImages || ReplaceImages.Contains(type));
2014-01-31 04:50:09 +00:00
}
}
public enum MetadataRefreshMode
{
/// <summary>
/// The none
/// </summary>
None = 0,
/// <summary>
/// The validation only
/// </summary>
ValidationOnly = 1,
/// <summary>
/// Providers will be executed based on default rules
/// </summary>
Default = 2,
2014-05-17 04:24:10 +00:00
/// <summary>
/// All providers will be executed to search for new metadata
2014-05-17 04:24:10 +00:00
/// </summary>
FullRefresh = 3
}
2014-01-31 04:50:09 +00:00
public enum ImageRefreshMode
{
/// <summary>
/// The none
/// </summary>
None = 0,
2014-01-31 04:50:09 +00:00
/// <summary>
/// The default
/// </summary>
Default = 1,
2014-01-31 04:50:09 +00:00
/// <summary>
/// Existing images will be validated
/// </summary>
ValidationOnly = 2,
2014-01-31 04:50:09 +00:00
/// <summary>
/// All providers will be executed to search for new metadata
/// </summary>
FullRefresh = 3
2014-01-31 04:50:09 +00:00
}
}