diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/ConfigurationService.cs | 49 | ||||
| -rw-r--r-- | MediaBrowser.Api/LibraryService.cs | 49 |
2 files changed, 50 insertions, 48 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 diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index aeb795a78..f8b4caf94 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -435,56 +435,11 @@ namespace MediaBrowser.Api Task.WaitAll(task); } - private async Task DeleteItem(DeleteItem request) + private Task DeleteItem(DeleteItem request) { var item = _dtoService.GetItemByDtoId(request.Id); - var parent = item.Parent; - - var locationType = item.LocationType; - - if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) - { - foreach (var path in item.GetDeletePaths().ToList()) - { - if (Directory.Exists(path)) - { - Directory.Delete(path, true); - } - else if (File.Exists(path)) - { - File.Delete(path); - } - } - - if (parent != null) - { - try - { - await parent.ValidateChildren(new Progress<double>(), CancellationToken.None) - .ConfigureAwait(false); - } - catch (Exception ex) - { - Logger.ErrorException("Error refreshing item", ex); - } - } - } - else if (parent != null) - { - try - { - await parent.RemoveChild(item, CancellationToken.None).ConfigureAwait(false); - } - catch (Exception ex) - { - Logger.ErrorException("Error removing item", ex); - } - } - else - { - throw new InvalidOperationException("Don't know how to delete " + item.Name); - } + return _libraryManager.DeleteItem(item); } /// <summary> |
