mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-02 21:24:15 -04:00
extracted provider manager. took more off the kernel
This commit is contained in:
parent
211d24e66e
commit
9911df11e8
@ -93,7 +93,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected string GetOutputFilePath(StreamState state)
|
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());
|
return Path.Combine(folder, GetCommandLineArguments("dummy\\dummy", state).GetMD5() + GetOutputFileExtension(state).ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ namespace MediaBrowser.Common.Implementations
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The json serializer
|
/// The json serializer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly IJsonSerializer JsonSerializer = new JsonSerializer();
|
public readonly IJsonSerializer JsonSerializer = new JsonSerializer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _XML serializer
|
/// The _XML serializer
|
||||||
@ -524,8 +524,7 @@ namespace MediaBrowser.Common.Implementations
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress)
|
public async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
var pkgManager = Resolve<IPackageManager>();
|
await PackageManager.InstallPackage(progress, package, cancellationToken).ConfigureAwait(false);
|
||||||
await pkgManager.InstallPackage(progress, package, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = package.version }, Logger);
|
EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<Version> { Argument = package.version }, Logger);
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The logger
|
/// The logger
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected static internal ILogger Logger { get; internal set; }
|
public static ILogger Logger { get; set; }
|
||||||
protected static internal ILibraryManager LibraryManager { get; internal set; }
|
public static ILibraryManager LibraryManager { get; set; }
|
||||||
protected static internal IServerConfigurationManager ConfigurationManager { get; internal set; }
|
public static IServerConfigurationManager ConfigurationManager { get; set; }
|
||||||
|
public static IProviderManager ProviderManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||||
@ -652,7 +653,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
LocalTrailers = null;
|
LocalTrailers = null;
|
||||||
|
|
||||||
// Refresh for the item
|
// Refresh for the item
|
||||||
var itemRefreshTask = Kernel.Instance.ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);
|
var itemRefreshTask = ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class User : BaseItem
|
public class User : BaseItem
|
||||||
{
|
{
|
||||||
internal static IUserManager UserManager { get; set; }
|
public static IUserManager UserManager { get; set; }
|
||||||
internal static IXmlSerializer XmlSerializer { get; set; }
|
public static IXmlSerializer XmlSerializer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _root folder path
|
/// The _root folder path
|
||||||
@ -363,7 +363,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
ResolveArgs = null;
|
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)
|
if (changed || forceSave)
|
||||||
{
|
{
|
||||||
|
@ -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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
public class FileSystemManager : IDisposable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the directory watchers.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The directory watchers.</value>
|
|
||||||
private DirectoryWatchers DirectoryWatchers { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="FileSystemManager" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="logManager">The log manager.</param>
|
|
||||||
/// <param name="taskManager">The task manager.</param>
|
|
||||||
/// <param name="libraryManager">The library manager.</param>
|
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
|
||||||
public FileSystemManager(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
|
||||||
{
|
|
||||||
DirectoryWatchers = new DirectoryWatchers(logManager, taskManager, libraryManager, configurationManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Start the directory watchers on our library folders
|
|
||||||
/// </summary>
|
|
||||||
public void StartWatchers()
|
|
||||||
{
|
|
||||||
DirectoryWatchers.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves to library filesystem.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">The item.</param>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="dataToSave">The data to save.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
/// <exception cref="System.ArgumentNullException"></exception>
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
||||||
protected virtual void Dispose(bool dispose)
|
|
||||||
{
|
|
||||||
if (dispose)
|
|
||||||
{
|
|
||||||
DirectoryWatchers.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
29
MediaBrowser.Controller/IO/IDirectoryWatchers.cs
Normal file
29
MediaBrowser.Controller/IO/IDirectoryWatchers.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Controller.IO
|
||||||
|
{
|
||||||
|
public interface IDirectoryWatchers : IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
void TemporarilyIgnore(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the temp ignore.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
void RemoveTempIgnore(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts this instance.
|
||||||
|
/// </summary>
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops this instance.
|
||||||
|
/// </summary>
|
||||||
|
void Stop();
|
||||||
|
}
|
||||||
|
}
|
@ -74,12 +74,18 @@ namespace MediaBrowser.Controller
|
|||||||
/// Gets the FF MPEG stream cache path.
|
/// Gets the FF MPEG stream cache path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The FF MPEG stream cache path.</value>
|
/// <value>The FF MPEG stream cache path.</value>
|
||||||
string FFMpegStreamCachePath { get; }
|
string EncodedMediaCachePath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the folder path to tools
|
/// Gets the folder path to tools
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The media tools path.</value>
|
/// <value>The media tools path.</value>
|
||||||
string MediaToolsPath { get; }
|
string MediaToolsPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the downloaded images data path.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The downloaded images data path.</value>
|
||||||
|
string DownloadedImagesDataPath { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,13 @@
|
|||||||
using MediaBrowser.Common;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Common.ScheduledTasks;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.IO;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
using MediaBrowser.Controller.MediaInfo;
|
using MediaBrowser.Controller.MediaInfo;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Plugins;
|
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Weather;
|
using MediaBrowser.Controller.Weather;
|
||||||
using MediaBrowser.Model.Logging;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller
|
namespace MediaBrowser.Controller
|
||||||
@ -24,7 +15,7 @@ namespace MediaBrowser.Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class Kernel
|
/// Class Kernel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Kernel : IDisposable
|
public class Kernel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the instance.
|
/// Gets the instance.
|
||||||
@ -36,25 +27,13 @@ namespace MediaBrowser.Controller
|
|||||||
/// Gets the image manager.
|
/// Gets the image manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The image manager.</value>
|
/// <value>The image manager.</value>
|
||||||
public ImageManager ImageManager { get; private set; }
|
public ImageManager ImageManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the FFMPEG controller.
|
/// Gets the FFMPEG controller.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The FFMPEG controller.</value>
|
/// <value>The FFMPEG controller.</value>
|
||||||
public FFMpegManager FFMpegManager { get; private set; }
|
public FFMpegManager FFMpegManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the file system manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The file system manager.</value>
|
|
||||||
public FileSystemManager FileSystemManager { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the provider manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The provider manager.</value>
|
|
||||||
public ProviderManager ProviderManager { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the web application that can be used for url building.
|
/// 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
|
/// Gets the list of Localized string files
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The string files.</value>
|
/// <value>The string files.</value>
|
||||||
public IEnumerable<LocalizedStringData> StringFiles { get; private set; }
|
public IEnumerable<LocalizedStringData> StringFiles { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of currently registered weather prvoiders
|
/// Gets the list of currently registered weather prvoiders
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The weather providers.</value>
|
/// <value>The weather providers.</value>
|
||||||
public IEnumerable<IWeatherProvider> WeatherProviders { get; private set; }
|
public IEnumerable<IWeatherProvider> WeatherProviders { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the list of currently registered metadata prvoiders
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The metadata providers enumerable.</value>
|
|
||||||
public BaseMetadataProvider[] MetadataProviders { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of currently registered image processors
|
/// Gets the list of currently registered image processors
|
||||||
/// Image processors are specialized metadata providers that run after the normal ones
|
/// Image processors are specialized metadata providers that run after the normal ones
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The image enhancers.</value>
|
/// <value>The image enhancers.</value>
|
||||||
public IEnumerable<IImageEnhancer> ImageEnhancers { get; private set; }
|
public IEnumerable<IImageEnhancer> ImageEnhancers { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available user repositories
|
/// Gets the list of available user repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user repositories.</value>
|
/// <value>The user repositories.</value>
|
||||||
private IEnumerable<IUserRepository> UserRepositories { get; set; }
|
public IEnumerable<IUserRepository> UserRepositories { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the active user repository
|
/// Gets the active user repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user repository.</value>
|
/// <value>The user repository.</value>
|
||||||
public IUserRepository UserRepository { get; private set; }
|
public IUserRepository UserRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the active user repository
|
/// Gets the active user repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The display preferences repository.</value>
|
/// <value>The display preferences repository.</value>
|
||||||
public IDisplayPreferencesRepository DisplayPreferencesRepository { get; private set; }
|
public IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available item repositories
|
/// Gets the list of available item repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The item repositories.</value>
|
/// <value>The item repositories.</value>
|
||||||
private IEnumerable<IItemRepository> ItemRepositories { get; set; }
|
public IEnumerable<IItemRepository> ItemRepositories { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the active item repository
|
/// Gets the active item repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The item repository.</value>
|
/// <value>The item repository.</value>
|
||||||
public IItemRepository ItemRepository { get; private set; }
|
public IItemRepository ItemRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available DisplayPreferencesRepositories
|
/// Gets the list of available DisplayPreferencesRepositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The display preferences repositories.</value>
|
/// <value>The display preferences repositories.</value>
|
||||||
private IEnumerable<IDisplayPreferencesRepository> DisplayPreferencesRepositories { get; set; }
|
public IEnumerable<IDisplayPreferencesRepository> DisplayPreferencesRepositories { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of available item repositories
|
/// Gets the list of available item repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user data repositories.</value>
|
/// <value>The user data repositories.</value>
|
||||||
private IEnumerable<IUserDataRepository> UserDataRepositories { get; set; }
|
public IEnumerable<IUserDataRepository> UserDataRepositories { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the active user data repository
|
/// Gets the active user data repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user data repository.</value>
|
/// <value>The user data repository.</value>
|
||||||
public IUserDataRepository UserDataRepository { get; private set; }
|
public IUserDataRepository UserDataRepository { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the UDP server port number.
|
/// Gets the UDP server port number.
|
||||||
@ -160,121 +133,39 @@ namespace MediaBrowser.Controller
|
|||||||
get { return 7359; }
|
get { return 7359; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IXmlSerializer _xmlSerializer;
|
|
||||||
|
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
private readonly ILogManager _logManager;
|
|
||||||
private IApplicationHost ApplicationHost { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a kernel based on a Data path, which is akin to our current programdata path
|
/// Creates a kernel based on a Data path, which is akin to our current programdata path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appHost">The app host.</param>
|
|
||||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
|
||||||
/// <param name="logManager">The log manager.</param>
|
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">isoManager</exception>
|
public Kernel(IServerConfigurationManager configurationManager)
|
||||||
public Kernel(IApplicationHost appHost, IXmlSerializer xmlSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
|
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
ApplicationHost = appHost;
|
|
||||||
_configurationManager = configurationManager;
|
_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Composes the parts with ioc container.
|
|
||||||
/// </summary>
|
|
||||||
protected void FindParts()
|
|
||||||
{
|
|
||||||
// For now there's no real way to inject these properly
|
|
||||||
BaseItem.LibraryManager = ApplicationHost.Resolve<ILibraryManager>();
|
|
||||||
User.UserManager = ApplicationHost.Resolve<IUserManager>();
|
|
||||||
|
|
||||||
FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager));
|
|
||||||
ImageManager = (ImageManager)ApplicationHost.CreateInstance(typeof(ImageManager));
|
|
||||||
ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager));
|
|
||||||
|
|
||||||
UserDataRepositories = ApplicationHost.GetExports<IUserDataRepository>();
|
|
||||||
UserRepositories = ApplicationHost.GetExports<IUserRepository>();
|
|
||||||
DisplayPreferencesRepositories = ApplicationHost.GetExports<IDisplayPreferencesRepository>();
|
|
||||||
ItemRepositories = ApplicationHost.GetExports<IItemRepository>();
|
|
||||||
WeatherProviders = ApplicationHost.GetExports<IWeatherProvider>();
|
|
||||||
ImageEnhancers = ApplicationHost.GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray();
|
|
||||||
StringFiles = ApplicationHost.GetExports<LocalizedStringData>();
|
|
||||||
MetadataProviders = ApplicationHost.GetExports<BaseMetadataProvider>().OrderBy(e => e.Priority).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs initializations that can be reloaded at anytime
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
public async Task Init()
|
|
||||||
{
|
|
||||||
FindParts();
|
|
||||||
|
|
||||||
await LoadRepositories().ConfigureAwait(false);
|
|
||||||
|
|
||||||
await ApplicationHost.Resolve<IUserManager>().RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
|
|
||||||
|
|
||||||
foreach (var entryPoint in ApplicationHost.GetExports<IServerEntryPoint>())
|
|
||||||
{
|
|
||||||
entryPoint.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
ReloadFileSystemManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
||||||
protected virtual void Dispose(bool dispose)
|
|
||||||
{
|
|
||||||
if (dispose)
|
|
||||||
{
|
|
||||||
DisposeFileSystemManager();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when [composable parts loaded].
|
/// Called when [composable parts loaded].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
protected Task LoadRepositories()
|
public Task LoadRepositories(IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
// Get the current item repository
|
// Get the current item repository
|
||||||
ItemRepository = GetRepository(ItemRepositories, _configurationManager.Configuration.ItemRepository);
|
ItemRepository = GetRepository(ItemRepositories, configurationManager.Configuration.ItemRepository);
|
||||||
var itemRepoTask = ItemRepository.Initialize();
|
var itemRepoTask = ItemRepository.Initialize();
|
||||||
|
|
||||||
// Get the current user repository
|
// Get the current user repository
|
||||||
UserRepository = GetRepository(UserRepositories, _configurationManager.Configuration.UserRepository);
|
UserRepository = GetRepository(UserRepositories, configurationManager.Configuration.UserRepository);
|
||||||
var userRepoTask = UserRepository.Initialize();
|
var userRepoTask = UserRepository.Initialize();
|
||||||
|
|
||||||
// Get the current item repository
|
// Get the current item repository
|
||||||
UserDataRepository = GetRepository(UserDataRepositories, _configurationManager.Configuration.UserDataRepository);
|
UserDataRepository = GetRepository(UserDataRepositories, configurationManager.Configuration.UserDataRepository);
|
||||||
var userDataRepoTask = UserDataRepository.Initialize();
|
var userDataRepoTask = UserDataRepository.Initialize();
|
||||||
|
|
||||||
// Get the current display preferences repository
|
// Get the current display preferences repository
|
||||||
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, _configurationManager.Configuration.DisplayPreferencesRepository);
|
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, configurationManager.Configuration.DisplayPreferencesRepository);
|
||||||
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
|
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
|
||||||
|
|
||||||
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
|
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)) ??
|
return enumerable.FirstOrDefault(r => string.Equals(r.Name, name, StringComparison.OrdinalIgnoreCase)) ??
|
||||||
enumerable.FirstOrDefault();
|
enumerable.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the file system manager.
|
|
||||||
/// </summary>
|
|
||||||
private void DisposeFileSystemManager()
|
|
||||||
{
|
|
||||||
if (FileSystemManager != null)
|
|
||||||
{
|
|
||||||
FileSystemManager.Dispose();
|
|
||||||
FileSystemManager = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reloads the file system manager.
|
|
||||||
/// </summary>
|
|
||||||
private void ReloadFileSystemManager()
|
|
||||||
{
|
|
||||||
DisposeFileSystemManager();
|
|
||||||
|
|
||||||
FileSystemManager = new FileSystemManager(_logManager, ApplicationHost.Resolve<ITaskManager>(), ApplicationHost.Resolve<ILibraryManager>(), _configurationManager);
|
|
||||||
FileSystemManager.StartWatchers();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Localization
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LocalizedStrings
|
public class LocalizedStrings
|
||||||
{
|
{
|
||||||
internal static IServerApplicationPaths ApplicationPaths;
|
public static IServerApplicationPaths ApplicationPaths;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base prefix
|
/// The base prefix
|
||||||
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Localization
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Ratings
|
public static class Ratings
|
||||||
{
|
{
|
||||||
internal static IServerConfigurationManager ConfigurationManager;
|
public static IServerConfigurationManager ConfigurationManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The ratings def
|
/// The ratings def
|
||||||
|
@ -102,12 +102,14 @@
|
|||||||
<Compile Include="Entities\Year.cs" />
|
<Compile Include="Entities\Year.cs" />
|
||||||
<Compile Include="Extensions\XmlExtensions.cs" />
|
<Compile Include="Extensions\XmlExtensions.cs" />
|
||||||
<Compile Include="IO\FileSystem.cs" />
|
<Compile Include="IO\FileSystem.cs" />
|
||||||
<Compile Include="IO\FileSystemManager.cs" />
|
<Compile Include="IO\IDirectoryWatchers.cs" />
|
||||||
<Compile Include="IO\NativeMethods.cs" />
|
<Compile Include="IO\NativeMethods.cs" />
|
||||||
<Compile Include="IServerApplicationHost.cs" />
|
<Compile Include="IServerApplicationHost.cs" />
|
||||||
<Compile Include="IServerApplicationPaths.cs" />
|
<Compile Include="IServerApplicationPaths.cs" />
|
||||||
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
|
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
|
||||||
<Compile Include="Library\DtoBuilder.cs" />
|
<Compile Include="Library\DtoBuilder.cs" />
|
||||||
|
<Compile Include="Providers\IProviderManager.cs" />
|
||||||
|
<Compile Include="Providers\MetadataProviderPriority.cs" />
|
||||||
<Compile Include="Providers\Music\LastfmAlbumProvider.cs" />
|
<Compile Include="Providers\Music\LastfmAlbumProvider.cs" />
|
||||||
<Compile Include="Providers\Music\FanArtAlbumProvider.cs" />
|
<Compile Include="Providers\Music\FanArtAlbumProvider.cs" />
|
||||||
<Compile Include="Providers\Music\FanArtArtistProvider.cs" />
|
<Compile Include="Providers\Music\FanArtArtistProvider.cs" />
|
||||||
@ -154,7 +156,6 @@
|
|||||||
<Compile Include="Providers\Movies\MovieProviderFromXml.cs" />
|
<Compile Include="Providers\Movies\MovieProviderFromXml.cs" />
|
||||||
<Compile Include="Providers\Movies\PersonProviderFromJson.cs" />
|
<Compile Include="Providers\Movies\PersonProviderFromJson.cs" />
|
||||||
<Compile Include="Providers\Movies\TmdbPersonProvider.cs" />
|
<Compile Include="Providers\Movies\TmdbPersonProvider.cs" />
|
||||||
<Compile Include="Providers\ProviderManager.cs" />
|
|
||||||
<Compile Include="Providers\SortNameProvider.cs" />
|
<Compile Include="Providers\SortNameProvider.cs" />
|
||||||
<Compile Include="Providers\TV\EpisodeImageFromMediaLocationProvider.cs" />
|
<Compile Include="Providers\TV\EpisodeImageFromMediaLocationProvider.cs" />
|
||||||
<Compile Include="Providers\TV\EpisodeProviderFromXml.cs" />
|
<Compile Include="Providers\TV\EpisodeProviderFromXml.cs" />
|
||||||
@ -176,7 +177,6 @@
|
|||||||
<Compile Include="Library\TVUtils.cs" />
|
<Compile Include="Library\TVUtils.cs" />
|
||||||
<Compile Include="ScheduledTasks\RefreshMediaLibraryTask.cs" />
|
<Compile Include="ScheduledTasks\RefreshMediaLibraryTask.cs" />
|
||||||
<Compile Include="Library\ItemResolveArgs.cs" />
|
<Compile Include="Library\ItemResolveArgs.cs" />
|
||||||
<Compile Include="IO\DirectoryWatchers.cs" />
|
|
||||||
<Compile Include="IO\FileData.cs" />
|
<Compile Include="IO\FileData.cs" />
|
||||||
<Compile Include="Kernel.cs" />
|
<Compile Include="Kernel.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Extensions;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class BaseMetadataProvider
|
/// Class BaseMetadataProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BaseMetadataProvider : IDisposable
|
public abstract class BaseMetadataProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the logger.
|
/// Gets the logger.
|
||||||
@ -27,16 +26,6 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <value>The configuration manager.</value>
|
/// <value>The configuration manager.</value>
|
||||||
protected IServerConfigurationManager ConfigurationManager { get; private set; }
|
protected IServerConfigurationManager ConfigurationManager { get; private set; }
|
||||||
|
|
||||||
// Cache these since they will be used a lot
|
|
||||||
/// <summary>
|
|
||||||
/// The false task result
|
|
||||||
/// </summary>
|
|
||||||
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
|
||||||
/// <summary>
|
|
||||||
/// The true task result
|
|
||||||
/// </summary>
|
|
||||||
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _id
|
/// The _id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -135,7 +124,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="providerVersion">The provider version.</param>
|
/// <param name="providerVersion">The provider version.</param>
|
||||||
/// <param name="status">The status.</param>
|
/// <param name="status">The status.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">item</exception>
|
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||||
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)
|
if (item == null)
|
||||||
{
|
{
|
||||||
@ -162,7 +151,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
/// <param name="status">The status.</param>
|
/// <param name="status">The status.</param>
|
||||||
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);
|
SetLastRefreshed(item, value, ProviderVersion, status);
|
||||||
}
|
}
|
||||||
@ -254,76 +243,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException"></exception>
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
public async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
public abstract Task<bool> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">The item.</param>
|
|
||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
|
||||||
protected abstract Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the priority.
|
/// Gets the priority.
|
||||||
@ -331,23 +251,6 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <value>The priority.</value>
|
/// <value>The priority.</value>
|
||||||
public abstract MetadataProviderPriority Priority { get; }
|
public abstract MetadataProviderPriority Priority { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
||||||
protected virtual void Dispose(bool dispose)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true or false indicating if the provider should refresh when the contents of it's directory changes
|
/// Returns true or false indicating if the provider should refresh when the contents of it's directory changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -386,34 +289,4 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
return item.FileSystemStamp;
|
return item.FileSystemStamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines when a provider should execute, relative to others
|
|
||||||
/// </summary>
|
|
||||||
public enum MetadataProviderPriority
|
|
||||||
{
|
|
||||||
// Run this provider at the beginning
|
|
||||||
/// <summary>
|
|
||||||
/// The first
|
|
||||||
/// </summary>
|
|
||||||
First = 1,
|
|
||||||
|
|
||||||
// Run this provider after all first priority providers
|
|
||||||
/// <summary>
|
|
||||||
/// The second
|
|
||||||
/// </summary>
|
|
||||||
Second = 2,
|
|
||||||
|
|
||||||
// Run this provider after all second priority providers
|
|
||||||
/// <summary>
|
|
||||||
/// The third
|
|
||||||
/// </summary>
|
|
||||||
Third = 3,
|
|
||||||
|
|
||||||
// Run this provider last
|
|
||||||
/// <summary>
|
|
||||||
/// The last
|
|
||||||
/// </summary>
|
|
||||||
Last = 4
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() => Fetch(item, cancellationToken));
|
return Task.Run(() => Fetch(item, cancellationToken));
|
||||||
}
|
}
|
||||||
|
51
MediaBrowser.Controller/Providers/IProviderManager.cs
Normal file
51
MediaBrowser.Controller/Providers/IProviderManager.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Downloads the and save image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="source">The source.</param>
|
||||||
|
/// <param name="targetName">Name of the target.</param>
|
||||||
|
/// <param name="resourcePool">The resource pool.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task{System.String}.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||||
|
Task<string> DownloadAndSaveImage(BaseItem item, string source, string targetName, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves to library filesystem.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <param name="dataToSave">The data to save.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
|
Task SaveToLibraryFilesystem(BaseItem item, string path, Stream dataToSave, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the metadata providers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
|
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
||||||
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
|
Task<bool> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the metadata providers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="providers">The providers.</param>
|
||||||
|
void AddMetadataProviders(IEnumerable<BaseMetadataProvider> providers);
|
||||||
|
}
|
||||||
|
}
|
@ -52,6 +52,11 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -59,7 +64,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
/// Provides a base class for extracting media information through ffprobe
|
/// Provides a base class for extracting media information through ffprobe
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public abstract class BaseFFProbeProvider<T> : BaseFFMpegProvider<T>
|
public abstract class BaseFFProbeProvider<T> : BaseFFMpegProvider<T>, IDisposable
|
||||||
where T : BaseItem
|
where T : BaseItem
|
||||||
{
|
{
|
||||||
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||||
@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var myItem = (T)item;
|
var myItem = (T)item;
|
||||||
|
|
||||||
@ -351,14 +351,17 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
FFProbeCache.Dispose();
|
FFProbeCache.Dispose();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
base.Dispose(dispose);
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,11 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -26,7 +31,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var audio = (Audio)item;
|
var audio = (Audio)item;
|
||||||
|
|
||||||
|
@ -59,6 +59,11 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,7 +71,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(item.PrimaryImagePath))
|
if (string.IsNullOrEmpty(item.PrimaryImagePath))
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Controller.Providers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Determines when a provider should execute, relative to others
|
||||||
|
/// </summary>
|
||||||
|
public enum MetadataProviderPriority
|
||||||
|
{
|
||||||
|
// Run this provider at the beginning
|
||||||
|
/// <summary>
|
||||||
|
/// The first
|
||||||
|
/// </summary>
|
||||||
|
First = 1,
|
||||||
|
|
||||||
|
// Run this provider after all first priority providers
|
||||||
|
/// <summary>
|
||||||
|
/// The second
|
||||||
|
/// </summary>
|
||||||
|
Second = 2,
|
||||||
|
|
||||||
|
// Run this provider after all second priority providers
|
||||||
|
/// <summary>
|
||||||
|
/// The third
|
||||||
|
/// </summary>
|
||||||
|
Third = 3,
|
||||||
|
|
||||||
|
// Run this provider last
|
||||||
|
/// <summary>
|
||||||
|
/// The last
|
||||||
|
/// </summary>
|
||||||
|
Last = 4
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class FanArtMovieProvider
|
/// Class FanArtMovieProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class FanArtMovieProvider : FanartBaseProvider
|
class FanArtMovieProvider : FanartBaseProvider, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fan art
|
/// The fan art
|
||||||
@ -32,6 +32,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <value>The HTTP client.</value>
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
protected IHttpClient HttpClient { get; private set; }
|
||||||
|
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="FanArtMovieProvider" /> class.
|
/// Initializes a new instance of the <see cref="FanArtMovieProvider" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,7 +41,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
||||||
public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (httpClient == null)
|
if (httpClient == null)
|
||||||
@ -47,19 +49,19 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
throw new ArgumentNullException("httpClient");
|
throw new ArgumentNullException("httpClient");
|
||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
FanArtResourcePool.Dispose();
|
FanArtResourcePool.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(dispose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -103,7 +105,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -147,7 +149,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
|
Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -173,7 +175,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
|
Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -196,7 +198,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
|
Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -220,7 +222,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -244,7 +246,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -260,5 +262,10 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
SetLastRefreshed(movie, DateTime.UtcNow);
|
SetLastRefreshed(movie, DateTime.UtcNow);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,10 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class MovieDbProvider
|
/// Class MovieDbProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MovieDbProvider : BaseMetadataProvider
|
public class MovieDbProvider : BaseMetadataProvider, IDisposable
|
||||||
{
|
{
|
||||||
|
protected readonly IProviderManager ProviderManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The movie db
|
/// The movie db
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -58,11 +60,12 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
/// <param name="jsonSerializer">The json serializer.</param>
|
/// <param name="jsonSerializer">The json serializer.</param>
|
||||||
/// <param name="httpClient">The HTTP client.</param>
|
/// <param name="httpClient">The HTTP client.</param>
|
||||||
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)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
JsonSerializer = jsonSerializer;
|
JsonSerializer = jsonSerializer;
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
ProviderManager = providerManager;
|
||||||
Current = this;
|
Current = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,13 +73,12 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
MovieDbResourcePool.Dispose();
|
MovieDbResourcePool.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(dispose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -209,16 +211,17 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="providerVersion">The provider version.</param>
|
||||||
/// <param name="status">The status.</param>
|
/// <param name="status">The status.</param>
|
||||||
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)
|
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||||
{
|
{
|
||||||
//in addition to ours, we need to set the last refreshed time for the local data provider
|
//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
|
//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 });
|
var data = item.ProviderData.GetValueOrDefault(JsonProvider.Id, new BaseProviderInfo { ProviderId = JsonProvider.Id });
|
||||||
data.LastRefreshed = value;
|
data.LastRefreshed = value;
|
||||||
item.ProviderData[JsonProvider.Id] = data;
|
item.ProviderData[JsonProvider.Id] = data;
|
||||||
@ -291,7 +294,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token</param>
|
/// <param name="cancellationToken">The cancellation token</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HasAltMeta(item))
|
if (HasAltMeta(item))
|
||||||
{
|
{
|
||||||
@ -724,7 +727,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
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
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -1050,7 +1053,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -1661,5 +1664,10 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
public TmdbImageSettings images { get; set; }
|
public TmdbImageSettings images { get; set; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MovieProviderFromJson : MovieDbProvider
|
public class MovieProviderFromJson : MovieDbProvider
|
||||||
{
|
{
|
||||||
public MovieProviderFromJson(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient) :
|
public MovieProviderFromJson(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient, IProviderManager providerManager)
|
||||||
base(logManager, configurationManager, jsonSerializer, httpClient)
|
: base(logManager, configurationManager, jsonSerializer, httpClient, providerManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> 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
|
// Since we don't have anything truly async, and since deserializing can be expensive, create a task to force parallelism
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() => Fetch(item, cancellationToken));
|
return Task.Run(() => Fetch(item, cancellationToken));
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class PersonProviderFromJson : TmdbPersonProvider
|
class PersonProviderFromJson : TmdbPersonProvider
|
||||||
{
|
{
|
||||||
public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager) :
|
public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
base(httpClient, jsonSerializer, logManager, configurationManager)
|
: base(httpClient, jsonSerializer, logManager, configurationManager, providerManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,9 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected const string MetaFileName = "MBPerson.json";
|
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)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (jsonSerializer == null)
|
if (jsonSerializer == null)
|
||||||
@ -39,6 +41,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
JsonSerializer = jsonSerializer;
|
JsonSerializer = jsonSerializer;
|
||||||
|
ProviderManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -83,7 +86,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -209,7 +212,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
|
|
||||||
JsonSerializer.SerializeToStream(searchResult, memoryStream);
|
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);
|
Logger.Debug("TmdbPersonProvider downloaded and saved information for {0}", person.Name);
|
||||||
}
|
}
|
||||||
@ -288,7 +291,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||||||
}
|
}
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
var tmdbSettings = await Kernel.Instance.MetadataProviders.OfType<MovieDbProvider>().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,
|
var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.File_Path,
|
||||||
"folder" + Path.GetExtension(profile.File_Path), cancellationToken).ConfigureAwait(false);
|
"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))
|
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);
|
Logger.Debug("TmdbPersonProvider downloaded and saved image for {0}", item.Name);
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,12 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
{
|
{
|
||||||
public class FanArtAlbumProvider : FanartBaseProvider
|
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)
|
public override bool Supports(BaseItem item)
|
||||||
@ -37,7 +41,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var mbid = item.GetProviderId(MetadataProviders.Musicbrainz);
|
var mbid = item.GetProviderId(MetadataProviders.Musicbrainz);
|
||||||
if (mbid == null)
|
if (mbid == null)
|
||||||
@ -67,7 +71,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
/// <value>The HTTP client.</value>
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
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)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (httpClient == null)
|
if (httpClient == null)
|
||||||
@ -36,6 +38,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
throw new ArgumentNullException("httpClient");
|
throw new ArgumentNullException("httpClient");
|
||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +83,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
Logger.Debug("FanArtProvider getting ClearLogo for " + artist.Name);
|
Logger.Debug("FanArtProvider getting ClearLogo for " + artist.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -146,7 +149,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
Logger.Debug("FanArtProvider getting Backdrop for " + artist.Name);
|
Logger.Debug("FanArtProvider getting Backdrop for " + artist.Name);
|
||||||
try
|
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++;
|
numBackdrops++;
|
||||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||||
}
|
}
|
||||||
@ -203,7 +206,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
Logger.Debug("FanArtProvider getting ClearArt for " + artist.Name);
|
Logger.Debug("FanArtProvider getting ClearArt for " + artist.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -226,7 +229,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
Logger.Debug("FanArtProvider getting Banner for " + artist.Name);
|
Logger.Debug("FanArtProvider getting Banner for " + artist.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -250,7 +253,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
Logger.Debug("FanArtProvider getting Primary image for " + artist.Name);
|
Logger.Debug("FanArtProvider getting Primary image for " + artist.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,12 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
{
|
{
|
||||||
private static readonly Task<string> BlankId = Task.FromResult("0000");
|
private static readonly Task<string> 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)
|
: base(jsonSerializer, httpClient, logManager, configurationManager)
|
||||||
{
|
{
|
||||||
|
_providerManager = providerManager;
|
||||||
LocalMetaFileName = LastfmHelper.LocalAlbumMetaFileName;
|
LocalMetaFileName = LastfmHelper.LocalAlbumMetaFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,12 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
{
|
{
|
||||||
public class LastfmArtistProvider : LastfmBaseProvider
|
public class LastfmArtistProvider : LastfmBaseProvider
|
||||||
{
|
{
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(jsonSerializer, httpClient, logManager, configurationManager)
|
: base(jsonSerializer, httpClient, logManager, configurationManager)
|
||||||
{
|
{
|
||||||
|
_providerManager = providerManager;
|
||||||
LocalMetaFileName = LastfmHelper.LocalArtistMetaFileName;
|
LocalMetaFileName = LastfmHelper.LocalArtistMetaFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token</param>
|
/// <param name="cancellationToken">The cancellation token</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (item.DontFetchMeta)
|
if (item.DontFetchMeta)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,17 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
return !string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.SortName);
|
return !string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.SortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache these since they will be used a lot
|
||||||
|
/// <summary>
|
||||||
|
/// The false task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -56,7 +67,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return SetSortName(item, cancellationToken) ? TrueTaskResult : FalseTaskResult;
|
return SetSortName(item, cancellationToken) ? TrueTaskResult : FalseTaskResult;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,7 +62,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() => Fetch(item, cancellationToken));
|
return Task.Run(() => Fetch(item, cancellationToken));
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <value>The HTTP client.</value>
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
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)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (httpClient == null)
|
if (httpClient == null)
|
||||||
@ -33,6 +35,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
throw new ArgumentNullException("httpClient");
|
throw new ArgumentNullException("httpClient");
|
||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Supports(BaseItem item)
|
public override bool Supports(BaseItem item)
|
||||||
@ -53,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
|| (!thumbExists && ConfigurationManager.Configuration.DownloadSeriesImages.Thumb);
|
|| (!thumbExists && ConfigurationManager.Configuration.DownloadSeriesImages.Thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -90,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
|
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -114,7 +117,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
|
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -138,7 +141,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
|
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class RemoteEpisodeProvider : BaseMetadataProvider
|
class RemoteEpisodeProvider : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the HTTP client.
|
/// Gets the HTTP client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,10 +36,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="httpClient">The HTTP client.</param>
|
/// <param name="httpClient">The HTTP client.</param>
|
||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -117,7 +120,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -229,7 +232,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
|
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -282,7 +285,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
doc.Save(ms);
|
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;
|
return true;
|
||||||
|
@ -26,7 +26,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <value>The HTTP client.</value>
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
protected IHttpClient HttpClient { get; private set; }
|
||||||
|
|
||||||
public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
|
public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (httpClient == null)
|
if (httpClient == null)
|
||||||
@ -34,6 +36,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
throw new ArgumentNullException("httpClient");
|
throw new ArgumentNullException("httpClient");
|
||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -97,7 +100,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -174,7 +177,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (n != null)
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -197,8 +200,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var bannerImagePath =
|
var bannerImagePath =
|
||||||
await
|
await _providerManager.DownloadAndSaveImage(season,
|
||||||
Kernel.Instance.ProviderManager.DownloadAndSaveImage(season,
|
|
||||||
TVUtils.BannerUrl + n.InnerText,
|
TVUtils.BannerUrl + n.InnerText,
|
||||||
"banner" +
|
"banner" +
|
||||||
Path.GetExtension(n.InnerText),
|
Path.GetExtension(n.InnerText),
|
||||||
@ -229,7 +231,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List<string>();
|
if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List<string>();
|
||||||
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -257,8 +259,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
season.BackdropImagePaths.Add(
|
season.BackdropImagePaths.Add(
|
||||||
await
|
await _providerManager.DownloadAndSaveImage(season,
|
||||||
Kernel.Instance.ProviderManager.DownloadAndSaveImage(season,
|
|
||||||
TVUtils.BannerUrl +
|
TVUtils.BannerUrl +
|
||||||
n.InnerText,
|
n.InnerText,
|
||||||
"backdrop" +
|
"backdrop" +
|
||||||
|
@ -22,8 +22,10 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class RemoteSeriesProvider
|
/// Class RemoteSeriesProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class RemoteSeriesProvider : BaseMetadataProvider
|
class RemoteSeriesProvider : BaseMetadataProvider, IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The tv db
|
/// The tv db
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -44,7 +46,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
/// <param name="configurationManager">The configuration manager.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
||||||
public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (httpClient == null)
|
if (httpClient == null)
|
||||||
@ -52,6 +54,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
throw new ArgumentNullException("httpClient");
|
throw new ArgumentNullException("httpClient");
|
||||||
}
|
}
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
_providerManager = providerManager;
|
||||||
Current = this;
|
Current = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +62,12 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
TvDbResourcePool.Dispose();
|
TvDbResourcePool.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(dispose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -149,7 +151,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -253,7 +255,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
doc.Save(ms);
|
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
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -389,7 +391,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
{
|
{
|
||||||
try
|
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);
|
series.SetImage(ImageType.Banner, bannerImagePath);
|
||||||
}
|
}
|
||||||
@ -418,7 +420,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
{
|
{
|
||||||
try
|
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)
|
catch (HttpException)
|
||||||
{
|
{
|
||||||
@ -584,7 +586,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
return name.Trim();
|
return name.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
protected override Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() => Fetch(item, cancellationToken));
|
return Task.Run(() => Fetch(item, cancellationToken));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.ScheduledTasks;
|
using MediaBrowser.Controller.ScheduledTasks;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
@ -12,35 +13,35 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.IO
|
namespace MediaBrowser.Server.Implementations.IO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class DirectoryWatchers
|
/// Class DirectoryWatchers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DirectoryWatchers : IDisposable
|
public class DirectoryWatchers : IDirectoryWatchers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file system watchers
|
/// The file system watchers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ConcurrentBag<FileSystemWatcher> FileSystemWatchers = new ConcurrentBag<FileSystemWatcher>();
|
private ConcurrentBag<FileSystemWatcher> _fileSystemWatchers = new ConcurrentBag<FileSystemWatcher>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The update timer
|
/// The update timer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Timer updateTimer;
|
private Timer _updateTimer;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The affected paths
|
/// The affected paths
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<string, string> affectedPaths = new ConcurrentDictionary<string, string>();
|
private readonly ConcurrentDictionary<string, string> _affectedPaths = new ConcurrentDictionary<string, string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dynamic list of paths that should be ignored. Added to during our own file sytem modifications.
|
/// A dynamic list of paths that should be ignored. Added to during our own file sytem modifications.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<string,string> TempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
private readonly ConcurrentDictionary<string,string> _tempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The timer lock
|
/// The timer lock
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly object timerLock = new object();
|
private readonly object _timerLock = new object();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
|
/// 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
|
|||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
public void TemporarilyIgnore(string path)
|
public void TemporarilyIgnore(string path)
|
||||||
{
|
{
|
||||||
TempIgnoredPaths[path] = path;
|
_tempIgnoredPaths[path] = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,7 +59,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
public void RemoveTempIgnore(string path)
|
public void RemoveTempIgnore(string path)
|
||||||
{
|
{
|
||||||
string val;
|
string val;
|
||||||
TempIgnoredPaths.TryRemove(path, out val);
|
_tempIgnoredPaths.TryRemove(path, out val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -95,7 +96,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts this instance.
|
/// Starts this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
LibraryManager.LibraryChanged += Instance_LibraryChanged;
|
LibraryManager.LibraryChanged += Instance_LibraryChanged;
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
newWatcher.EnableRaisingEvents = true;
|
newWatcher.EnableRaisingEvents = true;
|
||||||
FileSystemWatchers.Add(newWatcher);
|
_fileSystemWatchers.Add(newWatcher);
|
||||||
|
|
||||||
Logger.Info("Watching directory " + path);
|
Logger.Info("Watching directory " + path);
|
||||||
}
|
}
|
||||||
@ -199,7 +200,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
private void StopWatchingPath(string 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)
|
if (watcher != null)
|
||||||
{
|
{
|
||||||
@ -218,18 +219,18 @@ namespace MediaBrowser.Controller.IO
|
|||||||
watcher.EnableRaisingEvents = false;
|
watcher.EnableRaisingEvents = false;
|
||||||
watcher.Dispose();
|
watcher.Dispose();
|
||||||
|
|
||||||
var watchers = FileSystemWatchers.ToList();
|
var watchers = _fileSystemWatchers.ToList();
|
||||||
|
|
||||||
watchers.Remove(watcher);
|
watchers.Remove(watcher);
|
||||||
|
|
||||||
FileSystemWatchers = new ConcurrentBag<FileSystemWatcher>(watchers);
|
_fileSystemWatchers = new ConcurrentBag<FileSystemWatcher>(watchers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the LibraryChanged event of the Kernel
|
/// Handles the LibraryChanged event of the Kernel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender">The source of the event.</param>
|
/// <param name="sender">The source of the event.</param>
|
||||||
/// <param name="e">The <see cref="Library.ChildrenChangedEventArgs" /> instance containing the event data.</param>
|
/// <param name="e">The <see cref="MediaBrowser.Controller.Library.ChildrenChangedEventArgs" /> instance containing the event data.</param>
|
||||||
void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e)
|
void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Folder is AggregateFolder && e.HasAddOrRemoveChange)
|
if (e.Folder is AggregateFolder && e.HasAddOrRemoveChange)
|
||||||
@ -316,7 +317,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TempIgnoredPaths.ContainsKey(e.FullPath))
|
if (_tempIgnoredPaths.ContainsKey(e.FullPath))
|
||||||
{
|
{
|
||||||
Logger.Info("Watcher requested to ignore change to " + e.FullPath);
|
Logger.Info("Watcher requested to ignore change to " + e.FullPath);
|
||||||
return;
|
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
|
//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;
|
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
|
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
|
|||||||
/// <param name="stateInfo">The state info.</param>
|
/// <param name="stateInfo">The state info.</param>
|
||||||
private async void TimerStopped(object stateInfo)
|
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.
|
// 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.");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info("Timer stopped.");
|
Logger.Info("Timer stopped.");
|
||||||
|
|
||||||
updateTimer.Dispose();
|
_updateTimer.Dispose();
|
||||||
updateTimer = null;
|
_updateTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = affectedPaths.Keys.ToList();
|
var paths = _affectedPaths.Keys.ToList();
|
||||||
affectedPaths.Clear();
|
_affectedPaths.Clear();
|
||||||
|
|
||||||
await ProcessPathChanges(paths).ConfigureAwait(false);
|
await ProcessPathChanges(paths).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -493,29 +494,29 @@ namespace MediaBrowser.Controller.IO
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops this instance.
|
/// Stops this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
LibraryManager.LibraryChanged -= Instance_LibraryChanged;
|
LibraryManager.LibraryChanged -= Instance_LibraryChanged;
|
||||||
|
|
||||||
FileSystemWatcher watcher;
|
FileSystemWatcher watcher;
|
||||||
|
|
||||||
while (FileSystemWatchers.TryTake(out watcher))
|
while (_fileSystemWatchers.TryTake(out watcher))
|
||||||
{
|
{
|
||||||
watcher.Changed -= watcher_Changed;
|
watcher.Changed -= watcher_Changed;
|
||||||
watcher.EnableRaisingEvents = false;
|
watcher.EnableRaisingEvents = false;
|
||||||
watcher.Dispose();
|
watcher.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (timerLock)
|
lock (_timerLock)
|
||||||
{
|
{
|
||||||
if (updateTimer != null)
|
if (_updateTimer != null)
|
||||||
{
|
{
|
||||||
updateTimer.Dispose();
|
_updateTimer.Dispose();
|
||||||
updateTimer = null;
|
_updateTimer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
affectedPaths.Clear();
|
_affectedPaths.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
@ -111,6 +111,7 @@
|
|||||||
<Compile Include="HttpServer\ServerFactory.cs" />
|
<Compile Include="HttpServer\ServerFactory.cs" />
|
||||||
<Compile Include="HttpServer\StreamWriter.cs" />
|
<Compile Include="HttpServer\StreamWriter.cs" />
|
||||||
<Compile Include="HttpServer\SwaggerService.cs" />
|
<Compile Include="HttpServer\SwaggerService.cs" />
|
||||||
|
<Compile Include="IO\DirectoryWatchers.cs" />
|
||||||
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
|
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
|
||||||
<Compile Include="Library\LibraryManager.cs" />
|
<Compile Include="Library\LibraryManager.cs" />
|
||||||
<Compile Include="Library\ResolverHelper.cs" />
|
<Compile Include="Library\ResolverHelper.cs" />
|
||||||
@ -128,6 +129,7 @@
|
|||||||
<Compile Include="Library\Resolvers\VideoResolver.cs" />
|
<Compile Include="Library\Resolvers\VideoResolver.cs" />
|
||||||
<Compile Include="Library\UserManager.cs" />
|
<Compile Include="Library\UserManager.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Providers\ProviderManager.cs" />
|
||||||
<Compile Include="Reflection\TypeMapper.cs" />
|
<Compile Include="Reflection\TypeMapper.cs" />
|
||||||
<Compile Include="ScheduledTasks\PeopleValidationTask.cs" />
|
<Compile Include="ScheduledTasks\PeopleValidationTask.cs" />
|
||||||
<Compile Include="ScheduledTasks\ChapterImagesTask.cs" />
|
<Compile Include="ScheduledTasks\ChapterImagesTask.cs" />
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Extensions;
|
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@ -13,12 +15,12 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Server.Implementations.Providers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class ProviderManager
|
/// Class ProviderManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProviderManager : IDisposable
|
public class ProviderManager : IProviderManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The remote image cache
|
/// The remote image cache
|
||||||
@ -41,23 +43,37 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _directory watchers
|
||||||
|
/// </summary>
|
||||||
|
private readonly IDirectoryWatchers _directoryWatchers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the configuration manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The configuration manager.</value>
|
||||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||||
|
|
||||||
private Kernel Kernel { get; set; }
|
/// <summary>
|
||||||
|
/// Gets the list of currently registered metadata prvoiders
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The metadata providers enumerable.</value>
|
||||||
|
private BaseMetadataProvider[] MetadataProviders { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
|
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kernel">The kernel.</param>
|
|
||||||
/// <param name="httpClient">The HTTP client.</param>
|
/// <param name="httpClient">The HTTP client.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger, IServerConfigurationManager configurationManager)
|
/// <param name="directoryWatchers">The directory watchers.</param>
|
||||||
|
/// <param name="logManager">The log manager.</param>
|
||||||
|
public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, IDirectoryWatchers directoryWatchers, ILogManager logManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logManager.GetLogger("ProviderManager");
|
||||||
Kernel = kernel;
|
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
ConfigurationManager = configurationManager;
|
ConfigurationManager = configurationManager;
|
||||||
_remoteImageCache = new FileSystemRepository(ImagesDataPath);
|
_directoryWatchers = directoryWatchers;
|
||||||
|
_remoteImageCache = new FileSystemRepository(configurationManager.ApplicationPaths.DownloadedImagesDataPath);
|
||||||
|
|
||||||
configurationManager.ConfigurationUpdated += configurationManager_ConfigurationUpdated;
|
configurationManager.ConfigurationUpdated += configurationManager_ConfigurationUpdated;
|
||||||
}
|
}
|
||||||
@ -76,38 +92,21 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The _images data path
|
|
||||||
/// </summary>
|
|
||||||
private string _imagesDataPath;
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the images data path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The images data path.</value>
|
|
||||||
public string ImagesDataPath
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_imagesDataPath == null)
|
|
||||||
{
|
|
||||||
_imagesDataPath = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "remote-images");
|
|
||||||
|
|
||||||
if (!Directory.Exists(_imagesDataPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(_imagesDataPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _imagesDataPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the supported providers key.
|
/// Gets or sets the supported providers key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The supported providers key.</value>
|
/// <value>The supported providers key.</value>
|
||||||
private Guid SupportedProvidersKey { get; set; }
|
private Guid SupportedProvidersKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the metadata providers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="providers">The providers.</param>
|
||||||
|
public void AddMetadataProviders(IEnumerable<BaseMetadataProvider> providers)
|
||||||
|
{
|
||||||
|
MetadataProviders = providers.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs all metadata providers for an entity, and returns true or false indicating if at least one was refreshed and requires persistence
|
/// Runs all metadata providers for an entity, and returns true or false indicating if at least one was refreshed and requires persistence
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -116,7 +115,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
internal async Task<bool> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true)
|
public async Task<bool> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true)
|
||||||
{
|
{
|
||||||
// Allow providers of the same priority to execute in parallel
|
// Allow providers of the same priority to execute in parallel
|
||||||
MetadataProviderPriority? currentPriority = null;
|
MetadataProviderPriority? currentPriority = null;
|
||||||
@ -127,7 +126,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
// Determine if supported providers have changed
|
// 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;
|
BaseProviderInfo supportedProvidersInfo;
|
||||||
|
|
||||||
@ -201,7 +200,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTasks.Add(provider.FetchAsync(item, force, cancellationToken));
|
currentTasks.Add(FetchAsync(provider, item, force, cancellationToken));
|
||||||
currentPriority = provider.Priority;
|
currentPriority = provider.Priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,13 +218,69 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
return result || providersChanged;
|
return result || providersChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="provider">The provider.</param>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
|
private async Task<bool> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Notifies the kernal that a provider has begun refreshing
|
/// Notifies the kernal that a provider has begun refreshing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="provider">The provider.</param>
|
/// <param name="provider">The provider.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="cancellationTokenSource">The cancellation token source.</param>
|
/// <param name="cancellationTokenSource">The cancellation token source.</param>
|
||||||
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;
|
var key = item.Id + provider.GetType().Name;
|
||||||
|
|
||||||
@ -253,7 +308,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="provider">The provider.</param>
|
/// <param name="provider">The provider.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
internal void OnProviderRefreshCompleted(BaseMetadataProvider provider, BaseItem item)
|
public void OnProviderRefreshCompleted(BaseMetadataProvider provider, BaseItem item)
|
||||||
{
|
{
|
||||||
var key = item.Id + provider.GetType().Name;
|
var key = item.Id + provider.GetType().Name;
|
||||||
|
|
||||||
@ -268,7 +323,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the currently running providers and cancels any that should not be run due to configuration changes
|
/// Validates the currently running providers and cancels any that should not be run due to configuration changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void ValidateCurrentlyRunningProviders()
|
private void ValidateCurrentlyRunningProviders()
|
||||||
{
|
{
|
||||||
_logger.Info("Validing currently running providers");
|
_logger.Info("Validing currently running providers");
|
||||||
|
|
||||||
@ -321,7 +376,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
if (ConfigurationManager.Configuration.SaveLocalMeta) // queue to media directories
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -352,6 +407,63 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
return localPath;
|
return localPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves to library filesystem.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <param name="dataToSave">The data to save.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -364,6 +476,9 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
@ -27,17 +27,21 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ImageCleanupTask" /> class.
|
/// Initializes a new instance of the <see cref="ImageCleanupTask" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kernel">The kernel.</param>
|
/// <param name="kernel">The kernel.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
public ImageCleanupTask(Kernel kernel, ILogger logger, ILibraryManager libraryManager)
|
/// <param name="libraryManager">The library manager.</param>
|
||||||
|
/// <param name="appPaths">The app paths.</param>
|
||||||
|
public ImageCleanupTask(Kernel kernel, ILogger logger, ILibraryManager libraryManager, IServerApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
|
_appPaths = appPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -65,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||||||
// First gather all image files
|
// First gather all image files
|
||||||
var files = GetFiles(_kernel.FFMpegManager.AudioImagesDataPath)
|
var files = GetFiles(_kernel.FFMpegManager.AudioImagesDataPath)
|
||||||
.Concat(GetFiles(_kernel.FFMpegManager.VideoImagesDataPath))
|
.Concat(GetFiles(_kernel.FFMpegManager.VideoImagesDataPath))
|
||||||
.Concat(GetFiles(_kernel.ProviderManager.ImagesDataPath))
|
.Concat(GetFiles(_appPaths.DownloadedImagesDataPath))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Now gather all items
|
// Now gather all items
|
||||||
|
@ -302,7 +302,7 @@ namespace MediaBrowser.Server.Implementations
|
|||||||
/// Gets the FF MPEG stream cache path.
|
/// Gets the FF MPEG stream cache path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The FF MPEG stream cache path.</value>
|
/// <value>The FF MPEG stream cache path.</value>
|
||||||
public string FFMpegStreamCachePath
|
public string EncodedMediaCachePath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -345,5 +345,31 @@ namespace MediaBrowser.Server.Implementations
|
|||||||
return _mediaToolsPath;
|
return _mediaToolsPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _images data path
|
||||||
|
/// </summary>
|
||||||
|
private string _downloadedImagesDataPath;
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the images data path.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The images data path.</value>
|
||||||
|
public string DownloadedImagesDataPath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_downloadedImagesDataPath == null)
|
||||||
|
{
|
||||||
|
_downloadedImagesDataPath = Path.Combine(DataPath, "remote-images");
|
||||||
|
|
||||||
|
if (!Directory.Exists(_downloadedImagesDataPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_downloadedImagesDataPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _downloadedImagesDataPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.ServerManager
|
|||||||
/// <value>The web socket listeners.</value>
|
/// <value>The web socket listeners.</value>
|
||||||
private readonly List<IWebSocketListener> _webSocketListeners = new List<IWebSocketListener>();
|
private readonly List<IWebSocketListener> _webSocketListeners = new List<IWebSocketListener>();
|
||||||
|
|
||||||
private Kernel _kernel;
|
private readonly Kernel _kernel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerManager" /> class.
|
/// Initializes a new instance of the <see cref="ServerManager" /> class.
|
||||||
|
@ -156,13 +156,13 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
CompositionRoot = new ApplicationHost();
|
CompositionRoot = new ApplicationHost();
|
||||||
|
|
||||||
var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager);
|
|
||||||
|
|
||||||
Logger = CompositionRoot.LogManager.GetLogger("App");
|
Logger = CompositionRoot.LogManager.GetLogger("App");
|
||||||
|
|
||||||
win.Show();
|
|
||||||
|
|
||||||
await CompositionRoot.Init();
|
await CompositionRoot.Init();
|
||||||
|
|
||||||
|
var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager, CompositionRoot.UserManager, CompositionRoot.LibraryManager, CompositionRoot.JsonSerializer);
|
||||||
|
|
||||||
|
win.Show();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -2,18 +2,24 @@
|
|||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Constants;
|
using MediaBrowser.Common.Constants;
|
||||||
using MediaBrowser.Common.Events;
|
|
||||||
using MediaBrowser.Common.Implementations;
|
using MediaBrowser.Common.Implementations;
|
||||||
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Common.Updates;
|
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
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.Resolvers;
|
||||||
using MediaBrowser.Controller.Updates;
|
using MediaBrowser.Controller.Updates;
|
||||||
|
using MediaBrowser.Controller.Weather;
|
||||||
using MediaBrowser.IsoMounter;
|
using MediaBrowser.IsoMounter;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
@ -23,7 +29,9 @@ using MediaBrowser.Server.Implementations;
|
|||||||
using MediaBrowser.Server.Implementations.BdInfo;
|
using MediaBrowser.Server.Implementations.BdInfo;
|
||||||
using MediaBrowser.Server.Implementations.Configuration;
|
using MediaBrowser.Server.Implementations.Configuration;
|
||||||
using MediaBrowser.Server.Implementations.HttpServer;
|
using MediaBrowser.Server.Implementations.HttpServer;
|
||||||
|
using MediaBrowser.Server.Implementations.IO;
|
||||||
using MediaBrowser.Server.Implementations.Library;
|
using MediaBrowser.Server.Implementations.Library;
|
||||||
|
using MediaBrowser.Server.Implementations.Providers;
|
||||||
using MediaBrowser.Server.Implementations.ServerManager;
|
using MediaBrowser.Server.Implementations.ServerManager;
|
||||||
using MediaBrowser.Server.Implementations.Udp;
|
using MediaBrowser.Server.Implementations.Udp;
|
||||||
using MediaBrowser.Server.Implementations.Updates;
|
using MediaBrowser.Server.Implementations.Updates;
|
||||||
@ -78,22 +86,72 @@ namespace MediaBrowser.ServerApplication
|
|||||||
return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
|
return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the installation manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The installation manager.</value>
|
||||||
private IInstallationManager InstallationManager { get; set; }
|
private IInstallationManager InstallationManager { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the server manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The server manager.</value>
|
||||||
private IServerManager ServerManager { get; set; }
|
private IServerManager ServerManager { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the user manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The user manager.</value>
|
||||||
|
public IUserManager UserManager { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the library manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The library manager.</value>
|
||||||
|
internal ILibraryManager LibraryManager { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the directory watchers.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The directory watchers.</value>
|
||||||
|
private IDirectoryWatchers DirectoryWatchers { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the provider manager.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The provider manager.</value>
|
||||||
|
private IProviderManager ProviderManager { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the zip client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The zip client.</value>
|
||||||
|
private IZipClient ZipClient { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP server.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTP server.</value>
|
||||||
|
private IHttpServer HttpServer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inits this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
public override async Task Init()
|
public override async Task Init()
|
||||||
{
|
{
|
||||||
await base.Init().ConfigureAwait(false);
|
await base.Init().ConfigureAwait(false);
|
||||||
|
|
||||||
await ServerKernel.Init().ConfigureAwait(false);
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await ServerKernel.LoadRepositories(ServerConfigurationManager).ConfigureAwait(false);
|
||||||
|
|
||||||
|
DirectoryWatchers.Start();
|
||||||
|
|
||||||
|
Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers resources that classes will depend on
|
/// Registers resources that classes will depend on
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
protected override async Task RegisterResources()
|
protected override async Task RegisterResources()
|
||||||
{
|
{
|
||||||
ServerKernel = new Kernel(this, XmlSerializer, LogManager, ServerConfigurationManager);
|
ServerKernel = new Kernel(ServerConfigurationManager);
|
||||||
|
|
||||||
await base.RegisterResources().ConfigureAwait(false);
|
await base.RegisterResources().ConfigureAwait(false);
|
||||||
|
|
||||||
@ -108,20 +166,66 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
RegisterSingleInstance<IIsoManager>(new PismoIsoManager(Logger));
|
RegisterSingleInstance<IIsoManager>(new PismoIsoManager(Logger));
|
||||||
RegisterSingleInstance<IBlurayExaminer>(new BdInfoExaminer());
|
RegisterSingleInstance<IBlurayExaminer>(new BdInfoExaminer());
|
||||||
RegisterSingleInstance<IZipClient>(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);
|
ServerManager = new ServerManager(this, NetworkManager, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel);
|
||||||
RegisterSingleInstance(ServerManager);
|
RegisterSingleInstance(ServerManager);
|
||||||
|
|
||||||
var userManager = new UserManager(ServerKernel, Logger, ServerConfigurationManager);
|
UserManager = new UserManager(ServerKernel, Logger, ServerConfigurationManager);
|
||||||
|
RegisterSingleInstance(UserManager);
|
||||||
|
|
||||||
RegisterSingleInstance<IUserManager>(userManager);
|
LibraryManager = new LibraryManager(ServerKernel, Logger, TaskManager, UserManager, ServerConfigurationManager);
|
||||||
|
RegisterSingleInstance(LibraryManager);
|
||||||
RegisterSingleInstance<ILibraryManager>(new LibraryManager(ServerKernel, Logger, TaskManager, userManager, ServerConfigurationManager));
|
|
||||||
|
|
||||||
InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
|
InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
|
||||||
RegisterSingleInstance(InstallationManager);
|
RegisterSingleInstance(InstallationManager);
|
||||||
|
|
||||||
|
DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
|
||||||
|
RegisterSingleInstance(DirectoryWatchers);
|
||||||
|
|
||||||
|
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager);
|
||||||
|
RegisterSingleInstance(ProviderManager);
|
||||||
|
|
||||||
|
SetKernelProperties();
|
||||||
|
SetStaticProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the kernel properties.
|
||||||
|
/// </summary>
|
||||||
|
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<IUserDataRepository>();
|
||||||
|
ServerKernel.UserRepositories = GetExports<IUserRepository>();
|
||||||
|
ServerKernel.DisplayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>();
|
||||||
|
ServerKernel.ItemRepositories = GetExports<IItemRepository>();
|
||||||
|
ServerKernel.WeatherProviders = GetExports<IWeatherProvider>();
|
||||||
|
ServerKernel.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray();
|
||||||
|
ServerKernel.StringFiles = GetExports<LocalizedStringData>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dirty hacks
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -131,12 +235,14 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
base.FindParts();
|
base.FindParts();
|
||||||
|
|
||||||
Resolve<IHttpServer>().Init(GetExports<IRestfulService>(false));
|
HttpServer.Init(GetExports<IRestfulService>(false));
|
||||||
Resolve<IServerManager>().AddWebSocketListeners(GetExports<IWebSocketListener>(false));
|
|
||||||
|
|
||||||
Resolve<IServerManager>().Start();
|
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
|
||||||
|
ServerManager.Start();
|
||||||
|
|
||||||
Resolve<ILibraryManager>().AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>());
|
LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>());
|
||||||
|
|
||||||
|
ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().OrderBy(e => e.Priority).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -164,9 +270,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <returns>Task{CheckForUpdateResult}.</returns>
|
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||||
public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
var pkgManager = Resolve<IPackageManager>();
|
var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
||||||
var availablePackages = await pkgManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||||
var version = Resolve<IInstallationManager>().GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
|
||||||
|
|
||||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||||
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
||||||
|
@ -9,7 +9,7 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication.EntryPoints
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class NewItemNotifier
|
/// Class NewItemNotifier
|
@ -0,0 +1,41 @@
|
|||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Plugins;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace MediaBrowser.ServerApplication.EntryPoints
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class RefreshUsersMetadata
|
||||||
|
/// </summary>
|
||||||
|
public class RefreshUsersMetadata : IServerEntryPoint
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The _user manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RefreshUsersMetadata" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userManager">The user manager.</param>
|
||||||
|
public RefreshUsersMetadata(IUserManager userManager)
|
||||||
|
{
|
||||||
|
_userManager = userManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs this instance.
|
||||||
|
/// </summary>
|
||||||
|
public async void Run()
|
||||||
|
{
|
||||||
|
await _userManager.RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using MediaBrowser.Controller.Library;
|
|||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication.EntryPoints
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class StartupWizard
|
/// Class StartupWizard
|
@ -12,7 +12,7 @@ using MediaBrowser.Model.Tasks;
|
|||||||
using MediaBrowser.Model.Updates;
|
using MediaBrowser.Model.Updates;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication.EntryPoints
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class WebSocketEvents
|
/// Class WebSocketEvents
|
@ -4,6 +4,7 @@ using MediaBrowser.Controller.Configuration;
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.ServerApplication.Logging;
|
using MediaBrowser.ServerApplication.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -39,6 +40,10 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
|
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MainWindow" /> class.
|
/// Initializes a new instance of the <see cref="MainWindow" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -46,7 +51,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
/// <param name="appHost">The app host.</param>
|
/// <param name="appHost">The app host.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">logger</exception>
|
/// <exception cref="System.ArgumentNullException">logger</exception>
|
||||||
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)
|
if (logManager == null)
|
||||||
{
|
{
|
||||||
@ -65,6 +70,9 @@ namespace MediaBrowser.ServerApplication
|
|||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_logManager = logManager;
|
_logManager = logManager;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
|
_userManager = userManager;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
|
_jsonSerializer = jsonSerializer;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -209,8 +217,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
||||||
private void cmOpenExplorer_click(object sender, RoutedEventArgs e)
|
private void cmOpenExplorer_click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var explorer = (LibraryExplorer)_appHost.CreateInstance(typeof(LibraryExplorer));
|
new LibraryExplorer(_jsonSerializer, _logger, _appHost, _userManager, _libraryManager).Show();
|
||||||
explorer.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -220,7 +227,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
||||||
private void cmOpenDashboard_click(object sender, RoutedEventArgs e)
|
private void cmOpenDashboard_click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var user = _appHost.Resolve<IUserManager>().Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
|
var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
|
||||||
OpenDashboard(user);
|
OpenDashboard(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +256,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
||||||
private void cmdBrowseLibrary_click(object sender, RoutedEventArgs e)
|
private void cmdBrowseLibrary_click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var user = _appHost.Resolve<IUserManager>().Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
|
var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
|
||||||
App.OpenDashboardPage("index.html", user, _configurationManager);
|
App.OpenDashboardPage("index.html", user, _configurationManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +158,10 @@
|
|||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="NewItemNotifier.cs" />
|
<Compile Include="EntryPoints\NewItemNotifier.cs" />
|
||||||
<Compile Include="StartupWizard.cs" />
|
<Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
|
||||||
<Compile Include="WebSocketEvents.cs" />
|
<Compile Include="EntryPoints\StartupWizard.cs" />
|
||||||
|
<Compile Include="EntryPoints\WebSocketEvents.cs" />
|
||||||
<Page Include="App.xaml">
|
<Page Include="App.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@ -406,6 +407,6 @@ del "$(SolutionDir)..\Deploy\MBServer.zip"
|
|||||||
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
|
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
|
||||||
<Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
|
<Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
|
||||||
</GetAssemblyIdentity>
|
</GetAssemblyIdentity>
|
||||||
<Exec Command="copy $(SolutionDir)..\Deploy\MBServer.zip $(SolutionDir)..\Deploy\MBServer_%(CurrentAssembly.Version).zip /y" Condition="'$(ConfigurationName)' == 'Release'"/>
|
<Exec Command="copy $(SolutionDir)..\Deploy\MBServer.zip $(SolutionDir)..\Deploy\MBServer_%(CurrentAssembly.Version).zip /y" Condition="'$(ConfigurationName)' == 'Release'" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
@ -237,4 +237,7 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user