add back global metadata settings

pull/702/head
Luke Pulverenti 11 years ago
parent 88965f75e2
commit 74625cc580

@ -2,7 +2,6 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@ -48,13 +47,6 @@ namespace MediaBrowser.Api
}
[Route("/System/Configuration/SaveLocalMetadata", "POST")]
[Api(("Updates saving of local metadata and images for all types"))]
public class UpdateSaveLocalMetadata : IReturnVoid
{
public bool Enabled { get; set; }
}
[Route("/System/Configuration/VideoImageExtraction", "POST")]
[Api(("Updates image extraction for all types"))]
public class UpdateVideoImageExtraction : IReturnVoid
@ -144,57 +136,6 @@ namespace MediaBrowser.Api
_configurationManager.SaveConfiguration();
}
public void Post(UpdateSaveLocalMetadata request)
{
var config = _configurationManager.Configuration;
if (request.Enabled)
{
config.SaveLocalMeta = true;
foreach (var options in config.MetadataOptions)
{
options.DisabledMetadataSavers = new string[] { };
}
}
else
{
config.SaveLocalMeta = false;
DisableSaversForType(typeof(Game), config);
DisableSaversForType(typeof(GameSystem), config);
DisableSaversForType(typeof(Movie), config);
DisableSaversForType(typeof(BoxSet), config);
DisableSaversForType(typeof(Book), config);
DisableSaversForType(typeof(Series), config);
DisableSaversForType(typeof(Season), config);
DisableSaversForType(typeof(Episode), config);
DisableSaversForType(typeof(MusicAlbum), config);
DisableSaversForType(typeof(MusicArtist), config);
DisableSaversForType(typeof(AdultVideo), config);
DisableSaversForType(typeof(MusicVideo), config);
DisableSaversForType(typeof(Video), config);
}
_configurationManager.SaveConfiguration();
}
private void DisableSaversForType(Type type, ServerConfiguration config)
{
var options = GetMetadataOptions(type, config);
const string mediabrowserSaverName = "Media Browser Xml";
if (!options.DisabledMetadataSavers.Contains(mediabrowserSaverName, StringComparer.OrdinalIgnoreCase))
{
var list = options.DisabledMetadataSavers.ToList();
list.Add(mediabrowserSaverName);
options.DisabledMetadataSavers = list.ToArray();
}
}
private void EnableImageExtractionForType(Type type, ServerConfiguration config, bool enabled)
{
var options = GetMetadataOptions(type, config);

@ -276,6 +276,11 @@ namespace MediaBrowser.Providers.Manager
if (provider is IRemoteMetadataProvider)
{
if (!ConfigurationManager.Configuration.EnableInternetProviders)
{
return false;
}
if (Array.IndexOf(options.DisabledMetadataFetchers, provider.Name) != -1)
{
return false;
@ -312,6 +317,11 @@ namespace MediaBrowser.Providers.Manager
if (provider is IRemoteImageProvider)
{
if (!ConfigurationManager.Configuration.EnableInternetProviders)
{
return false;
}
if (Array.IndexOf(options.DisabledImageFetchers, provider.Name) != -1)
{
return false;
@ -473,19 +483,25 @@ namespace MediaBrowser.Providers.Manager
Type = MetadataPluginType.LocalMetadataProvider
}));
// Fetchers
list.AddRange(providers.Where(i => (i is IRemoteMetadataProvider)).Select(i => new MetadataPlugin
if (ConfigurationManager.Configuration.EnableInternetProviders)
{
Name = i.Name,
Type = MetadataPluginType.MetadataFetcher
}));
// Savers
list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit, false)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
// Fetchers
list.AddRange(providers.Where(i => (i is IRemoteMetadataProvider)).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.MetadataFetcher
}));
}
if (item.IsSaveLocalMetadataEnabled())
{
Name = i.Name,
Type = MetadataPluginType.MetadataSaver
}));
// Savers
list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit, true)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.MetadataSaver
}));
}
}
private void AddImagePlugins<T>(List<MetadataPlugin> list, T item, List<IImageProvider> imageProviders)
@ -499,8 +515,18 @@ namespace MediaBrowser.Providers.Manager
Type = MetadataPluginType.LocalImageProvider
}));
if (ConfigurationManager.Configuration.EnableInternetProviders)
{
// Fetchers
list.AddRange(imageProviders.Where(i => i is IRemoteImageProvider).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.ImageFetcher
}));
}
// Fetchers
list.AddRange(imageProviders.Where(i => !(i is ILocalImageProvider)).Select(i => new MetadataPlugin
list.AddRange(imageProviders.Where(i => i is IDynamicImageProvider).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.ImageFetcher
@ -526,7 +552,7 @@ namespace MediaBrowser.Providers.Manager
/// <returns>Task.</returns>
public async Task SaveMetadata(IHasMetadata item, ItemUpdateType updateType)
{
foreach (var saver in _savers.Where(i => IsSaverEnabledForItem(i, item, updateType, true)))
foreach (var saver in _savers.Where(i => IsSaverEnabledForItem(i, item, updateType, false)))
{
_logger.Debug("Saving {0} to {1}.", item.Path ?? item.Name, saver.Name);
@ -579,15 +605,23 @@ namespace MediaBrowser.Providers.Manager
}
}
private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType, bool enforceConfiguration)
private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType, bool includeDisabled)
{
var options = GetMetadataOptions(item);
try
{
if (enforceConfiguration && options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
if (!includeDisabled)
{
return false;
if (!item.IsSaveLocalMetadataEnabled())
{
return false;
}
if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
{
return false;
}
}
return saver.IsEnabledFor(item, updateType);

Loading…
Cancel
Save