diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-19 13:50:37 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-19 13:50:37 -0500 |
| commit | 4a39df98cdd56505db5eea61d29509179cd9e48e (patch) | |
| tree | c6b43a8d539fa0c3504c007afffb58fe9a9619c4 /MediaBrowser.Api/ConfigurationService.cs | |
| parent | 411ce2175102c7e37546971b7f07f593260732c3 (diff) | |
rework image extraction settings
Diffstat (limited to 'MediaBrowser.Api/ConfigurationService.cs')
| -rw-r--r-- | MediaBrowser.Api/ConfigurationService.cs | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index d8ecc3685..b0b74ed66 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -55,6 +55,13 @@ namespace MediaBrowser.Api public bool Enabled { get; set; } } + [Route("/System/Configuration/VideoImageExtraction", "POST")] + [Api(("Updates image extraction for all types"))] + public class UpdateVideoImageExtraction : IReturnVoid + { + public bool Enabled { get; set; } + } + public class ConfigurationService : BaseApiService { /// <summary> @@ -123,6 +130,20 @@ namespace MediaBrowser.Api /// This is a temporary method used until image settings get broken out. /// </summary> /// <param name="request"></param> + public void Post(UpdateVideoImageExtraction request) + { + var config = _configurationManager.Configuration; + + EnableImageExtractionForType(typeof(Movie), config, request.Enabled); + EnableImageExtractionForType(typeof(Episode), config, request.Enabled); + EnableImageExtractionForType(typeof(AdultVideo), config, request.Enabled); + EnableImageExtractionForType(typeof(MusicVideo), config, request.Enabled); + EnableImageExtractionForType(typeof(Video), config, request.Enabled); + EnableImageExtractionForType(typeof(Trailer), config, request.Enabled); + + _configurationManager.SaveConfiguration(); + } + public void Post(UpdateSaveLocalMetadata request) { var config = _configurationManager.Configuration; @@ -157,7 +178,7 @@ namespace MediaBrowser.Api _configurationManager.SaveConfiguration(); } - + private void DisableSaversForType(Type type, ServerConfiguration config) { var options = GetMetadataOptions(type, config); @@ -174,6 +195,32 @@ namespace MediaBrowser.Api } } + private void EnableImageExtractionForType(Type type, ServerConfiguration config, bool enabled) + { + var options = GetMetadataOptions(type, config); + + const string imageProviderName = "Screen Grabber"; + + var contains = options.DisabledImageFetchers.Contains(imageProviderName, StringComparer.OrdinalIgnoreCase); + + if (!enabled && !contains) + { + var list = options.DisabledImageFetchers.ToList(); + + list.Add(imageProviderName); + + options.DisabledImageFetchers = list.ToArray(); + } + else if (enabled && contains) + { + var list = options.DisabledImageFetchers.ToList(); + + list.Remove(imageProviderName); + + options.DisabledImageFetchers = list.ToArray(); + } + } + private MetadataOptions GetMetadataOptions(Type type, ServerConfiguration config) { var options = config.MetadataOptions |
