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.Common.IO;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers; 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")] [Route("/System/Configuration/VideoImageExtraction", "POST")]
[Api(("Updates image extraction for all types"))] [Api(("Updates image extraction for all types"))]
public class UpdateVideoImageExtraction : IReturnVoid public class UpdateVideoImageExtraction : IReturnVoid
@ -144,57 +136,6 @@ namespace MediaBrowser.Api
_configurationManager.SaveConfiguration(); _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) private void EnableImageExtractionForType(Type type, ServerConfiguration config, bool enabled)
{ {
var options = GetMetadataOptions(type, config); var options = GetMetadataOptions(type, config);

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

Loading…
Cancel
Save