update wizard function of enable/disable local metadata saving
This commit is contained in:
parent
6ff59b7e59
commit
44bb192ce0
|
@ -1,10 +1,15 @@
|
|||
using MediaBrowser.Common.Extensions;
|
||||
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;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using ServiceStack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -43,6 +48,13 @@ 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; }
|
||||
}
|
||||
|
||||
public class ConfigurationService : BaseApiService
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -106,5 +118,83 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
return ToOptimizedSerializedResultUsingCache(_providerManager.GetAllMetadataPlugins().ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a temporary method used until image settings get broken out.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
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(Trailer), 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 MetadataOptions GetMetadataOptions(Type type, ServerConfiguration config)
|
||||
{
|
||||
var options = config.MetadataOptions
|
||||
.FirstOrDefault(i => string.Equals(i.ItemType, type.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
var list = config.MetadataOptions.ToList();
|
||||
|
||||
options = new MetadataOptions
|
||||
{
|
||||
ItemType = type.Name
|
||||
};
|
||||
|
||||
list.Add(options);
|
||||
|
||||
config.MetadataOptions = list.ToArray();
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,17 +162,13 @@ namespace MediaBrowser.Controller.Library
|
|||
/// <param name="resolvers">The resolvers.</param>
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
/// <param name="itemComparers">The item comparers.</param>
|
||||
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||
/// <param name="postscanTasks">The postscan tasks.</param>
|
||||
/// <param name="peoplePrescanTasks">The people prescan tasks.</param>
|
||||
void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
||||
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||
IEnumerable<IItemResolver> resolvers,
|
||||
IEnumerable<IIntroProvider> introProviders,
|
||||
IEnumerable<IBaseItemComparer> itemComparers,
|
||||
IEnumerable<ILibraryPrescanTask> prescanTasks,
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks,
|
||||
IEnumerable<IPeoplePrescanTask> peoplePrescanTasks);
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks);
|
||||
|
||||
/// <summary>
|
||||
/// Sorts the specified items.
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for tasks that run prior to the media library scan
|
||||
/// </summary>
|
||||
public interface ILibraryPrescanTask
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs the specified progress.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task Run(IProgress<double> progress, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IPeoplePrescanTask
|
||||
/// </summary>
|
||||
public interface IPeoplePrescanTask
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs the specified progress.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task Run(IProgress<double> progress, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
|
@ -111,9 +111,7 @@
|
|||
<Compile Include="Entities\IHasAwards.cs" />
|
||||
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
|
||||
<Compile Include="Library\ILibraryPostScanTask.cs" />
|
||||
<Compile Include="Library\ILibraryPrescanTask.cs" />
|
||||
<Compile Include="Library\IMetadataSaver.cs" />
|
||||
<Compile Include="Library\IPeoplePrescanTask.cs" />
|
||||
<Compile Include="Library\ItemUpdateType.cs" />
|
||||
<Compile Include="Library\IUserDataManager.cs" />
|
||||
<Compile Include="Library\UserDataSaveEventArgs.cs" />
|
||||
|
|
|
@ -88,5 +88,12 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <param name="updateType">Type of the update.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveMetadata(IHasMetadata item, ItemUpdateType updateType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata options.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>MetadataOptions.</returns>
|
||||
MetadataOptions GetMetadataOptions(IHasMetadata item);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Folders
|
||||
{
|
||||
public class UserRootFolderNameProvider : BaseMetadataProvider
|
||||
{
|
||||
public UserRootFolderNameProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is UserRootFolder;
|
||||
}
|
||||
|
||||
public override Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var parentName = Path.GetFileNameWithoutExtension(item.Path);
|
||||
|
||||
if (string.Equals(parentName, "default", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.Name = "Media Library";
|
||||
}
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
|
||||
return TrueTaskResult;
|
||||
}
|
||||
|
||||
public override MetadataProviderPriority Priority
|
||||
{
|
||||
get { return MetadataProviderPriority.First; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -71,7 +71,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
|
||||
var itemOfType = (TItemType)item;
|
||||
var config = GetMetadataOptions(itemOfType);
|
||||
var config = ProviderManager.GetMetadataOptions(item);
|
||||
|
||||
var updateType = ItemUpdateType.Unspecified;
|
||||
var refreshResult = GetLastResult(item.Id);
|
||||
|
@ -157,15 +157,6 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
private readonly MetadataOptions _defaultOptions = new MetadataOptions();
|
||||
protected MetadataOptions GetMetadataOptions(TItemType item)
|
||||
{
|
||||
var type = item.GetType().Name;
|
||||
return ServerConfigurationManager.Configuration.MetadataOptions
|
||||
.FirstOrDefault(i => string.Equals(i.ItemType, type, StringComparison.OrdinalIgnoreCase)) ??
|
||||
_defaultOptions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Befores the metadata refresh.
|
||||
/// </summary>
|
||||
|
|
|
@ -470,7 +470,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}));
|
||||
|
||||
// Savers
|
||||
list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
|
||||
list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit, false)).OrderBy(i => i.Name).Select(i => new MetadataPlugin
|
||||
{
|
||||
Name = i.Name,
|
||||
Type = MetadataPluginType.MetadataSaver
|
||||
|
@ -498,6 +498,14 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
private readonly ConcurrentDictionary<string, SemaphoreSlim> _fileLocks = new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
public MetadataOptions GetMetadataOptions(IHasMetadata item)
|
||||
{
|
||||
var type = item.GetType().Name;
|
||||
return ConfigurationManager.Configuration.MetadataOptions
|
||||
.FirstOrDefault(i => string.Equals(i.ItemType, type, StringComparison.OrdinalIgnoreCase)) ??
|
||||
new MetadataOptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the metadata.
|
||||
/// </summary>
|
||||
|
@ -506,7 +514,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)))
|
||||
foreach (var saver in _savers.Where(i => IsSaverEnabledForItem(i, item, updateType, true)))
|
||||
{
|
||||
_logger.Debug("Saving {0} to {1}.", item.Path ?? item.Name, saver.Name);
|
||||
|
||||
|
@ -559,10 +567,17 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType)
|
||||
private bool IsSaverEnabledForItem(IMetadataSaver saver, IHasMetadata item, ItemUpdateType updateType, bool enforceConfiguration)
|
||||
{
|
||||
var options = GetMetadataOptions(item);
|
||||
|
||||
try
|
||||
{
|
||||
if (enforceConfiguration && options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return saver.IsEnabledFor(item, updateType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -135,11 +135,11 @@
|
|||
<Compile Include="People\MovieDbPersonImageProvider.cs" />
|
||||
<Compile Include="Movies\MovieUpdatesPrescanTask.cs" />
|
||||
<Compile Include="Movies\MovieXmlParser.cs" />
|
||||
<Compile Include="Movies\FanArtMovieUpdatesPrescanTask.cs" />
|
||||
<Compile Include="Movies\FanArtMovieUpdatesPostScanTask.cs" />
|
||||
<Compile Include="Movies\MovieDbProvider.cs" />
|
||||
<Compile Include="Music\AlbumXmlProvider.cs" />
|
||||
<Compile Include="Music\ArtistXmlProvider.cs" />
|
||||
<Compile Include="Music\FanArtUpdatesPrescanTask.cs" />
|
||||
<Compile Include="Music\FanArtUpdatesPostScanTask.cs" />
|
||||
<Compile Include="Music\LastfmAlbumProvider.cs" />
|
||||
<Compile Include="Music\LastfmHelper.cs" />
|
||||
<Compile Include="Music\FanArtAlbumProvider.cs" />
|
||||
|
@ -172,7 +172,7 @@
|
|||
<Compile Include="TV\EpisodeMetadataService.cs" />
|
||||
<Compile Include="TV\EpisodeXmlProvider.cs" />
|
||||
<Compile Include="TV\EpisodeXmlParser.cs" />
|
||||
<Compile Include="TV\FanArtTvUpdatesPrescanTask.cs" />
|
||||
<Compile Include="TV\FanArtTvUpdatesPostScanTask.cs" />
|
||||
<Compile Include="TV\FanartSeasonProvider.cs" />
|
||||
<Compile Include="TV\FanartSeriesProvider.cs" />
|
||||
<Compile Include="TV\MovieDbSeriesImageProvider.cs" />
|
||||
|
@ -190,7 +190,6 @@
|
|||
<Compile Include="TV\SeriesXmlProvider.cs" />
|
||||
<Compile Include="TV\SeriesXmlParser.cs" />
|
||||
<Compile Include="TV\TvdbPrescanTask.cs" />
|
||||
<Compile Include="Folders\UserRootFolderNameProvider.cs" />
|
||||
<Compile Include="Users\UserMetadataService.cs" />
|
||||
<Compile Include="Videos\VideoMetadataService.cs" />
|
||||
<Compile Include="Years\YearMetadataService.cs" />
|
||||
|
|
|
@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.Movies
|
||||
{
|
||||
class FanartMovieUpdatesPrescanTask : ILibraryPostScanTask
|
||||
class FanartMovieUpdatesPostScanTask : ILibraryPostScanTask
|
||||
{
|
||||
private const string UpdatesUrl = "http://api.fanart.tv/webservice/newmovies/{0}/{1}/";
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
public FanartMovieUpdatesPrescanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
public FanartMovieUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
{
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_config = config;
|
||||
|
@ -118,7 +118,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
return new List<string>();
|
||||
}
|
||||
|
||||
var updates = _jsonSerializer.DeserializeFromString<List<FanartUpdatesPrescanTask.FanArtUpdate>>(json);
|
||||
var updates = _jsonSerializer.DeserializeFromString<List<FanartUpdatesPostScanTask.FanArtUpdate>>(json);
|
||||
|
||||
var existingDictionary = existingIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
|
@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
class FanartUpdatesPrescanTask : ILibraryPostScanTask
|
||||
class FanartUpdatesPostScanTask : ILibraryPostScanTask
|
||||
{
|
||||
private const string UpdatesUrl = "http://api.fanart.tv/webservice/newmusic/{0}/{1}/";
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace MediaBrowser.Providers.Music
|
|||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
public FanartUpdatesPrescanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
public FanartUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
{
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_config = config;
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is MusicAlbum;
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
|
||||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
// If new metadata has been downloaded or metadata was manually edited, proceed
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
if (item is MusicArtist)
|
||||
{
|
||||
|
@ -56,16 +56,6 @@ namespace MediaBrowser.Providers.Savers
|
|||
}
|
||||
}
|
||||
|
||||
// If new metadata has been downloaded or metadata was manually edited, proceed
|
||||
if (wasMetadataDownloaded || wasMetadataEdited)
|
||||
{
|
||||
var artist = item as MusicArtist;
|
||||
if (artist != null && artist.IsAccessedByName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is BoxSet;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is Episode;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
|
||||
!(item is Season) &&
|
||||
|
@ -65,15 +65,6 @@ namespace MediaBrowser.Providers.Savers
|
|||
}
|
||||
}
|
||||
|
||||
// If new metadata has been downloaded or metadata was manually edited, proceed
|
||||
if (wasMetadataDownloaded || wasMetadataEdited)
|
||||
{
|
||||
if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is GameSystem;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is Game;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
var video = item as Video;
|
||||
// Check parent for null to avoid running this against things like video backdrops
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is Season;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
|
||||
|
||||
// If new metadata has been downloaded and save local is on
|
||||
if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
|
||||
if (wasMetadataEdited || wasMetadataDownloaded)
|
||||
{
|
||||
return item is Series;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
class FanArtTvUpdatesPrescanTask : ILibraryPostScanTask
|
||||
class FanArtTvUpdatesPostScanTask : ILibraryPostScanTask
|
||||
{
|
||||
private const string UpdatesUrl = "http://api.fanart.tv/webservice/newtv/{0}/{1}/";
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
public FanArtTvUpdatesPrescanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
public FanArtTvUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem)
|
||||
{
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_config = config;
|
||||
|
@ -127,7 +127,7 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
var existingDictionary = existingSeriesIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var updates = _jsonSerializer.DeserializeFromString<List<FanartUpdatesPrescanTask.FanArtUpdate>>(json);
|
||||
var updates = _jsonSerializer.DeserializeFromString<List<FanartUpdatesPostScanTask.FanArtUpdate>>(json);
|
||||
|
||||
return updates.Select(i => i.id).Where(existingDictionary.ContainsKey);
|
||||
}
|
|
@ -17,7 +17,7 @@ using System.Xml;
|
|||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
class SeriesPostScanTask : ILibraryPostScanTask
|
||||
class SeriesPostScanTask : ILibraryPostScanTask, IHasOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// The _library manager
|
||||
|
@ -89,6 +89,15 @@ namespace MediaBrowser.Providers.TV
|
|||
progress.Report(percent);
|
||||
}
|
||||
}
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// Run after tvdb update task
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MissingEpisodeProvider
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace MediaBrowser.Providers.TV
|
|||
/// <summary>
|
||||
/// Class TvdbPrescanTask
|
||||
/// </summary>
|
||||
public class TvdbPrescanTask : ILibraryPrescanTask
|
||||
public class TvdbPrescanTask : ILibraryPostScanTask
|
||||
{
|
||||
/// <summary>
|
||||
/// The server time URL
|
||||
|
|
|
@ -38,24 +38,13 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// Gets or sets the postscan tasks.
|
||||
/// </summary>
|
||||
/// <value>The postscan tasks.</value>
|
||||
private IEnumerable<ILibraryPostScanTask> PostscanTasks { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the prescan tasks.
|
||||
/// </summary>
|
||||
/// <value>The prescan tasks.</value>
|
||||
private IEnumerable<ILibraryPrescanTask> PrescanTasks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the people prescan tasks.
|
||||
/// </summary>
|
||||
/// <value>The people prescan tasks.</value>
|
||||
private IEnumerable<IPeoplePrescanTask> PeoplePrescanTasks { get; set; }
|
||||
private ILibraryPostScanTask[] PostscanTasks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intro providers.
|
||||
/// </summary>
|
||||
/// <value>The intro providers.</value>
|
||||
private IEnumerable<IIntroProvider> IntroProviders { get; set; }
|
||||
private IIntroProvider[] IntroProviders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of entity resolution ignore rules
|
||||
|
@ -205,26 +194,27 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// <param name="resolvers">The resolvers.</param>
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
/// <param name="itemComparers">The item comparers.</param>
|
||||
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||
/// <param name="postscanTasks">The postscan tasks.</param>
|
||||
/// <param name="peoplePrescanTasks">The people prescan tasks.</param>
|
||||
public void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
||||
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||
IEnumerable<IItemResolver> resolvers,
|
||||
IEnumerable<IIntroProvider> introProviders,
|
||||
IEnumerable<IBaseItemComparer> itemComparers,
|
||||
IEnumerable<ILibraryPrescanTask> prescanTasks,
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks,
|
||||
IEnumerable<IPeoplePrescanTask> peoplePrescanTasks)
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks)
|
||||
{
|
||||
EntityResolutionIgnoreRules = rules.ToArray();
|
||||
PluginFolderCreators = pluginFolders.ToArray();
|
||||
EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray();
|
||||
IntroProviders = introProviders;
|
||||
IntroProviders = introProviders.ToArray();
|
||||
Comparers = itemComparers.ToArray();
|
||||
PrescanTasks = prescanTasks;
|
||||
PostscanTasks = postscanTasks;
|
||||
PeoplePrescanTasks = peoplePrescanTasks;
|
||||
|
||||
PostscanTasks = postscanTasks.OrderBy(i =>
|
||||
{
|
||||
var hasOrder = i as IHasOrder;
|
||||
|
||||
return hasOrder == null ? 0 : hasOrder.Order;
|
||||
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -845,7 +835,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// <returns>Task.</returns>
|
||||
public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
return new PeopleValidator(this, PeoplePrescanTasks, _logger).ValidatePeople(cancellationToken, progress);
|
||||
return new PeopleValidator(this, _logger).ValidatePeople(cancellationToken, progress);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -970,14 +960,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
|
||||
innerProgress.RegisterAction(pct => progress.Report(2 + pct * .13));
|
||||
|
||||
// Run prescan tasks
|
||||
await RunPrescanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
progress.Report(15);
|
||||
|
||||
innerProgress = new ActionableProgress<double>();
|
||||
|
||||
innerProgress.RegisterAction(pct => progress.Report(15 + pct * .6));
|
||||
innerProgress.RegisterAction(pct => progress.Report(2 + pct * .73));
|
||||
|
||||
// Now validate the entire media library
|
||||
await RootFolder.ValidateChildren(innerProgress, cancellationToken, new MetadataRefreshOptions(), recursive: true).ConfigureAwait(false);
|
||||
|
@ -998,55 +983,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the prescan tasks.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task RunPrescanTasks(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = PrescanTasks.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var numTasks = tasks.Count;
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
// Prevent access to modified closure
|
||||
var currentNumComplete = numComplete;
|
||||
|
||||
innerProgress.RegisterAction(pct =>
|
||||
{
|
||||
double innerPercent = (currentNumComplete * 100) + pct;
|
||||
innerPercent /= numTasks;
|
||||
progress.Report(innerPercent);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
await task.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Pre-scan task cancelled: {0}", task.GetType().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running pre-scan task", ex);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= numTasks;
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the post scan tasks.
|
||||
/// </summary>
|
||||
|
|
|
@ -3,7 +3,6 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Model.Logging;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -24,19 +23,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IEnumerable<IPeoplePrescanTask> _prescanTasks;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PeopleValidator" /> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public PeopleValidator(ILibraryManager libraryManager, IEnumerable<IPeoplePrescanTask> prescanTasks, ILogger logger)
|
||||
public PeopleValidator(ILibraryManager libraryManager, ILogger logger)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_prescanTasks = prescanTasks;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -51,11 +46,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
|
||||
innerProgress.RegisterAction(pct => progress.Report(pct * .15));
|
||||
|
||||
// Run prescan tasks
|
||||
await RunPrescanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
progress.Report(15);
|
||||
|
||||
var people = _libraryManager.RootFolder.GetRecursiveChildren()
|
||||
.SelectMany(c => c.People)
|
||||
.DistinctBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
|
||||
|
@ -94,55 +84,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the prescan tasks.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task RunPrescanTasks(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = _prescanTasks.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var numTasks = tasks.Count;
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
// Prevent access to modified closure
|
||||
var currentNumComplete = numComplete;
|
||||
|
||||
innerProgress.RegisterAction(pct =>
|
||||
{
|
||||
double innerPercent = (currentNumComplete * 100) + pct;
|
||||
innerPercent /= numTasks;
|
||||
progress.Report(innerPercent);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
await task.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Pre-scan task cancelled: {0}", task.GetType().Name);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running pre-scan task", ex);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= numTasks;
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -497,9 +497,7 @@ namespace MediaBrowser.ServerApplication
|
|||
GetExports<IItemResolver>(),
|
||||
GetExports<IIntroProvider>(),
|
||||
GetExports<IBaseItemComparer>(),
|
||||
GetExports<ILibraryPrescanTask>(),
|
||||
GetExports<ILibraryPostScanTask>(),
|
||||
GetExports<IPeoplePrescanTask>());
|
||||
GetExports<ILibraryPostScanTask>());
|
||||
|
||||
ProviderManager.AddParts(GetExports<IImageProvider>(), GetExports<IMetadataService>(), GetExports<IMetadataProvider>(),
|
||||
GetExports<IMetadataSaver>());
|
||||
|
|
Loading…
Reference in New Issue
Block a user