diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index fb5f566930..012a553634 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -93,7 +93,7 @@ namespace MediaBrowser.Api.Playback
/// System.String.
protected string GetOutputFilePath(StreamState state)
{
- var folder = ApplicationPaths.FFMpegStreamCachePath;
+ var folder = ApplicationPaths.EncodedMediaCachePath;
return Path.Combine(folder, GetCommandLineArguments("dummy\\dummy", state).GetMD5() + GetOutputFileExtension(state).ToLower());
}
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index a5af2ff66a..a4d191148f 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -77,7 +77,7 @@ namespace MediaBrowser.Common.Implementations
///
/// The json serializer
///
- protected readonly IJsonSerializer JsonSerializer = new JsonSerializer();
+ public readonly IJsonSerializer JsonSerializer = new JsonSerializer();
///
/// The _XML serializer
@@ -524,8 +524,7 @@ namespace MediaBrowser.Common.Implementations
/// Task.
public async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress progress)
{
- var pkgManager = Resolve();
- await pkgManager.InstallPackage(progress, package, cancellationToken).ConfigureAwait(false);
+ await PackageManager.InstallPackage(progress, package, cancellationToken).ConfigureAwait(false);
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs { Argument = package.version }, Logger);
}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index e80c3d71f3..f90044d8b0 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -96,9 +96,10 @@ namespace MediaBrowser.Controller.Entities
///
/// The logger
///
- protected static internal ILogger Logger { get; internal set; }
- protected static internal ILibraryManager LibraryManager { get; internal set; }
- protected static internal IServerConfigurationManager ConfigurationManager { get; internal set; }
+ public static ILogger Logger { get; set; }
+ public static ILibraryManager LibraryManager { get; set; }
+ public static IServerConfigurationManager ConfigurationManager { get; set; }
+ public static IProviderManager ProviderManager { get; set; }
///
/// Returns a that represents this instance.
@@ -652,7 +653,7 @@ namespace MediaBrowser.Controller.Entities
LocalTrailers = null;
// Refresh for the item
- var itemRefreshTask = Kernel.Instance.ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);
+ var itemRefreshTask = ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs
index ef50a08671..7e50b1ea55 100644
--- a/MediaBrowser.Controller/Entities/User.cs
+++ b/MediaBrowser.Controller/Entities/User.cs
@@ -18,8 +18,8 @@ namespace MediaBrowser.Controller.Entities
///
public class User : BaseItem
{
- internal static IUserManager UserManager { get; set; }
- internal static IXmlSerializer XmlSerializer { get; set; }
+ public static IUserManager UserManager { get; set; }
+ public static IXmlSerializer XmlSerializer { get; set; }
///
/// The _root folder path
@@ -363,7 +363,7 @@ namespace MediaBrowser.Controller.Entities
ResolveArgs = null;
}
- var changed = await Kernel.Instance.ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders).ConfigureAwait(false);
+ var changed = await ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders).ConfigureAwait(false);
if (changed || forceSave)
{
diff --git a/MediaBrowser.Controller/IO/FileSystemManager.cs b/MediaBrowser.Controller/IO/FileSystemManager.cs
deleted file mode 100644
index 463672ece0..0000000000
--- a/MediaBrowser.Controller/IO/FileSystemManager.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Common.ScheduledTasks;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Model.Logging;
-using System;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Controller.IO
-{
- ///
- /// This class will manage our file system watching and modifications. Any process that needs to
- /// modify the directories that the system is watching for changes should use the methods of
- /// this class to do so. This way we can have the watchers correctly respond to only external changes.
- ///
- public class FileSystemManager : IDisposable
- {
- ///
- /// Gets or sets the directory watchers.
- ///
- /// The directory watchers.
- private DirectoryWatchers DirectoryWatchers { get; set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The log manager.
- /// The task manager.
- /// The library manager.
- /// The configuration manager.
- public FileSystemManager(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
- {
- DirectoryWatchers = new DirectoryWatchers(logManager, taskManager, libraryManager, configurationManager);
- }
-
- ///
- /// Start the directory watchers on our library folders
- ///
- public void StartWatchers()
- {
- DirectoryWatchers.Start();
- }
-
- ///
- /// Saves to library filesystem.
- ///
- /// The item.
- /// The path.
- /// The data to save.
- /// The cancellation token.
- /// Task.
- ///
- public async Task SaveToLibraryFilesystem(BaseItem item, string path, Stream dataToSave, CancellationToken cancellationToken)
- {
- if (item == null)
- {
- throw new ArgumentNullException();
- }
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException();
- }
- if (dataToSave == null)
- {
- throw new ArgumentNullException();
- }
- if (cancellationToken == null)
- {
- throw new ArgumentNullException();
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- //Tell the watchers to ignore
- DirectoryWatchers.TemporarilyIgnore(path);
-
- //Make the mod
-
- dataToSave.Position = 0;
-
- try
- {
- using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
- {
- await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
-
- dataToSave.Dispose();
-
- // If this is ever used for something other than metadata we can add a file type param
- item.ResolveArgs.AddMetadataFile(path);
- }
- }
- finally
- {
- //Remove the ignore
- DirectoryWatchers.RemoveTempIgnore(path);
- }
- }
-
- ///
- /// Releases unmanaged and - optionally - managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected virtual void Dispose(bool dispose)
- {
- if (dispose)
- {
- DirectoryWatchers.Dispose();
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
- }
-}
diff --git a/MediaBrowser.Controller/IO/IDirectoryWatchers.cs b/MediaBrowser.Controller/IO/IDirectoryWatchers.cs
new file mode 100644
index 0000000000..9a43ee8acf
--- /dev/null
+++ b/MediaBrowser.Controller/IO/IDirectoryWatchers.cs
@@ -0,0 +1,29 @@
+using System;
+
+namespace MediaBrowser.Controller.IO
+{
+ public interface IDirectoryWatchers : IDisposable
+ {
+ ///
+ /// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
+ ///
+ /// The path.
+ void TemporarilyIgnore(string path);
+
+ ///
+ /// Removes the temp ignore.
+ ///
+ /// The path.
+ void RemoveTempIgnore(string path);
+
+ ///
+ /// Starts this instance.
+ ///
+ void Start();
+
+ ///
+ /// Stops this instance.
+ ///
+ void Stop();
+ }
+}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs
index c9bac4dd2a..f88d7a5f6a 100644
--- a/MediaBrowser.Controller/IServerApplicationPaths.cs
+++ b/MediaBrowser.Controller/IServerApplicationPaths.cs
@@ -74,12 +74,18 @@ namespace MediaBrowser.Controller
/// Gets the FF MPEG stream cache path.
///
/// The FF MPEG stream cache path.
- string FFMpegStreamCachePath { get; }
+ string EncodedMediaCachePath { get; }
///
/// Gets the folder path to tools
///
/// The media tools path.
string MediaToolsPath { get; }
+
+ ///
+ /// Gets the downloaded images data path.
+ ///
+ /// The downloaded images data path.
+ string DownloadedImagesDataPath { get; }
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs
index 40c59c8cfd..d43c505a5e 100644
--- a/MediaBrowser.Controller/Kernel.cs
+++ b/MediaBrowser.Controller/Kernel.cs
@@ -1,22 +1,13 @@
-using MediaBrowser.Common;
-using MediaBrowser.Common.ScheduledTasks;
-using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.IO;
-using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.MediaInfo;
using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Weather;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller
@@ -24,7 +15,7 @@ namespace MediaBrowser.Controller
///
/// Class Kernel
///
- public class Kernel : IDisposable
+ public class Kernel
{
///
/// Gets the instance.
@@ -36,25 +27,13 @@ namespace MediaBrowser.Controller
/// Gets the image manager.
///
/// The image manager.
- public ImageManager ImageManager { get; private set; }
+ public ImageManager ImageManager { get; set; }
///
/// Gets the FFMPEG controller.
///
/// The FFMPEG controller.
- public FFMpegManager FFMpegManager { get; private set; }
-
- ///
- /// Gets or sets the file system manager.
- ///
- /// The file system manager.
- public FileSystemManager FileSystemManager { get; private set; }
-
- ///
- /// Gets the provider manager.
- ///
- /// The provider manager.
- public ProviderManager ProviderManager { get; private set; }
+ public FFMpegManager FFMpegManager { get; set; }
///
/// Gets the name of the web application that can be used for url building.
@@ -82,74 +61,68 @@ namespace MediaBrowser.Controller
/// Gets the list of Localized string files
///
/// The string files.
- public IEnumerable StringFiles { get; private set; }
+ public IEnumerable StringFiles { get; set; }
///
/// Gets the list of currently registered weather prvoiders
///
/// The weather providers.
- public IEnumerable WeatherProviders { get; private set; }
-
- ///
- /// Gets the list of currently registered metadata prvoiders
- ///
- /// The metadata providers enumerable.
- public BaseMetadataProvider[] MetadataProviders { get; private set; }
+ public IEnumerable WeatherProviders { get; set; }
///
/// Gets the list of currently registered image processors
/// Image processors are specialized metadata providers that run after the normal ones
///
/// The image enhancers.
- public IEnumerable ImageEnhancers { get; private set; }
+ public IEnumerable ImageEnhancers { get; set; }
///
/// Gets the list of available user repositories
///
/// The user repositories.
- private IEnumerable UserRepositories { get; set; }
+ public IEnumerable UserRepositories { get; set; }
///
/// Gets the active user repository
///
/// The user repository.
- public IUserRepository UserRepository { get; private set; }
+ public IUserRepository UserRepository { get; set; }
///
/// Gets the active user repository
///
/// The display preferences repository.
- public IDisplayPreferencesRepository DisplayPreferencesRepository { get; private set; }
+ public IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
///
/// Gets the list of available item repositories
///
/// The item repositories.
- private IEnumerable ItemRepositories { get; set; }
+ public IEnumerable ItemRepositories { get; set; }
///
/// Gets the active item repository
///
/// The item repository.
- public IItemRepository ItemRepository { get; private set; }
+ public IItemRepository ItemRepository { get; set; }
///
/// Gets the list of available DisplayPreferencesRepositories
///
/// The display preferences repositories.
- private IEnumerable DisplayPreferencesRepositories { get; set; }
+ public IEnumerable DisplayPreferencesRepositories { get; set; }
///
/// Gets the list of available item repositories
///
/// The user data repositories.
- private IEnumerable UserDataRepositories { get; set; }
+ public IEnumerable UserDataRepositories { get; set; }
///
/// Gets the active user data repository
///
/// The user data repository.
- public IUserDataRepository UserDataRepository { get; private set; }
+ public IUserDataRepository UserDataRepository { get; set; }
///
/// Gets the UDP server port number.
@@ -160,121 +133,39 @@ namespace MediaBrowser.Controller
get { return 7359; }
}
- private readonly IXmlSerializer _xmlSerializer;
-
private readonly IServerConfigurationManager _configurationManager;
- private readonly ILogManager _logManager;
- private IApplicationHost ApplicationHost { get; set; }
///
/// Creates a kernel based on a Data path, which is akin to our current programdata path
///
- /// The app host.
- /// The XML serializer.
- /// The log manager.
/// The configuration manager.
- /// isoManager
- public Kernel(IApplicationHost appHost, IXmlSerializer xmlSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
+ public Kernel(IServerConfigurationManager configurationManager)
{
Instance = this;
- ApplicationHost = appHost;
_configurationManager = configurationManager;
- _xmlSerializer = xmlSerializer;
- _logManager = logManager;
-
- // For now there's no real way to inject these properly
- BaseItem.Logger = logManager.GetLogger("BaseItem");
- User.XmlSerializer = _xmlSerializer;
- Ratings.ConfigurationManager = _configurationManager;
- LocalizedStrings.ApplicationPaths = _configurationManager.ApplicationPaths;
- BaseItem.ConfigurationManager = configurationManager;
- }
-
- ///
- /// Composes the parts with ioc container.
- ///
- protected void FindParts()
- {
- // For now there's no real way to inject these properly
- BaseItem.LibraryManager = ApplicationHost.Resolve();
- User.UserManager = ApplicationHost.Resolve();
-
- FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager));
- ImageManager = (ImageManager)ApplicationHost.CreateInstance(typeof(ImageManager));
- ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager));
-
- UserDataRepositories = ApplicationHost.GetExports();
- UserRepositories = ApplicationHost.GetExports();
- DisplayPreferencesRepositories = ApplicationHost.GetExports();
- ItemRepositories = ApplicationHost.GetExports();
- WeatherProviders = ApplicationHost.GetExports();
- ImageEnhancers = ApplicationHost.GetExports().OrderBy(e => e.Priority).ToArray();
- StringFiles = ApplicationHost.GetExports();
- MetadataProviders = ApplicationHost.GetExports().OrderBy(e => e.Priority).ToArray();
- }
-
- ///
- /// Performs initializations that can be reloaded at anytime
- ///
- /// Task.
- public async Task Init()
- {
- FindParts();
-
- await LoadRepositories().ConfigureAwait(false);
-
- await ApplicationHost.Resolve().RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
-
- foreach (var entryPoint in ApplicationHost.GetExports())
- {
- entryPoint.Run();
- }
-
- ReloadFileSystemManager();
- }
-
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases unmanaged and - optionally - managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected virtual void Dispose(bool dispose)
- {
- if (dispose)
- {
- DisposeFileSystemManager();
- }
}
///
/// Called when [composable parts loaded].
///
/// Task.
- protected Task LoadRepositories()
+ public Task LoadRepositories(IServerConfigurationManager configurationManager)
{
// Get the current item repository
- ItemRepository = GetRepository(ItemRepositories, _configurationManager.Configuration.ItemRepository);
+ ItemRepository = GetRepository(ItemRepositories, configurationManager.Configuration.ItemRepository);
var itemRepoTask = ItemRepository.Initialize();
// Get the current user repository
- UserRepository = GetRepository(UserRepositories, _configurationManager.Configuration.UserRepository);
+ UserRepository = GetRepository(UserRepositories, configurationManager.Configuration.UserRepository);
var userRepoTask = UserRepository.Initialize();
// Get the current item repository
- UserDataRepository = GetRepository(UserDataRepositories, _configurationManager.Configuration.UserDataRepository);
+ UserDataRepository = GetRepository(UserDataRepositories, configurationManager.Configuration.UserDataRepository);
var userDataRepoTask = UserDataRepository.Initialize();
// Get the current display preferences repository
- DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, _configurationManager.Configuration.DisplayPreferencesRepository);
+ DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, configurationManager.Configuration.DisplayPreferencesRepository);
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
@@ -295,28 +186,5 @@ namespace MediaBrowser.Controller
return enumerable.FirstOrDefault(r => string.Equals(r.Name, name, StringComparison.OrdinalIgnoreCase)) ??
enumerable.FirstOrDefault();
}
-
- ///
- /// Disposes the file system manager.
- ///
- private void DisposeFileSystemManager()
- {
- if (FileSystemManager != null)
- {
- FileSystemManager.Dispose();
- FileSystemManager = null;
- }
- }
-
- ///
- /// Reloads the file system manager.
- ///
- private void ReloadFileSystemManager()
- {
- DisposeFileSystemManager();
-
- FileSystemManager = new FileSystemManager(_logManager, ApplicationHost.Resolve(), ApplicationHost.Resolve(), _configurationManager);
- FileSystemManager.StartWatchers();
- }
}
}
diff --git a/MediaBrowser.Controller/Localization/LocalizedStrings.cs b/MediaBrowser.Controller/Localization/LocalizedStrings.cs
index c7f4755b73..ea065b17af 100644
--- a/MediaBrowser.Controller/Localization/LocalizedStrings.cs
+++ b/MediaBrowser.Controller/Localization/LocalizedStrings.cs
@@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Localization
///
public class LocalizedStrings
{
- internal static IServerApplicationPaths ApplicationPaths;
+ public static IServerApplicationPaths ApplicationPaths;
///
/// The base prefix
diff --git a/MediaBrowser.Controller/Localization/Ratings.cs b/MediaBrowser.Controller/Localization/Ratings.cs
index bee7b6e557..a8fbdbc808 100644
--- a/MediaBrowser.Controller/Localization/Ratings.cs
+++ b/MediaBrowser.Controller/Localization/Ratings.cs
@@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Localization
///
public static class Ratings
{
- internal static IServerConfigurationManager ConfigurationManager;
+ public static IServerConfigurationManager ConfigurationManager;
///
/// The ratings def
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index c07713d7df..5ae6cccac5 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -102,12 +102,14 @@
-
+
+
+
@@ -154,7 +156,6 @@
-
@@ -176,7 +177,6 @@
-
diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
index a5823c60e2..aaf3fe6bfb 100644
--- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
+++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Logging;
@@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Providers
///
/// Class BaseMetadataProvider
///
- public abstract class BaseMetadataProvider : IDisposable
+ public abstract class BaseMetadataProvider
{
///
/// Gets the logger.
@@ -27,16 +26,6 @@ namespace MediaBrowser.Controller.Providers
/// The configuration manager.
protected IServerConfigurationManager ConfigurationManager { get; private set; }
- // Cache these since they will be used a lot
- ///
- /// The false task result
- ///
- protected static readonly Task FalseTaskResult = Task.FromResult(false);
- ///
- /// The true task result
- ///
- protected static readonly Task TrueTaskResult = Task.FromResult(true);
-
///
/// The _id
///
@@ -135,7 +124,7 @@ namespace MediaBrowser.Controller.Providers
/// The provider version.
/// The status.
/// item
- protected virtual void SetLastRefreshed(BaseItem item, DateTime value, string providerVersion, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
+ public virtual void SetLastRefreshed(BaseItem item, DateTime value, string providerVersion, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
{
if (item == null)
{
@@ -162,7 +151,7 @@ namespace MediaBrowser.Controller.Providers
/// The item.
/// The value.
/// The status.
- protected virtual void SetLastRefreshed(BaseItem item, DateTime value, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
+ public void SetLastRefreshed(BaseItem item, DateTime value, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
{
SetLastRefreshed(item, value, ProviderVersion, status);
}
@@ -254,76 +243,7 @@ namespace MediaBrowser.Controller.Providers
/// The cancellation token.
/// Task{System.Boolean}.
///
- public async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
- {
- if (item == null)
- {
- throw new ArgumentNullException();
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- Logger.Info("Running for {0}", item.Path ?? item.Name ?? "--Unknown--");
-
- // This provides the ability to cancel just this one provider
- var innerCancellationTokenSource = new CancellationTokenSource();
-
- Kernel.Instance.ProviderManager.OnProviderRefreshBeginning(this, item, innerCancellationTokenSource);
-
- try
- {
- var task = FetchAsyncInternal(item, force, CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, innerCancellationTokenSource.Token).Token);
-
- await task.ConfigureAwait(false);
-
- if (task.IsFaulted)
- {
- // Log the AggregateException
- if (task.Exception != null)
- {
- Logger.ErrorException("AggregateException:", task.Exception);
- }
-
- return false;
- }
-
- return task.Result;
- }
- catch (OperationCanceledException ex)
- {
- Logger.Info("{0} cancelled for {1}", GetType().Name, item.Name);
-
- // If the outer cancellation token is the one that caused the cancellation, throw it
- if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken)
- {
- throw;
- }
-
- return false;
- }
- catch (Exception ex)
- {
- Logger.ErrorException("failed refreshing {0}", ex, item.Name);
-
- SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.Failure);
- return true;
- }
- finally
- {
- innerCancellationTokenSource.Dispose();
-
- Kernel.Instance.ProviderManager.OnProviderRefreshCompleted(this, item);
- }
- }
-
- ///
- /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
- ///
- /// The item.
- /// if set to true [force].
- /// The cancellation token.
- /// Task{System.Boolean}.
- protected abstract Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken);
+ public abstract Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken);
///
/// Gets the priority.
@@ -331,23 +251,6 @@ namespace MediaBrowser.Controller.Providers
/// The priority.
public abstract MetadataProviderPriority Priority { get; }
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases unmanaged and - optionally - managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected virtual void Dispose(bool dispose)
- {
- }
-
///
/// Returns true or false indicating if the provider should refresh when the contents of it's directory changes
///
@@ -386,34 +289,4 @@ namespace MediaBrowser.Controller.Providers
return item.FileSystemStamp;
}
}
-
- ///
- /// Determines when a provider should execute, relative to others
- ///
- public enum MetadataProviderPriority
- {
- // Run this provider at the beginning
- ///
- /// The first
- ///
- First = 1,
-
- // Run this provider after all first priority providers
- ///
- /// The second
- ///
- Second = 2,
-
- // Run this provider after all second priority providers
- ///
- /// The third
- ///
- Third = 3,
-
- // Run this provider last
- ///
- /// The last
- ///
- Last = 4
- }
}
diff --git a/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs b/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs
index 45a47a58da..d2c2d5b15d 100644
--- a/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs
+++ b/MediaBrowser.Controller/Providers/FolderProviderFromXml.cs
@@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Providers
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() => Fetch(item, cancellationToken));
}
diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs
new file mode 100644
index 0000000000..902ed21bcd
--- /dev/null
+++ b/MediaBrowser.Controller/Providers/IProviderManager.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using MediaBrowser.Controller.Entities;
+using System;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Providers
+{
+ public interface IProviderManager : IDisposable
+ {
+ ///
+ /// Downloads the and save image.
+ ///
+ /// The item.
+ /// The source.
+ /// Name of the target.
+ /// The resource pool.
+ /// The cancellation token.
+ /// Task{System.String}.
+ /// item
+ Task DownloadAndSaveImage(BaseItem item, string source, string targetName, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
+
+ ///
+ /// Saves to library filesystem.
+ ///
+ /// The item.
+ /// The path.
+ /// The data to save.
+ /// The cancellation token.
+ /// Task.
+ ///
+ Task SaveToLibraryFilesystem(BaseItem item, string path, Stream dataToSave, CancellationToken cancellationToken);
+
+ ///
+ /// Executes the metadata providers.
+ ///
+ /// The item.
+ /// The cancellation token.
+ /// if set to true [force].
+ /// if set to true [allow slow providers].
+ /// Task{System.Boolean}.
+ Task ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true);
+
+ ///
+ /// Adds the metadata providers.
+ ///
+ /// The providers.
+ void AddMetadataProviders(IEnumerable providers);
+ }
+}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs
index 4b337aadce..70de387431 100644
--- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs
+++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs
@@ -52,6 +52,11 @@ namespace MediaBrowser.Controller.Providers
}
}
+ ///
+ /// The true task result
+ ///
+ protected static readonly Task TrueTaskResult = Task.FromResult(true);
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -59,7 +64,7 @@ namespace MediaBrowser.Controller.Providers
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
index 9fe2a6c01f..253d4dfed1 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// Provides a base class for extracting media information through ffprobe
///
///
- public abstract class BaseFFProbeProvider : BaseFFMpegProvider
+ public abstract class BaseFFProbeProvider : BaseFFMpegProvider, IDisposable
where T : BaseItem
{
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
@@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
var myItem = (T)item;
@@ -351,14 +351,17 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// Releases unmanaged and - optionally - managed resources.
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool dispose)
+ protected virtual void Dispose(bool dispose)
{
if (dispose)
{
FFProbeCache.Dispose();
}
+ }
- base.Dispose(dispose);
+ public void Dispose()
+ {
+ Dispose(true);
}
}
}
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs
index aedd035377..e752a863d4 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs
@@ -19,6 +19,11 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
}
+ ///
+ /// The true task result
+ ///
+ protected static readonly Task TrueTaskResult = Task.FromResult(true);
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -26,7 +31,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
var audio = (Audio)item;
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs
index a44acb8f66..5a8157ebf8 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs
@@ -59,6 +59,11 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
return false;
}
+ ///
+ /// The true task result
+ ///
+ protected static readonly Task TrueTaskResult = Task.FromResult(true);
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -66,7 +71,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(item.PrimaryImagePath))
{
diff --git a/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs b/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs
new file mode 100644
index 0000000000..9ddc0a33fa
--- /dev/null
+++ b/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs
@@ -0,0 +1,33 @@
+
+namespace MediaBrowser.Controller.Providers
+{
+ ///
+ /// Determines when a provider should execute, relative to others
+ ///
+ public enum MetadataProviderPriority
+ {
+ // Run this provider at the beginning
+ ///
+ /// The first
+ ///
+ First = 1,
+
+ // Run this provider after all first priority providers
+ ///
+ /// The second
+ ///
+ Second = 2,
+
+ // Run this provider after all second priority providers
+ ///
+ /// The third
+ ///
+ Third = 3,
+
+ // Run this provider last
+ ///
+ /// The last
+ ///
+ Last = 4
+ }
+}
diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
index 9c71642e99..af613f0233 100644
--- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// Class FanArtMovieProvider
///
- class FanArtMovieProvider : FanartBaseProvider
+ class FanArtMovieProvider : FanartBaseProvider, IDisposable
{
///
/// The fan art
@@ -32,6 +32,8 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The HTTP client.
protected IHttpClient HttpClient { get; private set; }
+ private readonly IProviderManager _providerManager;
+
///
/// Initializes a new instance of the class.
///
@@ -39,7 +41,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The log manager.
/// The configuration manager.
/// httpClient
- public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (httpClient == null)
@@ -47,19 +49,19 @@ namespace MediaBrowser.Controller.Providers.Movies
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
+ _providerManager = providerManager;
}
///
/// Releases unmanaged and - optionally - managed resources.
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool dispose)
+ protected virtual void Dispose(bool dispose)
{
if (dispose)
{
FanArtResourcePool.Dispose();
}
- base.Dispose(dispose);
}
///
@@ -103,7 +105,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -147,7 +149,7 @@ namespace MediaBrowser.Controller.Providers.Movies
Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
try
{
- movie.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -173,7 +175,7 @@ namespace MediaBrowser.Controller.Providers.Movies
Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
try
{
- movie.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -196,7 +198,7 @@ namespace MediaBrowser.Controller.Providers.Movies
Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
try
{
- movie.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, DISC_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -220,7 +222,7 @@ namespace MediaBrowser.Controller.Providers.Movies
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
try
{
- movie.SetImage(ImageType.Banner, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -244,7 +246,7 @@ namespace MediaBrowser.Controller.Providers.Movies
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
try
{
- movie.SetImage(ImageType.Thumb, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, THUMB_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -260,5 +262,10 @@ namespace MediaBrowser.Controller.Providers.Movies
SetLastRefreshed(movie, DateTime.UtcNow);
return true;
}
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
index 8d004a5744..3eea0979ce 100644
--- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
@@ -30,8 +30,10 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// Class MovieDbProvider
///
- public class MovieDbProvider : BaseMetadataProvider
+ public class MovieDbProvider : BaseMetadataProvider, IDisposable
{
+ protected readonly IProviderManager ProviderManager;
+
///
/// The movie db
///
@@ -58,11 +60,12 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The configuration manager.
/// The json serializer.
/// The HTTP client.
- public MovieDbProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public MovieDbProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient, IProviderManager providerManager)
: base(logManager, configurationManager)
{
JsonSerializer = jsonSerializer;
HttpClient = httpClient;
+ ProviderManager = providerManager;
Current = this;
}
@@ -70,13 +73,12 @@ namespace MediaBrowser.Controller.Providers.Movies
/// Releases unmanaged and - optionally - managed resources.
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool dispose)
+ protected virtual void Dispose(bool dispose)
{
if (dispose)
{
MovieDbResourcePool.Dispose();
}
- base.Dispose(dispose);
}
///
@@ -209,16 +211,17 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// The item.
/// The value.
+ /// The provider version.
/// The status.
- protected override void SetLastRefreshed(BaseItem item, DateTime value, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
+ public override void SetLastRefreshed(BaseItem item, DateTime value, string providerVersion, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
{
- base.SetLastRefreshed(item, value, status);
+ base.SetLastRefreshed(item, value, providerVersion, status);
if (ConfigurationManager.Configuration.SaveLocalMeta)
{
//in addition to ours, we need to set the last refreshed time for the local data provider
//so it won't see the new files we download and process them all over again
- if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(LogManager, ConfigurationManager, JsonSerializer, HttpClient);
+ if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(LogManager, ConfigurationManager, JsonSerializer, HttpClient, ProviderManager);
var data = item.ProviderData.GetValueOrDefault(JsonProvider.Id, new BaseProviderInfo { ProviderId = JsonProvider.Id });
data.LastRefreshed = value;
item.ProviderData[JsonProvider.Id] = data;
@@ -291,7 +294,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
if (HasAltMeta(item))
{
@@ -724,7 +727,7 @@ namespace MediaBrowser.Controller.Providers.Movies
cancellationToken.ThrowIfCancellationRequested();
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
+ await ProviderManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
}
}
@@ -1018,7 +1021,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
try
{
- item.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false);
+ item.PrimaryImagePath = await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false);
}
catch (HttpException)
{
@@ -1050,7 +1053,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
try
{
- item.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false));
+ item.BackdropImagePaths.Add(await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -1661,5 +1664,10 @@ namespace MediaBrowser.Controller.Providers.Movies
public TmdbImageSettings images { get; set; }
}
#endregion
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs
index 2a7a09625f..b81e0c51d1 100644
--- a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs
+++ b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs
@@ -15,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
///
public class MovieProviderFromJson : MovieDbProvider
{
- public MovieProviderFromJson(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient) :
- base(logManager, configurationManager, jsonSerializer, httpClient)
+ public MovieProviderFromJson(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient, IProviderManager providerManager)
+ : base(logManager, configurationManager, jsonSerializer, httpClient, providerManager)
{
}
@@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
// Since we don't have anything truly async, and since deserializing can be expensive, create a task to force parallelism
return Task.Run(() =>
diff --git a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromXml.cs b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromXml.cs
index 3e5a6fe8d7..2795336368 100644
--- a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromXml.cs
+++ b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromXml.cs
@@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() => Fetch(item, cancellationToken));
}
diff --git a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs
index 278d672617..e89f1a0443 100644
--- a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs
+++ b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs
@@ -15,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
///
class PersonProviderFromJson : TmdbPersonProvider
{
- public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager) :
- base(httpClient, jsonSerializer, logManager, configurationManager)
+ public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
+ : base(httpClient, jsonSerializer, logManager, configurationManager, providerManager)
{
}
@@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() =>
{
diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
index 5c977a928c..f721a04eb5 100644
--- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
@@ -26,7 +26,9 @@ namespace MediaBrowser.Controller.Providers.Movies
///
protected const string MetaFileName = "MBPerson.json";
- public TmdbPersonProvider(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
+ protected readonly IProviderManager ProviderManager;
+
+ public TmdbPersonProvider(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (jsonSerializer == null)
@@ -39,6 +41,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
HttpClient = httpClient;
JsonSerializer = jsonSerializer;
+ ProviderManager = providerManager;
}
///
@@ -83,7 +86,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -209,7 +212,7 @@ namespace MediaBrowser.Controller.Providers.Movies
JsonSerializer.SerializeToStream(searchResult, memoryStream);
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(person, Path.Combine(person.MetaLocation, MetaFileName), memoryStream, cancellationToken);
+ await ProviderManager.SaveToLibraryFilesystem(person, Path.Combine(person.MetaLocation, MetaFileName), memoryStream, cancellationToken);
Logger.Debug("TmdbPersonProvider downloaded and saved information for {0}", person.Name);
}
@@ -288,7 +291,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
if (profile != null)
{
- var tmdbSettings = await Kernel.Instance.MetadataProviders.OfType().First().TmdbSettings.ConfigureAwait(false);
+ var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.File_Path,
"folder" + Path.GetExtension(profile.File_Path), cancellationToken).ConfigureAwait(false);
@@ -319,7 +322,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
using (var sourceStream = await HttpClient.GetMemoryStream(source, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
{
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(item, localPath, sourceStream, cancellationToken).ConfigureAwait(false);
+ await ProviderManager.SaveToLibraryFilesystem(item, localPath, sourceStream, cancellationToken).ConfigureAwait(false);
Logger.Debug("TmdbPersonProvider downloaded and saved image for {0}", item.Name);
}
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
index 2d7284c80e..331bd00dab 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
@@ -15,8 +15,12 @@ namespace MediaBrowser.Controller.Providers.Music
{
public class FanArtAlbumProvider : FanartBaseProvider
{
- public FanArtAlbumProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
+ private readonly IProviderManager _providerManager;
+
+ public FanArtAlbumProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
+ : base(logManager, configurationManager)
{
+ _providerManager = providerManager;
}
public override bool Supports(BaseItem item)
@@ -37,7 +41,7 @@ namespace MediaBrowser.Controller.Providers.Music
DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
}
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
var mbid = item.GetProviderId(MetadataProviders.Musicbrainz);
if (mbid == null)
@@ -67,7 +71,7 @@ namespace MediaBrowser.Controller.Providers.Music
return false;
}
- item.SetImage(ImageType.Primary, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, cover, "folder.jpg", FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, cover, "folder.jpg", FanArtResourcePool, cancellationToken).ConfigureAwait(false));
return true;
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
index 3834bff912..4846c8fdc3 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
@@ -28,7 +28,9 @@ namespace MediaBrowser.Controller.Providers.Music
/// The HTTP client.
protected IHttpClient HttpClient { get; private set; }
- public FanArtArtistProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ private readonly IProviderManager _providerManager;
+
+ public FanArtArtistProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (httpClient == null)
@@ -36,6 +38,7 @@ namespace MediaBrowser.Controller.Providers.Music
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
+ _providerManager = providerManager;
}
///
@@ -80,7 +83,7 @@ namespace MediaBrowser.Controller.Providers.Music
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -118,7 +121,7 @@ namespace MediaBrowser.Controller.Providers.Music
Logger.Debug("FanArtProvider getting ClearLogo for " + artist.Name);
try
{
- artist.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(artist, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ artist.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(artist, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -146,7 +149,7 @@ namespace MediaBrowser.Controller.Providers.Music
Logger.Debug("FanArtProvider getting Backdrop for " + artist.Name);
try
{
- artist.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(artist, path, ("Backdrop"+(numBackdrops > 0 ? numBackdrops.ToString() : "")+".jpg"), FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ artist.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(artist, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString() : "") + ".jpg"), FanArtResourcePool, cancellationToken).ConfigureAwait(false));
numBackdrops++;
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
}
@@ -203,7 +206,7 @@ namespace MediaBrowser.Controller.Providers.Music
Logger.Debug("FanArtProvider getting ClearArt for " + artist.Name);
try
{
- artist.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(artist, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ artist.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(artist, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -226,7 +229,7 @@ namespace MediaBrowser.Controller.Providers.Music
Logger.Debug("FanArtProvider getting Banner for " + artist.Name);
try
{
- artist.SetImage(ImageType.Banner, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(artist, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ artist.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(artist, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -250,7 +253,7 @@ namespace MediaBrowser.Controller.Providers.Music
Logger.Debug("FanArtProvider getting Primary image for " + artist.Name);
try
{
- artist.SetImage(ImageType.Primary, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(artist, path, PRIMARY_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ artist.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(artist, path, PRIMARY_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
index 70de42f4d4..7f2952c663 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs
@@ -16,9 +16,12 @@ namespace MediaBrowser.Controller.Providers.Music
{
private static readonly Task BlankId = Task.FromResult("0000");
- public LastfmAlbumProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ private readonly IProviderManager _providerManager;
+
+ public LastfmAlbumProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(jsonSerializer, httpClient, logManager, configurationManager)
{
+ _providerManager = providerManager;
LocalMetaFileName = LastfmHelper.LocalAlbumMetaFileName;
}
@@ -62,7 +65,7 @@ namespace MediaBrowser.Controller.Providers.Music
cancellationToken.ThrowIfCancellationRequested();
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
+ await _providerManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
index 29cb35cdc9..016650071a 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
@@ -19,10 +19,12 @@ namespace MediaBrowser.Controller.Providers.Music
{
public class LastfmArtistProvider : LastfmBaseProvider
{
-
- public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ private readonly IProviderManager _providerManager;
+
+ public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(jsonSerializer, httpClient, logManager, configurationManager)
{
+ _providerManager = providerManager;
LocalMetaFileName = LastfmHelper.LocalArtistMetaFileName;
}
@@ -91,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.Music
cancellationToken.ThrowIfCancellationRequested();
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
+ await _providerManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
index d8b4c387f5..26817a41ca 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
@@ -196,7 +196,7 @@ namespace MediaBrowser.Controller.Providers.Music
/// if set to true [force].
/// The cancellation token
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
if (item.DontFetchMeta)
{
diff --git a/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs b/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs
index fab4684927..8b9b07bce8 100644
--- a/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs
+++ b/MediaBrowser.Controller/Providers/Music/MusicArtistProviderFromJson.cs
@@ -34,7 +34,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() =>
{
diff --git a/MediaBrowser.Controller/Providers/SortNameProvider.cs b/MediaBrowser.Controller/Providers/SortNameProvider.cs
index 2214d8a080..c36bcb6561 100644
--- a/MediaBrowser.Controller/Providers/SortNameProvider.cs
+++ b/MediaBrowser.Controller/Providers/SortNameProvider.cs
@@ -49,6 +49,17 @@ namespace MediaBrowser.Controller.Providers
return !string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.SortName);
}
+ // Cache these since they will be used a lot
+ ///
+ /// The false task result
+ ///
+ protected static readonly Task FalseTaskResult = Task.FromResult(false);
+
+ ///
+ /// The true task result
+ ///
+ protected static readonly Task TrueTaskResult = Task.FromResult(true);
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -56,7 +67,7 @@ namespace MediaBrowser.Controller.Providers
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return SetSortName(item, cancellationToken) ? TrueTaskResult : FalseTaskResult;
}
diff --git a/MediaBrowser.Controller/Providers/TV/EpisodeImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/TV/EpisodeImageFromMediaLocationProvider.cs
index e4ef738925..ac22b43bf7 100644
--- a/MediaBrowser.Controller/Providers/TV/EpisodeImageFromMediaLocationProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/EpisodeImageFromMediaLocationProvider.cs
@@ -50,6 +50,11 @@ namespace MediaBrowser.Controller.Providers.TV
}
}
+ ///
+ /// The true task result
+ ///
+ protected static readonly Task TrueTaskResult = Task.FromResult(true);
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -57,7 +62,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Controller/Providers/TV/EpisodeProviderFromXml.cs b/MediaBrowser.Controller/Providers/TV/EpisodeProviderFromXml.cs
index 1913397d47..483d1ddce4 100644
--- a/MediaBrowser.Controller/Providers/TV/EpisodeProviderFromXml.cs
+++ b/MediaBrowser.Controller/Providers/TV/EpisodeProviderFromXml.cs
@@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() => Fetch(item, cancellationToken));
}
diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
index 5dcead7b1a..5690ba47f5 100644
--- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
@@ -25,7 +25,9 @@ namespace MediaBrowser.Controller.Providers.TV
/// The HTTP client.
protected IHttpClient HttpClient { get; private set; }
- public FanArtTvProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ private readonly IProviderManager _providerManager;
+
+ public FanArtTvProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (httpClient == null)
@@ -33,6 +35,7 @@ namespace MediaBrowser.Controller.Providers.TV
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
+ _providerManager = providerManager;
}
public override bool Supports(BaseItem item)
@@ -53,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.TV
|| (!thumbExists && ConfigurationManager.Configuration.DownloadSeriesImages.Thumb);
}
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -90,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.TV
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
try
{
- series.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, LOGO_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -114,7 +117,7 @@ namespace MediaBrowser.Controller.Providers.TV
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
try
{
- series.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, ART_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -138,7 +141,7 @@ namespace MediaBrowser.Controller.Providers.TV
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
try
{
- series.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, THUMB_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
index eee43016c6..46bb21c48a 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
@@ -22,6 +22,8 @@ namespace MediaBrowser.Controller.Providers.TV
///
class RemoteEpisodeProvider : BaseMetadataProvider
{
+ private readonly IProviderManager _providerManager;
+
///
/// Gets the HTTP client.
///
@@ -34,10 +36,11 @@ namespace MediaBrowser.Controller.Providers.TV
/// The HTTP client.
/// The log manager.
/// The configuration manager.
- public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
HttpClient = httpClient;
+ _providerManager = providerManager;
}
///
@@ -117,7 +120,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// The item.
/// if set to true [force].
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -229,7 +232,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
- episode.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken);
+ episode.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken);
}
catch (HttpException)
{
@@ -282,7 +285,7 @@ namespace MediaBrowser.Controller.Providers.TV
var ms = new MemoryStream();
doc.Save(ms);
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(episode, Path.Combine(episode.MetaLocation, Path.GetFileNameWithoutExtension(episode.Path) + ".xml"), ms, cancellationToken).ConfigureAwait(false);
+ await _providerManager.SaveToLibraryFilesystem(episode, Path.Combine(episode.MetaLocation, Path.GetFileNameWithoutExtension(episode.Path) + ".xml"), ms, cancellationToken).ConfigureAwait(false);
}
return true;
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
index 03d7d3353d..f39e91834f 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
@@ -25,8 +25,10 @@ namespace MediaBrowser.Controller.Providers.TV
///
/// The HTTP client.
protected IHttpClient HttpClient { get; private set; }
+
+ private readonly IProviderManager _providerManager;
- public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (httpClient == null)
@@ -34,6 +36,7 @@ namespace MediaBrowser.Controller.Providers.TV
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
+ _providerManager = providerManager;
}
///
@@ -97,7 +100,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -174,7 +177,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
if (n != null)
- season.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false);
+ season.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false);
}
catch (HttpException)
{
@@ -197,8 +200,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
var bannerImagePath =
- await
- Kernel.Instance.ProviderManager.DownloadAndSaveImage(season,
+ await _providerManager.DownloadAndSaveImage(season,
TVUtils.BannerUrl + n.InnerText,
"banner" +
Path.GetExtension(n.InnerText),
@@ -229,7 +231,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List();
- season.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false));
+ season.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -257,8 +259,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
season.BackdropImagePaths.Add(
- await
- Kernel.Instance.ProviderManager.DownloadAndSaveImage(season,
+ await _providerManager.DownloadAndSaveImage(season,
TVUtils.BannerUrl +
n.InnerText,
"backdrop" +
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
index efb158b1e9..ddc4e7fca2 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
@@ -22,8 +22,10 @@ namespace MediaBrowser.Controller.Providers.TV
///
/// Class RemoteSeriesProvider
///
- class RemoteSeriesProvider : BaseMetadataProvider
+ class RemoteSeriesProvider : BaseMetadataProvider, IDisposable
{
+ private readonly IProviderManager _providerManager;
+
///
/// The tv db
///
@@ -44,7 +46,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// The log manager.
/// The configuration manager.
/// httpClient
- public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
+ public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
if (httpClient == null)
@@ -52,6 +54,7 @@ namespace MediaBrowser.Controller.Providers.TV
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
+ _providerManager = providerManager;
Current = this;
}
@@ -59,13 +62,12 @@ namespace MediaBrowser.Controller.Providers.TV
/// Releases unmanaged and - optionally - managed resources.
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void Dispose(bool dispose)
+ protected virtual void Dispose(bool dispose)
{
if (dispose)
{
TvDbResourcePool.Dispose();
}
- base.Dispose(dispose);
}
///
@@ -149,7 +151,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -252,8 +254,8 @@ namespace MediaBrowser.Controller.Providers.TV
{
var ms = new MemoryStream();
doc.Save(ms);
-
- await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(series, Path.Combine(series.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
+
+ await _providerManager.SaveToLibraryFilesystem(series, Path.Combine(series.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
}
}
}
@@ -366,7 +368,7 @@ namespace MediaBrowser.Controller.Providers.TV
{
try
{
- series.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false);
+ series.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false);
}
catch (HttpException)
{
@@ -389,7 +391,7 @@ namespace MediaBrowser.Controller.Providers.TV
{
try
{
- var bannerImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken);
+ var bannerImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken);
series.SetImage(ImageType.Banner, bannerImagePath);
}
@@ -418,7 +420,7 @@ namespace MediaBrowser.Controller.Providers.TV
{
try
{
- series.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false));
+ series.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false));
}
catch (HttpException)
{
@@ -584,7 +586,9 @@ namespace MediaBrowser.Controller.Providers.TV
return name.Trim();
}
-
-
+ public void Dispose()
+ {
+ Dispose(true);
+ }
}
}
diff --git a/MediaBrowser.Controller/Providers/TV/SeriesProviderFromXml.cs b/MediaBrowser.Controller/Providers/TV/SeriesProviderFromXml.cs
index f9d409c184..8e42e9d550 100644
--- a/MediaBrowser.Controller/Providers/TV/SeriesProviderFromXml.cs
+++ b/MediaBrowser.Controller/Providers/TV/SeriesProviderFromXml.cs
@@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// if set to true [force].
/// The cancellation token.
/// Task{System.Boolean}.
- protected override Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
+ public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
return Task.Run(() => Fetch(item, cancellationToken));
}
diff --git a/MediaBrowser.Controller/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs
similarity index 87%
rename from MediaBrowser.Controller/IO/DirectoryWatchers.cs
rename to MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs
index 5789c0240a..c1371a32b0 100644
--- a/MediaBrowser.Controller/IO/DirectoryWatchers.cs
+++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs
@@ -1,6 +1,7 @@
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.ScheduledTasks;
using MediaBrowser.Model.Logging;
@@ -12,35 +13,35 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-namespace MediaBrowser.Controller.IO
+namespace MediaBrowser.Server.Implementations.IO
{
///
/// Class DirectoryWatchers
///
- public class DirectoryWatchers : IDisposable
+ public class DirectoryWatchers : IDirectoryWatchers
{
///
/// The file system watchers
///
- private ConcurrentBag FileSystemWatchers = new ConcurrentBag();
+ private ConcurrentBag _fileSystemWatchers = new ConcurrentBag();
///
/// The update timer
///
- private Timer updateTimer;
+ private Timer _updateTimer;
///
/// The affected paths
///
- private readonly ConcurrentDictionary affectedPaths = new ConcurrentDictionary();
+ private readonly ConcurrentDictionary _affectedPaths = new ConcurrentDictionary();
///
/// A dynamic list of paths that should be ignored. Added to during our own file sytem modifications.
///
- private readonly ConcurrentDictionary TempIgnoredPaths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
+ private readonly ConcurrentDictionary _tempIgnoredPaths = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
///
/// The timer lock
///
- private readonly object timerLock = new object();
+ private readonly object _timerLock = new object();
///
/// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
@@ -48,7 +49,7 @@ namespace MediaBrowser.Controller.IO
/// The path.
public void TemporarilyIgnore(string path)
{
- TempIgnoredPaths[path] = path;
+ _tempIgnoredPaths[path] = path;
}
///
@@ -58,7 +59,7 @@ namespace MediaBrowser.Controller.IO
public void RemoveTempIgnore(string path)
{
string val;
- TempIgnoredPaths.TryRemove(path, out val);
+ _tempIgnoredPaths.TryRemove(path, out val);
}
///
@@ -95,7 +96,7 @@ namespace MediaBrowser.Controller.IO
///
/// Starts this instance.
///
- internal void Start()
+ public void Start()
{
LibraryManager.LibraryChanged += Instance_LibraryChanged;
@@ -178,7 +179,7 @@ namespace MediaBrowser.Controller.IO
try
{
newWatcher.EnableRaisingEvents = true;
- FileSystemWatchers.Add(newWatcher);
+ _fileSystemWatchers.Add(newWatcher);
Logger.Info("Watching directory " + path);
}
@@ -199,7 +200,7 @@ namespace MediaBrowser.Controller.IO
/// The path.
private void StopWatchingPath(string path)
{
- var watcher = FileSystemWatchers.FirstOrDefault(f => f.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+ var watcher = _fileSystemWatchers.FirstOrDefault(f => f.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
if (watcher != null)
{
@@ -218,18 +219,18 @@ namespace MediaBrowser.Controller.IO
watcher.EnableRaisingEvents = false;
watcher.Dispose();
- var watchers = FileSystemWatchers.ToList();
+ var watchers = _fileSystemWatchers.ToList();
watchers.Remove(watcher);
- FileSystemWatchers = new ConcurrentBag(watchers);
+ _fileSystemWatchers = new ConcurrentBag(watchers);
}
///
/// Handles the LibraryChanged event of the Kernel
///
/// The source of the event.
- /// The instance containing the event data.
+ /// The instance containing the event data.
void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e)
{
if (e.Folder is AggregateFolder && e.HasAddOrRemoveChange)
@@ -316,7 +317,7 @@ namespace MediaBrowser.Controller.IO
{
return;
}
- if (TempIgnoredPaths.ContainsKey(e.FullPath))
+ if (_tempIgnoredPaths.ContainsKey(e.FullPath))
{
Logger.Info("Watcher requested to ignore change to " + e.FullPath);
return;
@@ -327,17 +328,17 @@ namespace MediaBrowser.Controller.IO
//Since we're watching created, deleted and renamed we always want the parent of the item to be the affected path
var affectedPath = e.FullPath;
- affectedPaths.AddOrUpdate(affectedPath, affectedPath, (key, oldValue) => affectedPath);
+ _affectedPaths.AddOrUpdate(affectedPath, affectedPath, (key, oldValue) => affectedPath);
- lock (timerLock)
+ lock (_timerLock)
{
- if (updateTimer == null)
+ if (_updateTimer == null)
{
- updateTimer = new Timer(TimerStopped, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
+ _updateTimer = new Timer(TimerStopped, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
}
else
{
- updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
+ _updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
}
}
}
@@ -348,24 +349,24 @@ namespace MediaBrowser.Controller.IO
/// The state info.
private async void TimerStopped(object stateInfo)
{
- lock (timerLock)
+ lock (_timerLock)
{
// Extend the timer as long as any of the paths are still being written to.
- if (affectedPaths.Any(p => IsFileLocked(p.Key)))
+ if (_affectedPaths.Any(p => IsFileLocked(p.Key)))
{
Logger.Info("Timer extended.");
- updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
+ _updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
return;
}
Logger.Info("Timer stopped.");
- updateTimer.Dispose();
- updateTimer = null;
+ _updateTimer.Dispose();
+ _updateTimer = null;
}
- var paths = affectedPaths.Keys.ToList();
- affectedPaths.Clear();
+ var paths = _affectedPaths.Keys.ToList();
+ _affectedPaths.Clear();
await ProcessPathChanges(paths).ConfigureAwait(false);
}
@@ -493,29 +494,29 @@ namespace MediaBrowser.Controller.IO
///
/// Stops this instance.
///
- private void Stop()
+ public void Stop()
{
LibraryManager.LibraryChanged -= Instance_LibraryChanged;
FileSystemWatcher watcher;
- while (FileSystemWatchers.TryTake(out watcher))
+ while (_fileSystemWatchers.TryTake(out watcher))
{
watcher.Changed -= watcher_Changed;
watcher.EnableRaisingEvents = false;
watcher.Dispose();
}
- lock (timerLock)
+ lock (_timerLock)
{
- if (updateTimer != null)
+ if (_updateTimer != null)
{
- updateTimer.Dispose();
- updateTimer = null;
+ _updateTimer.Dispose();
+ _updateTimer = null;
}
}
- affectedPaths.Clear();
+ _affectedPaths.Clear();
}
///
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index e56c79dedd..7810886723 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -111,6 +111,7 @@
+
@@ -128,6 +129,7 @@
+
diff --git a/MediaBrowser.Controller/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
similarity index 65%
rename from MediaBrowser.Controller/Providers/ProviderManager.cs
rename to MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
index 0df5f64d3a..5accc06d77 100644
--- a/MediaBrowser.Controller/Providers/ProviderManager.cs
+++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
@@ -1,9 +1,11 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
+using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
+using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Concurrent;
@@ -13,12 +15,12 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-namespace MediaBrowser.Controller.Providers
+namespace MediaBrowser.Server.Implementations.Providers
{
///
/// Class ProviderManager
///
- public class ProviderManager : IDisposable
+ public class ProviderManager : IProviderManager
{
///
/// The remote image cache
@@ -41,23 +43,37 @@ namespace MediaBrowser.Controller.Providers
///
private readonly IHttpClient _httpClient;
+ ///
+ /// The _directory watchers
+ ///
+ private readonly IDirectoryWatchers _directoryWatchers;
+
+ ///
+ /// Gets or sets the configuration manager.
+ ///
+ /// The configuration manager.
private IServerConfigurationManager ConfigurationManager { get; set; }
- private Kernel Kernel { get; set; }
+ ///
+ /// Gets the list of currently registered metadata prvoiders
+ ///
+ /// The metadata providers enumerable.
+ private BaseMetadataProvider[] MetadataProviders { get; set; }
///
/// Initializes a new instance of the class.
///
- /// The kernel.
/// The HTTP client.
- /// The logger.
- public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger, IServerConfigurationManager configurationManager)
+ /// The configuration manager.
+ /// The directory watchers.
+ /// The log manager.
+ public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, IDirectoryWatchers directoryWatchers, ILogManager logManager)
{
- _logger = logger;
- Kernel = kernel;
+ _logger = logManager.GetLogger("ProviderManager");
_httpClient = httpClient;
ConfigurationManager = configurationManager;
- _remoteImageCache = new FileSystemRepository(ImagesDataPath);
+ _directoryWatchers = directoryWatchers;
+ _remoteImageCache = new FileSystemRepository(configurationManager.ApplicationPaths.DownloadedImagesDataPath);
configurationManager.ConfigurationUpdated += configurationManager_ConfigurationUpdated;
}
@@ -77,37 +93,20 @@ namespace MediaBrowser.Controller.Providers
}
///
- /// The _images data path
+ /// Gets or sets the supported providers key.
///
- private string _imagesDataPath;
+ /// The supported providers key.
+ private Guid SupportedProvidersKey { get; set; }
+
///
- /// Gets the images data path.
+ /// Adds the metadata providers.
///
- /// The images data path.
- public string ImagesDataPath
+ /// The providers.
+ public void AddMetadataProviders(IEnumerable providers)
{
- get
- {
- if (_imagesDataPath == null)
- {
- _imagesDataPath = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "remote-images");
-
- if (!Directory.Exists(_imagesDataPath))
- {
- Directory.CreateDirectory(_imagesDataPath);
- }
- }
-
- return _imagesDataPath;
- }
+ MetadataProviders = providers.ToArray();
}
- ///
- /// Gets or sets the supported providers key.
- ///
- /// The supported providers key.
- private Guid SupportedProvidersKey { get; set; }
-
///
/// Runs all metadata providers for an entity, and returns true or false indicating if at least one was refreshed and requires persistence
///
@@ -116,7 +115,7 @@ namespace MediaBrowser.Controller.Providers
/// if set to true [force].
/// if set to true [allow slow providers].
/// Task{System.Boolean}.
- internal async Task ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true)
+ public async Task ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true)
{
// Allow providers of the same priority to execute in parallel
MetadataProviderPriority? currentPriority = null;
@@ -127,7 +126,7 @@ namespace MediaBrowser.Controller.Providers
cancellationToken.ThrowIfCancellationRequested();
// Determine if supported providers have changed
- var supportedProviders = Kernel.MetadataProviders.Where(p => p.Supports(item)).ToList();
+ var supportedProviders = MetadataProviders.Where(p => p.Supports(item)).ToList();
BaseProviderInfo supportedProvidersInfo;
@@ -201,7 +200,7 @@ namespace MediaBrowser.Controller.Providers
continue;
}
- currentTasks.Add(provider.FetchAsync(item, force, cancellationToken));
+ currentTasks.Add(FetchAsync(provider, item, force, cancellationToken));
currentPriority = provider.Priority;
}
@@ -219,13 +218,69 @@ namespace MediaBrowser.Controller.Providers
return result || providersChanged;
}
+ ///
+ /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
+ ///
+ /// The provider.
+ /// The item.
+ /// if set to true [force].
+ /// The cancellation token.
+ /// Task{System.Boolean}.
+ ///
+ private async Task FetchAsync(BaseMetadataProvider provider, BaseItem item, bool force, CancellationToken cancellationToken)
+ {
+ if (item == null)
+ {
+ throw new ArgumentNullException();
+ }
+
+ cancellationToken.ThrowIfCancellationRequested();
+
+ _logger.Info("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name ?? "--Unknown--");
+
+ // This provides the ability to cancel just this one provider
+ var innerCancellationTokenSource = new CancellationTokenSource();
+
+ OnProviderRefreshBeginning(provider, item, innerCancellationTokenSource);
+
+ try
+ {
+ return await provider.FetchAsync(item, force, CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, innerCancellationTokenSource.Token).Token).ConfigureAwait(false);
+ }
+ catch (OperationCanceledException ex)
+ {
+ _logger.Info("{0} cancelled for {1}", provider.GetType().Name, item.Name);
+
+ // If the outer cancellation token is the one that caused the cancellation, throw it
+ if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken)
+ {
+ throw;
+ }
+
+ return false;
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("{0} failed refreshing {1}", ex, provider.GetType().Name, item.Name);
+
+ provider.SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.Failure);
+ return true;
+ }
+ finally
+ {
+ innerCancellationTokenSource.Dispose();
+
+ OnProviderRefreshCompleted(provider, item);
+ }
+ }
+
///
/// Notifies the kernal that a provider has begun refreshing
///
/// The provider.
/// The item.
/// The cancellation token source.
- internal void OnProviderRefreshBeginning(BaseMetadataProvider provider, BaseItem item, CancellationTokenSource cancellationTokenSource)
+ public void OnProviderRefreshBeginning(BaseMetadataProvider provider, BaseItem item, CancellationTokenSource cancellationTokenSource)
{
var key = item.Id + provider.GetType().Name;
@@ -253,7 +308,7 @@ namespace MediaBrowser.Controller.Providers
///
/// The provider.
/// The item.
- internal void OnProviderRefreshCompleted(BaseMetadataProvider provider, BaseItem item)
+ public void OnProviderRefreshCompleted(BaseMetadataProvider provider, BaseItem item)
{
var key = item.Id + provider.GetType().Name;
@@ -268,7 +323,7 @@ namespace MediaBrowser.Controller.Providers
///
/// Validates the currently running providers and cancels any that should not be run due to configuration changes
///
- internal void ValidateCurrentlyRunningProviders()
+ private void ValidateCurrentlyRunningProviders()
{
_logger.Info("Validing currently running providers");
@@ -321,7 +376,7 @@ namespace MediaBrowser.Controller.Providers
if (ConfigurationManager.Configuration.SaveLocalMeta) // queue to media directories
{
- await Kernel.FileSystemManager.SaveToLibraryFilesystem(item, localPath, img, cancellationToken).ConfigureAwait(false);
+ await SaveToLibraryFilesystem(item, localPath, img, cancellationToken).ConfigureAwait(false);
}
else
{
@@ -352,6 +407,63 @@ namespace MediaBrowser.Controller.Providers
return localPath;
}
+
+ ///
+ /// Saves to library filesystem.
+ ///
+ /// The item.
+ /// The path.
+ /// The data to save.
+ /// The cancellation token.
+ /// Task.
+ ///
+ public async Task SaveToLibraryFilesystem(BaseItem item, string path, Stream dataToSave, CancellationToken cancellationToken)
+ {
+ if (item == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (string.IsNullOrEmpty(path))
+ {
+ throw new ArgumentNullException();
+ }
+ if (dataToSave == null)
+ {
+ throw new ArgumentNullException();
+ }
+ if (cancellationToken == null)
+ {
+ throw new ArgumentNullException();
+ }
+
+ cancellationToken.ThrowIfCancellationRequested();
+
+ //Tell the watchers to ignore
+ _directoryWatchers.TemporarilyIgnore(path);
+
+ //Make the mod
+
+ dataToSave.Position = 0;
+
+ try
+ {
+ using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
+ {
+ await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
+
+ dataToSave.Dispose();
+
+ // If this is ever used for something other than metadata we can add a file type param
+ item.ResolveArgs.AddMetadataFile(path);
+ }
+ }
+ finally
+ {
+ //Remove the ignore
+ _directoryWatchers.RemoveTempIgnore(path);
+ }
+ }
+
///
/// Releases unmanaged and - optionally - managed resources.
///
@@ -364,6 +476,9 @@ namespace MediaBrowser.Controller.Providers
}
}
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
public void Dispose()
{
Dispose(true);
diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs
index 8306e094bc..b20630edb7 100644
--- a/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs
+++ b/MediaBrowser.Server.Implementations/ScheduledTasks/ImageCleanupTask.cs
@@ -27,17 +27,21 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
///
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
+ private readonly IServerApplicationPaths _appPaths;
///
/// Initializes a new instance of the class.
///
/// The kernel.
/// The logger.
- public ImageCleanupTask(Kernel kernel, ILogger logger, ILibraryManager libraryManager)
+ /// The library manager.
+ /// The app paths.
+ public ImageCleanupTask(Kernel kernel, ILogger logger, ILibraryManager libraryManager, IServerApplicationPaths appPaths)
{
_kernel = kernel;
_logger = logger;
_libraryManager = libraryManager;
+ _appPaths = appPaths;
}
///
@@ -65,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
// First gather all image files
var files = GetFiles(_kernel.FFMpegManager.AudioImagesDataPath)
.Concat(GetFiles(_kernel.FFMpegManager.VideoImagesDataPath))
- .Concat(GetFiles(_kernel.ProviderManager.ImagesDataPath))
+ .Concat(GetFiles(_appPaths.DownloadedImagesDataPath))
.ToList();
// Now gather all items
diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs
index ff29badff2..429c893cab 100644
--- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs
+++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs
@@ -302,7 +302,7 @@ namespace MediaBrowser.Server.Implementations
/// Gets the FF MPEG stream cache path.
///
/// The FF MPEG stream cache path.
- public string FFMpegStreamCachePath
+ public string EncodedMediaCachePath
{
get
{
@@ -345,5 +345,31 @@ namespace MediaBrowser.Server.Implementations
return _mediaToolsPath;
}
}
+
+ ///
+ /// The _images data path
+ ///
+ private string _downloadedImagesDataPath;
+ ///
+ /// Gets the images data path.
+ ///
+ /// The images data path.
+ public string DownloadedImagesDataPath
+ {
+ get
+ {
+ if (_downloadedImagesDataPath == null)
+ {
+ _downloadedImagesDataPath = Path.Combine(DataPath, "remote-images");
+
+ if (!Directory.Exists(_downloadedImagesDataPath))
+ {
+ Directory.CreateDirectory(_downloadedImagesDataPath);
+ }
+ }
+
+ return _downloadedImagesDataPath;
+ }
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
index e4cb83e96d..60628853e9 100644
--- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
+++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
@@ -104,8 +104,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
/// The web socket listeners.
private readonly List _webSocketListeners = new List();
- private Kernel _kernel;
-
+ private readonly Kernel _kernel;
+
///
/// Initializes a new instance of the class.
///
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index a3e273438d..0155d0c90e 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -156,13 +156,13 @@ namespace MediaBrowser.ServerApplication
{
CompositionRoot = new ApplicationHost();
- var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager);
-
Logger = CompositionRoot.LogManager.GetLogger("App");
- win.Show();
-
await CompositionRoot.Init();
+
+ var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager, CompositionRoot.UserManager, CompositionRoot.LibraryManager, CompositionRoot.JsonSerializer);
+
+ win.Show();
}
catch (Exception ex)
{
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index df3765818e..2eccee0665 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -2,18 +2,24 @@
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
-using MediaBrowser.Common.Events;
using MediaBrowser.Common.Implementations;
using MediaBrowser.Common.Implementations.ScheduledTasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
-using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Localization;
+using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Controller.Plugins;
+using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Controller.Updates;
+using MediaBrowser.Controller.Weather;
using MediaBrowser.IsoMounter;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
@@ -23,7 +29,9 @@ using MediaBrowser.Server.Implementations;
using MediaBrowser.Server.Implementations.BdInfo;
using MediaBrowser.Server.Implementations.Configuration;
using MediaBrowser.Server.Implementations.HttpServer;
+using MediaBrowser.Server.Implementations.IO;
using MediaBrowser.Server.Implementations.Library;
+using MediaBrowser.Server.Implementations.Providers;
using MediaBrowser.Server.Implementations.ServerManager;
using MediaBrowser.Server.Implementations.Udp;
using MediaBrowser.Server.Implementations.Updates;
@@ -78,23 +86,73 @@ namespace MediaBrowser.ServerApplication
return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
}
+ ///
+ /// Gets or sets the installation manager.
+ ///
+ /// The installation manager.
private IInstallationManager InstallationManager { get; set; }
+ ///
+ /// Gets or sets the server manager.
+ ///
+ /// The server manager.
private IServerManager ServerManager { get; set; }
-
+ ///
+ /// Gets or sets the user manager.
+ ///
+ /// The user manager.
+ public IUserManager UserManager { get; set; }
+ ///
+ /// Gets or sets the library manager.
+ ///
+ /// The library manager.
+ internal ILibraryManager LibraryManager { get; set; }
+ ///
+ /// Gets or sets the directory watchers.
+ ///
+ /// The directory watchers.
+ private IDirectoryWatchers DirectoryWatchers { get; set; }
+ ///
+ /// Gets or sets the provider manager.
+ ///
+ /// The provider manager.
+ private IProviderManager ProviderManager { get; set; }
+ ///
+ /// Gets or sets the zip client.
+ ///
+ /// The zip client.
+ private IZipClient ZipClient { get; set; }
+ ///
+ /// Gets or sets the HTTP server.
+ ///
+ /// The HTTP server.
+ private IHttpServer HttpServer { get; set; }
+
+ ///
+ /// Inits this instance.
+ ///
+ /// Task.
public override async Task Init()
{
await base.Init().ConfigureAwait(false);
- await ServerKernel.Init().ConfigureAwait(false);
+ Task.Run(async () =>
+ {
+ await ServerKernel.LoadRepositories(ServerConfigurationManager).ConfigureAwait(false);
+
+ DirectoryWatchers.Start();
+
+ Parallel.ForEach(GetExports(), entryPoint => entryPoint.Run());
+ });
}
///
/// Registers resources that classes will depend on
///
+ /// Task.
protected override async Task RegisterResources()
{
- ServerKernel = new Kernel(this, XmlSerializer, LogManager, ServerConfigurationManager);
-
+ ServerKernel = new Kernel(ServerConfigurationManager);
+
await base.RegisterResources().ConfigureAwait(false);
RegisterSingleInstance(this);
@@ -108,20 +166,66 @@ namespace MediaBrowser.ServerApplication
RegisterSingleInstance(new PismoIsoManager(Logger));
RegisterSingleInstance(new BdInfoExaminer());
- RegisterSingleInstance(new DotNetZipClient());
- RegisterSingleInstance(ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html"), false);
+
+ ZipClient = new DotNetZipClient();
+ RegisterSingleInstance(ZipClient);
+
+ HttpServer = ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html");
+ RegisterSingleInstance(HttpServer, false);
ServerManager = new ServerManager(this, NetworkManager, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel);
RegisterSingleInstance(ServerManager);
- var userManager = new UserManager(ServerKernel, Logger, ServerConfigurationManager);
+ UserManager = new UserManager(ServerKernel, Logger, ServerConfigurationManager);
+ RegisterSingleInstance(UserManager);
- RegisterSingleInstance(userManager);
-
- RegisterSingleInstance(new LibraryManager(ServerKernel, Logger, TaskManager, userManager, ServerConfigurationManager));
+ LibraryManager = new LibraryManager(ServerKernel, Logger, TaskManager, UserManager, ServerConfigurationManager);
+ RegisterSingleInstance(LibraryManager);
InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
RegisterSingleInstance(InstallationManager);
+
+ DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
+ RegisterSingleInstance(DirectoryWatchers);
+
+ ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager);
+ RegisterSingleInstance(ProviderManager);
+
+ SetKernelProperties();
+ SetStaticProperties();
+ }
+
+ ///
+ /// Sets the kernel properties.
+ ///
+ private void SetKernelProperties()
+ {
+ ServerKernel.FFMpegManager = new FFMpegManager(ServerKernel, ZipClient, JsonSerializer, ProtobufSerializer, LogManager, ApplicationPaths);
+ ServerKernel.ImageManager = new ImageManager(ServerKernel, ProtobufSerializer, LogManager.GetLogger("ImageManager"), ApplicationPaths);
+
+ ServerKernel.UserDataRepositories = GetExports();
+ ServerKernel.UserRepositories = GetExports();
+ ServerKernel.DisplayPreferencesRepositories = GetExports();
+ ServerKernel.ItemRepositories = GetExports();
+ ServerKernel.WeatherProviders = GetExports();
+ ServerKernel.ImageEnhancers = GetExports().OrderBy(e => e.Priority).ToArray();
+ ServerKernel.StringFiles = GetExports();
+ }
+
+ ///
+ /// Dirty hacks
+ ///
+ private void SetStaticProperties()
+ {
+ // For now there's no real way to inject these properly
+ BaseItem.Logger = LogManager.GetLogger("BaseItem");
+ BaseItem.ConfigurationManager = ServerConfigurationManager;
+ BaseItem.LibraryManager = LibraryManager;
+ BaseItem.ProviderManager = ProviderManager;
+ User.XmlSerializer = XmlSerializer;
+ User.UserManager = UserManager;
+ Ratings.ConfigurationManager = ServerConfigurationManager;
+ LocalizedStrings.ApplicationPaths = ApplicationPaths;
}
///
@@ -131,12 +235,14 @@ namespace MediaBrowser.ServerApplication
{
base.FindParts();
- Resolve().Init(GetExports(false));
- Resolve().AddWebSocketListeners(GetExports(false));
+ HttpServer.Init(GetExports(false));
+
+ ServerManager.AddWebSocketListeners(GetExports(false));
+ ServerManager.Start();
- Resolve().Start();
+ LibraryManager.AddParts(GetExports(), GetExports(), GetExports(), GetExports());
- Resolve().AddParts(GetExports(), GetExports(), GetExports(), GetExports());
+ ProviderManager.AddMetadataProviders(GetExports().OrderBy(e => e.Priority).ToArray());
}
///
@@ -164,9 +270,8 @@ namespace MediaBrowser.ServerApplication
/// Task{CheckForUpdateResult}.
public async override Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress)
{
- var pkgManager = Resolve();
- var availablePackages = await pkgManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
- var version = Resolve().GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
+ var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
+ var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
diff --git a/MediaBrowser.ServerApplication/NewItemNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
similarity index 98%
rename from MediaBrowser.ServerApplication/NewItemNotifier.cs
rename to MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
index 4864cef62d..4a1f0ac74e 100644
--- a/MediaBrowser.ServerApplication/NewItemNotifier.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/NewItemNotifier.cs
@@ -9,7 +9,7 @@ using System.Linq;
using System.Threading;
using System.Windows.Controls.Primitives;
-namespace MediaBrowser.ServerApplication
+namespace MediaBrowser.ServerApplication.EntryPoints
{
///
/// Class NewItemNotifier
diff --git a/MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs b/MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs
new file mode 100644
index 0000000000..735a1f6559
--- /dev/null
+++ b/MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs
@@ -0,0 +1,41 @@
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Plugins;
+using System.Threading;
+
+namespace MediaBrowser.ServerApplication.EntryPoints
+{
+ ///
+ /// Class RefreshUsersMetadata
+ ///
+ public class RefreshUsersMetadata : IServerEntryPoint
+ {
+ ///
+ /// The _user manager
+ ///
+ private readonly IUserManager _userManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The user manager.
+ public RefreshUsersMetadata(IUserManager userManager)
+ {
+ _userManager = userManager;
+ }
+
+ ///
+ /// Runs this instance.
+ ///
+ public async void Run()
+ {
+ await _userManager.RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
+ }
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/StartupWizard.cs b/MediaBrowser.ServerApplication/EntryPoints/StartupWizard.cs
similarity index 97%
rename from MediaBrowser.ServerApplication/StartupWizard.cs
rename to MediaBrowser.ServerApplication/EntryPoints/StartupWizard.cs
index f7946c7112..43d9018a18 100644
--- a/MediaBrowser.ServerApplication/StartupWizard.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/StartupWizard.cs
@@ -4,7 +4,7 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using System.Linq;
-namespace MediaBrowser.ServerApplication
+namespace MediaBrowser.ServerApplication.EntryPoints
{
///
/// Class StartupWizard
diff --git a/MediaBrowser.ServerApplication/WebSocketEvents.cs b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
similarity index 99%
rename from MediaBrowser.ServerApplication/WebSocketEvents.cs
rename to MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
index 43972bafc2..13359fced2 100644
--- a/MediaBrowser.ServerApplication/WebSocketEvents.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
@@ -12,7 +12,7 @@ using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using System;
-namespace MediaBrowser.ServerApplication
+namespace MediaBrowser.ServerApplication.EntryPoints
{
///
/// Class WebSocketEvents
diff --git a/MediaBrowser.ServerApplication/MainWindow.xaml.cs b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
index 80f959b8bf..364dd9da65 100644
--- a/MediaBrowser.ServerApplication/MainWindow.xaml.cs
+++ b/MediaBrowser.ServerApplication/MainWindow.xaml.cs
@@ -4,6 +4,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.ServerApplication.Logging;
using System;
using System.ComponentModel;
@@ -38,7 +39,11 @@ namespace MediaBrowser.ServerApplication
/// The _configuration manager
///
private readonly IServerConfigurationManager _configurationManager;
-
+
+ private readonly IUserManager _userManager;
+ private readonly ILibraryManager _libraryManager;
+ private readonly IJsonSerializer _jsonSerializer;
+
///
/// Initializes a new instance of the class.
///
@@ -46,7 +51,7 @@ namespace MediaBrowser.ServerApplication
/// The logger.
/// The app host.
/// logger
- public MainWindow(ILogManager logManager, IApplicationHost appHost, IServerConfigurationManager configurationManager)
+ public MainWindow(ILogManager logManager, IApplicationHost appHost, IServerConfigurationManager configurationManager, IUserManager userManager, ILibraryManager libraryManager, IJsonSerializer jsonSerializer)
{
if (logManager == null)
{
@@ -65,6 +70,9 @@ namespace MediaBrowser.ServerApplication
_appHost = appHost;
_logManager = logManager;
_configurationManager = configurationManager;
+ _userManager = userManager;
+ _libraryManager = libraryManager;
+ _jsonSerializer = jsonSerializer;
InitializeComponent();
@@ -209,8 +217,7 @@ namespace MediaBrowser.ServerApplication
/// The instance containing the event data.
private void cmOpenExplorer_click(object sender, RoutedEventArgs e)
{
- var explorer = (LibraryExplorer)_appHost.CreateInstance(typeof(LibraryExplorer));
- explorer.Show();
+ new LibraryExplorer(_jsonSerializer, _logger, _appHost, _userManager, _libraryManager).Show();
}
///
@@ -220,7 +227,7 @@ namespace MediaBrowser.ServerApplication
/// The instance containing the event data.
private void cmOpenDashboard_click(object sender, RoutedEventArgs e)
{
- var user = _appHost.Resolve().Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
+ var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
OpenDashboard(user);
}
@@ -249,7 +256,7 @@ namespace MediaBrowser.ServerApplication
/// The instance containing the event data.
private void cmdBrowseLibrary_click(object sender, RoutedEventArgs e)
{
- var user = _appHost.Resolve().Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
+ var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
App.OpenDashboardPage("index.html", user, _configurationManager);
}
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index deec2d67ff..a67d61bfd8 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -158,9 +158,10 @@
-
-
-
+
+
+
+
MSBuild:Compile
Designer
@@ -403,9 +404,9 @@ del "$(SolutionDir)..\Deploy\MBServer.zip"
-->
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/MediaBrowser.sln b/MediaBrowser.sln
index 16caa617d6..c13ad6f819 100644
--- a/MediaBrowser.sln
+++ b/MediaBrowser.sln
@@ -237,4 +237,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(Performance) = preSolution
+ HasPerformanceSessions = true
+ EndGlobalSection
EndGlobal