mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts: MediaBrowser.Controller/Providers/FanartBaseProvider.cs MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IServerConfigurationManager
|
||||
/// </summary>
|
||||
public interface IServerConfigurationManager : IConfigurationManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the application paths.
|
||||
/// </summary>
|
||||
/// <value>The application paths.</value>
|
||||
IServerApplicationPaths ApplicationPaths { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration.
|
||||
/// </summary>
|
||||
/// <value>The configuration.</value>
|
||||
ServerConfiguration Configuration { get; }
|
||||
}
|
||||
}
|
||||
@@ -66,23 +66,23 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// The _kernel
|
||||
/// </summary>
|
||||
private readonly Kernel _kernel;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ImageManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="protobufSerializer">The protobuf serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ImageManager(Kernel kernel, IProtobufSerializer protobufSerializer, ILogger logger)
|
||||
public ImageManager(Kernel kernel, IProtobufSerializer protobufSerializer, ILogger logger, IServerApplicationPaths appPaths)
|
||||
{
|
||||
_protobufSerializer = protobufSerializer;
|
||||
_logger = logger;
|
||||
_kernel = kernel;
|
||||
|
||||
ImageSizeCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "image-sizes"));
|
||||
ResizedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "resized-images"));
|
||||
CroppedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "cropped-images"));
|
||||
EnhancedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "enhanced-images"));
|
||||
ImageSizeCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "image-sizes"));
|
||||
ResizedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "resized-images"));
|
||||
CroppedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "cropped-images"));
|
||||
EnhancedImageCache = new FileSystemRepository(Path.Combine(appPaths.ImageCachePath, "enhanced-images"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
@@ -96,6 +98,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
protected static internal ILogger Logger { get; internal set; }
|
||||
protected static internal ILibraryManager LibraryManager { get; internal set; }
|
||||
protected static internal IServerConfigurationManager ConfigurationManager { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||
@@ -311,7 +314,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
// non file-system entries will not have a path
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return new ItemResolveArgs
|
||||
return new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
|
||||
{
|
||||
FileInfo = new WIN32_FIND_DATA()
|
||||
};
|
||||
@@ -329,7 +332,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
throw new IOException("Unable to retrieve file system info for " + path);
|
||||
}
|
||||
|
||||
var args = new ItemResolveArgs
|
||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
|
||||
{
|
||||
FileInfo = pathInfo.Value,
|
||||
Path = path,
|
||||
@@ -997,7 +1000,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
return (DateTime.UtcNow - DateCreated).TotalDays < Kernel.Instance.Configuration.RecentItemDays;
|
||||
return (DateTime.UtcNow - DateCreated).TotalDays < ConfigurationManager.Configuration.RecentItemDays;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1020,7 +1023,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
return (DateTime.UtcNow - data.LastPlayedDate.Value).TotalDays < Kernel.Instance.Configuration.RecentlyPlayedDays;
|
||||
return (DateTime.UtcNow - data.LastPlayedDate.Value).TotalDays < ConfigurationManager.Configuration.RecentlyPlayedDays;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
@@ -18,6 +19,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
public class User : BaseItem
|
||||
{
|
||||
internal static IUserManager UserManager { get; set; }
|
||||
internal static IXmlSerializer XmlSerializer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _root folder path
|
||||
@@ -45,7 +47,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootFolderPath = Kernel.Instance.ApplicationPaths.DefaultUserViewsPath;
|
||||
_rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
}
|
||||
}
|
||||
return _rootFolderPath;
|
||||
@@ -61,7 +63,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
var safeFolderName = FileSystem.GetValidFilename(username);
|
||||
|
||||
return System.IO.Path.Combine(Kernel.Instance.ApplicationPaths.RootFolderPath, safeFolderName);
|
||||
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.RootFolderPath, safeFolderName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -171,7 +173,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
get
|
||||
{
|
||||
// Lazy load
|
||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)Kernel.Instance.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath));
|
||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)ConfigurationHelper.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath, XmlSerializer));
|
||||
return _configuration;
|
||||
}
|
||||
private set
|
||||
@@ -321,7 +323,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
var safeFolderName = FileSystem.GetValidFilename(username);
|
||||
|
||||
return System.IO.Path.Combine(Kernel.Instance.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
|
||||
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -411,7 +413,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
var userPath = RootFolderPath;
|
||||
|
||||
var defaultPath = Kernel.Instance.ApplicationPaths.DefaultUserViewsPath;
|
||||
var defaultPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
|
||||
if (userPath.Equals(defaultPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.ScheduledTasks;
|
||||
@@ -74,16 +74,13 @@ namespace MediaBrowser.Controller.IO
|
||||
private ITaskManager TaskManager { get; set; }
|
||||
|
||||
private ILibraryManager LibraryManager { get; set; }
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectoryWatchers" /> class.
|
||||
/// </summary>
|
||||
public DirectoryWatchers(ILogger logger, ITaskManager taskManager, ILibraryManager libraryManager)
|
||||
public DirectoryWatchers(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
throw new ArgumentNullException("logger");
|
||||
}
|
||||
if (taskManager == null)
|
||||
{
|
||||
throw new ArgumentNullException("taskManager");
|
||||
@@ -91,7 +88,8 @@ namespace MediaBrowser.Controller.IO
|
||||
|
||||
LibraryManager = libraryManager;
|
||||
TaskManager = taskManager;
|
||||
Logger = logger;
|
||||
Logger = logManager.GetLogger("DirectoryWatchers");
|
||||
ConfigurationManager = configurationManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -335,11 +333,11 @@ namespace MediaBrowser.Controller.IO
|
||||
{
|
||||
if (updateTimer == null)
|
||||
{
|
||||
updateTimer = new Timer(TimerStopped, null, TimeSpan.FromSeconds(Kernel.Instance.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
updateTimer = new Timer(TimerStopped, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
updateTimer.Change(TimeSpan.FromSeconds(Kernel.Instance.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,7 +354,7 @@ namespace MediaBrowser.Controller.IO
|
||||
if (affectedPaths.Any(p => IsFileLocked(p.Key)))
|
||||
{
|
||||
Logger.Info("Timer extended.");
|
||||
updateTimer.Change(TimeSpan.FromSeconds(Kernel.Instance.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
updateTimer.Change(TimeSpan.FromSeconds(ConfigurationManager.Configuration.FileWatcherDelay), TimeSpan.FromMilliseconds(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -33,14 +34,15 @@ namespace MediaBrowser.Controller.IO
|
||||
/// Initializes a new instance of the <see cref="FileSystemManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public FileSystemManager(Kernel kernel, ILogger logger, ITaskManager taskManager, ILibraryManager libraryManager)
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public FileSystemManager(Kernel kernel, ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
||||
: base(kernel)
|
||||
{
|
||||
_logger = logger;
|
||||
DirectoryWatchers = new DirectoryWatchers(logger, taskManager, libraryManager);
|
||||
_logger = logManager.GetLogger("FileSystemManager");
|
||||
DirectoryWatchers = new DirectoryWatchers(logManager, taskManager, libraryManager, configurationManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
|
||||
namespace MediaBrowser.Controller
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
@@ -11,7 +13,6 @@ using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
using MediaBrowser.Controller.Weather;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.System;
|
||||
@@ -26,7 +27,7 @@ namespace MediaBrowser.Controller
|
||||
/// <summary>
|
||||
/// Class Kernel
|
||||
/// </summary>
|
||||
public class Kernel : BaseKernel<ServerConfiguration, IServerApplicationPaths>
|
||||
public class Kernel : BaseKernel, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
@@ -161,23 +162,34 @@ namespace MediaBrowser.Controller
|
||||
get { return 7359; }
|
||||
}
|
||||
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly ILogManager _logManager;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a kernel based on a Data path, which is akin to our current programdata path
|
||||
/// </summary>
|
||||
/// <param name="appHost">The app host.</param>
|
||||
/// <param name="appPaths">The app paths.</param>
|
||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">isoManager</exception>
|
||||
public Kernel(IApplicationHost appHost, IServerApplicationPaths appPaths, IXmlSerializer xmlSerializer, ILogger logger)
|
||||
: base(appHost, appPaths, xmlSerializer, logger)
|
||||
public Kernel(IApplicationHost appHost, IXmlSerializer xmlSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(appHost, logManager, configurationManager)
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
// For now there's no real way to inject this properly
|
||||
BaseItem.Logger = logger;
|
||||
Ratings.Logger = logger;
|
||||
LocalizedStrings.Logger = logger;
|
||||
_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>
|
||||
@@ -185,14 +197,13 @@ namespace MediaBrowser.Controller
|
||||
/// </summary>
|
||||
protected void FindParts()
|
||||
{
|
||||
// For now there's no real way to inject this properly
|
||||
// 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));
|
||||
SecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager));
|
||||
|
||||
UserDataRepositories = ApplicationHost.GetExports<IUserDataRepository>();
|
||||
UserRepositories = ApplicationHost.GetExports<IUserRepository>();
|
||||
@@ -217,8 +228,6 @@ namespace MediaBrowser.Controller
|
||||
|
||||
await LoadRepositories().ConfigureAwait(false);
|
||||
|
||||
ReloadResourcePools();
|
||||
|
||||
await ApplicationHost.Resolve<IUserManager>().RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
foreach (var entryPoint in ApplicationHost.GetExports<IServerEntryPoint>())
|
||||
@@ -229,41 +238,25 @@ namespace MediaBrowser.Controller
|
||||
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 override void Dispose(bool dispose)
|
||||
protected virtual void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
DisposeResourcePools();
|
||||
|
||||
DisposeFileSystemManager();
|
||||
}
|
||||
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the resource pools.
|
||||
/// </summary>
|
||||
private void DisposeResourcePools()
|
||||
{
|
||||
if (ResourcePools != null)
|
||||
{
|
||||
ResourcePools.Dispose();
|
||||
ResourcePools = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the resource pools.
|
||||
/// </summary>
|
||||
private void ReloadResourcePools()
|
||||
{
|
||||
DisposeResourcePools();
|
||||
ResourcePools = new ResourcePool();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -273,19 +266,19 @@ namespace MediaBrowser.Controller
|
||||
protected Task LoadRepositories()
|
||||
{
|
||||
// Get the current item repository
|
||||
ItemRepository = GetRepository(ItemRepositories, Configuration.ItemRepository);
|
||||
ItemRepository = GetRepository(ItemRepositories, _configurationManager.Configuration.ItemRepository);
|
||||
var itemRepoTask = ItemRepository.Initialize();
|
||||
|
||||
// Get the current user repository
|
||||
UserRepository = GetRepository(UserRepositories, Configuration.UserRepository);
|
||||
UserRepository = GetRepository(UserRepositories, _configurationManager.Configuration.UserRepository);
|
||||
var userRepoTask = UserRepository.Initialize();
|
||||
|
||||
// Get the current item repository
|
||||
UserDataRepository = GetRepository(UserDataRepositories, Configuration.UserDataRepository);
|
||||
UserDataRepository = GetRepository(UserDataRepositories, _configurationManager.Configuration.UserDataRepository);
|
||||
var userDataRepoTask = UserDataRepository.Initialize();
|
||||
|
||||
// Get the current display preferences repository
|
||||
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, Configuration.DisplayPreferencesRepository);
|
||||
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, _configurationManager.Configuration.DisplayPreferencesRepository);
|
||||
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
|
||||
|
||||
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
|
||||
@@ -326,26 +319,10 @@ namespace MediaBrowser.Controller
|
||||
{
|
||||
DisposeFileSystemManager();
|
||||
|
||||
FileSystemManager = new FileSystemManager(this, Logger, ApplicationHost.Resolve<ITaskManager>(), ApplicationHost.Resolve<ILibraryManager>());
|
||||
FileSystemManager = new FileSystemManager(this, _logManager, ApplicationHost.Resolve<ITaskManager>(), ApplicationHost.Resolve<ILibraryManager>(), _configurationManager);
|
||||
FileSystemManager.StartWatchers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Completely overwrites the current configuration with a new copy
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
public void UpdateConfiguration(ServerConfiguration config)
|
||||
{
|
||||
Configuration = config;
|
||||
SaveConfiguration();
|
||||
|
||||
// Validate currently executing providers, in the background
|
||||
Task.Run(() =>
|
||||
{
|
||||
ProviderManager.ValidateCurrentlyRunningProviders();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the system info.
|
||||
/// </summary>
|
||||
|
||||
@@ -474,14 +474,8 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <param name="dto">The dto.</param>
|
||||
private static void SetSpecialCounts(Folder folder, User user, BaseItemDto dto)
|
||||
{
|
||||
var utcNow = DateTime.UtcNow;
|
||||
|
||||
var rcentlyAddedItemCount = 0;
|
||||
var recursiveItemCount = 0;
|
||||
var favoriteItemsCount = 0;
|
||||
var recentlyAddedUnPlayedItemCount = 0;
|
||||
var resumableItemCount = 0;
|
||||
var recentlyPlayedItemCount = 0;
|
||||
|
||||
double totalPercentPlayed = 0;
|
||||
|
||||
@@ -498,12 +492,6 @@ namespace MediaBrowser.Controller.Library
|
||||
if (child.IsRecentlyAdded(user))
|
||||
{
|
||||
rcentlyAddedItemCount++;
|
||||
|
||||
// Check recently added unplayed
|
||||
if (userdata == null || userdata.PlayCount == 0)
|
||||
{
|
||||
recentlyAddedUnPlayedItemCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Incrememt totalPercentPlayed
|
||||
@@ -521,32 +509,10 @@ namespace MediaBrowser.Controller.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userdata != null)
|
||||
{
|
||||
if (userdata.IsFavorite)
|
||||
{
|
||||
favoriteItemsCount++;
|
||||
}
|
||||
|
||||
if (userdata.PlaybackPositionTicks > 0)
|
||||
{
|
||||
resumableItemCount++;
|
||||
}
|
||||
|
||||
if (userdata.LastPlayedDate.HasValue && (utcNow - userdata.LastPlayedDate.Value).TotalDays < Kernel.Instance.Configuration.RecentlyPlayedDays)
|
||||
{
|
||||
recentlyPlayedItemCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dto.RecursiveItemCount = recursiveItemCount;
|
||||
dto.RecentlyAddedItemCount = rcentlyAddedItemCount;
|
||||
dto.RecentlyAddedUnPlayedItemCount = recentlyAddedUnPlayedItemCount;
|
||||
dto.ResumableItemCount = resumableItemCount;
|
||||
dto.FavoriteItemCount = favoriteItemsCount;
|
||||
dto.RecentlyPlayedItemCount = recentlyPlayedItemCount;
|
||||
|
||||
if (recursiveItemCount > 0)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.IO;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
@@ -13,6 +13,20 @@ namespace MediaBrowser.Controller.Library
|
||||
/// </summary>
|
||||
public class ItemResolveArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The _app paths
|
||||
/// </summary>
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ItemResolveArgs" /> class.
|
||||
/// </summary>
|
||||
/// <param name="appPaths">The app paths.</param>
|
||||
public ItemResolveArgs(IServerApplicationPaths appPaths)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file system children.
|
||||
/// </summary>
|
||||
@@ -99,9 +113,9 @@ namespace MediaBrowser.Controller.Library
|
||||
}
|
||||
|
||||
var parentDir = FileInfo.Path != null ? System.IO.Path.GetDirectoryName(FileInfo.Path) ?? string.Empty : string.Empty;
|
||||
|
||||
return (parentDir.Length > Kernel.Instance.ApplicationPaths.RootFolderPath.Length
|
||||
&& parentDir.StartsWith(Kernel.Instance.ApplicationPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return (parentDir.Length > _appPaths.RootFolderPath.Length
|
||||
&& parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -114,7 +128,7 @@ namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsDirectory && Path.Equals(Kernel.Instance.ApplicationPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase);
|
||||
return IsDirectory && Path.Equals(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
@@ -14,10 +15,8 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
public class LocalizedStrings
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
static internal ILogger Logger { get; set; }
|
||||
internal static IServerApplicationPaths ApplicationPaths;
|
||||
|
||||
/// <summary>
|
||||
/// The base prefix
|
||||
/// </summary>
|
||||
@@ -31,17 +30,21 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
private static LocalizedStrings _instance;
|
||||
|
||||
private IServerApplicationPaths _appPaths;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
/// <value>The instance.</value>
|
||||
public static LocalizedStrings Instance { get { return _instance ?? (_instance = new LocalizedStrings()); } }
|
||||
public static LocalizedStrings Instance { get { return _instance ?? (_instance = new LocalizedStrings(ApplicationPaths)); } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalizedStrings" /> class.
|
||||
/// </summary>
|
||||
public LocalizedStrings()
|
||||
public LocalizedStrings(IServerApplicationPaths appPaths)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
|
||||
foreach (var stringObject in Kernel.Instance.StringFiles)
|
||||
{
|
||||
AddStringData(LoadFromFile(GetFileName(stringObject),stringObject.GetType()));
|
||||
@@ -55,7 +58,7 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// <returns>System.String.</returns>
|
||||
protected string GetFileName(LocalizedStringData stringObject)
|
||||
{
|
||||
var path = Kernel.Instance.ApplicationPaths.LocalizationPath;
|
||||
var path = _appPaths.LocalizationPath;
|
||||
var name = Path.Combine(path, stringObject.Prefix + "strings-" + CultureInfo.CurrentCulture + ".xml");
|
||||
if (File.Exists(name))
|
||||
{
|
||||
@@ -125,17 +128,17 @@ namespace MediaBrowser.Controller.Localization
|
||||
}
|
||||
catch (TargetException ex)
|
||||
{
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
//Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
catch (FieldAccessException ex)
|
||||
{
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
//Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
//Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -11,7 +12,8 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
public static class Ratings
|
||||
{
|
||||
static internal ILogger Logger { get; set; }
|
||||
internal static IServerConfigurationManager ConfigurationManager;
|
||||
|
||||
/// <summary>
|
||||
/// The ratings def
|
||||
/// </summary>
|
||||
@@ -26,7 +28,7 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// <value>The ratings dict.</value>
|
||||
public static Dictionary<string, int> RatingsDict
|
||||
{
|
||||
get { return _ratingsDict ?? (_ratingsDict = Initialize(false)); }
|
||||
get { return _ratingsDict ?? (_ratingsDict = Initialize(false, ConfigurationManager)); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The ratings strings
|
||||
@@ -38,17 +40,17 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
/// <param name="blockUnrated">if set to <c>true</c> [block unrated].</param>
|
||||
/// <returns>Dictionary{System.StringSystem.Int32}.</returns>
|
||||
public static Dictionary<string, int> Initialize(bool blockUnrated)
|
||||
public static Dictionary<string, int> Initialize(bool blockUnrated, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
//build our ratings dictionary from the combined local one and us one
|
||||
ratingsDef = new RatingsDefinition(Path.Combine(Kernel.Instance.ApplicationPaths.LocalizationPath, "Ratings-" + Kernel.Instance.Configuration.MetadataCountryCode + ".txt"), Logger);
|
||||
ratingsDef = new RatingsDefinition(Path.Combine(configurationManager.ApplicationPaths.LocalizationPath, "Ratings-" + configurationManager.Configuration.MetadataCountryCode + ".txt"), configurationManager);
|
||||
//global value of None
|
||||
var dict = new Dictionary<string, int> {{"None", -1}};
|
||||
foreach (var pair in ratingsDef.RatingsDict)
|
||||
{
|
||||
dict.TryAdd(pair.Key, pair.Value);
|
||||
}
|
||||
if (Kernel.Instance.Configuration.MetadataCountryCode.ToUpper() != "US")
|
||||
if (configurationManager.Configuration.MetadataCountryCode.ToUpper() != "US")
|
||||
{
|
||||
foreach (var pair in new USRatingsDictionary())
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -10,26 +11,18 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
public class RatingsDefinition
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RatingsDefinition" /> class.
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public RatingsDefinition(string file, ILogger logger)
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public RatingsDefinition(string file, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
Logger = logger;
|
||||
|
||||
Logger.Info("Loading Certification Ratings from file " + file);
|
||||
this.file = file;
|
||||
if (!Load())
|
||||
{
|
||||
Init(Kernel.Instance.Configuration.MetadataCountryCode.ToUpper());
|
||||
Init(configurationManager.Configuration.MetadataCountryCode.ToUpper());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +101,7 @@ namespace MediaBrowser.Controller.Localization
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("Invalid line in ratings file " + file + "(" + line + ")");
|
||||
//Logger.Error("Invalid line in ratings file " + file + "(" + line + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,6 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mediabrowser.PluginSecurity">
|
||||
<HintPath>Plugins\Mediabrowser.PluginSecurity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
|
||||
@@ -74,6 +71,7 @@
|
||||
<Link>Properties\SharedVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="BaseManager.cs" />
|
||||
<Compile Include="Configuration\IServerConfigurationManager.cs" />
|
||||
<Compile Include="Drawing\ImageExtensions.cs" />
|
||||
<Compile Include="Drawing\ImageHeader.cs" />
|
||||
<Compile Include="Drawing\ImageManager.cs" />
|
||||
@@ -138,7 +136,6 @@
|
||||
<Compile Include="Library\IIntroProvider.cs" />
|
||||
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
|
||||
<Compile Include="Plugins\IServerEntryPoint.cs" />
|
||||
<Compile Include="Plugins\PluginSecurityManager.cs" />
|
||||
<Compile Include="Providers\Music\LastfmBaseProvider.cs" />
|
||||
<Compile Include="Providers\FanartBaseProvider.cs" />
|
||||
<Compile Include="Providers\IImageEnhancer.cs" />
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
/// The _protobuf serializer
|
||||
/// </summary>
|
||||
private readonly IProtobufSerializer _protobufSerializer;
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FFMpegManager" /> class.
|
||||
@@ -77,7 +78,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
/// <param name="protobufSerializer">The protobuf serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <exception cref="System.ArgumentNullException">zipClient</exception>
|
||||
public FFMpegManager(Kernel kernel, IZipClient zipClient, IJsonSerializer jsonSerializer, IProtobufSerializer protobufSerializer, ILogger logger)
|
||||
public FFMpegManager(Kernel kernel, IZipClient zipClient, IJsonSerializer jsonSerializer, IProtobufSerializer protobufSerializer, ILogManager logManager, IServerApplicationPaths appPaths)
|
||||
{
|
||||
if (kernel == null)
|
||||
{
|
||||
@@ -95,16 +96,13 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
{
|
||||
throw new ArgumentNullException("protobufSerializer");
|
||||
}
|
||||
if (logger == null)
|
||||
{
|
||||
throw new ArgumentNullException("logger");
|
||||
}
|
||||
|
||||
_kernel = kernel;
|
||||
_zipClient = zipClient;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_protobufSerializer = protobufSerializer;
|
||||
_logger = logger;
|
||||
_appPaths = appPaths;
|
||||
_logger = logManager.GetLogger("FFMpegManager");
|
||||
|
||||
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
|
||||
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
|
||||
@@ -223,7 +221,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
{
|
||||
if (_videoImagesDataPath == null)
|
||||
{
|
||||
_videoImagesDataPath = Path.Combine(_kernel.ApplicationPaths.DataPath, "ffmpeg-video-images");
|
||||
_videoImagesDataPath = Path.Combine(_appPaths.DataPath, "ffmpeg-video-images");
|
||||
|
||||
if (!Directory.Exists(_videoImagesDataPath))
|
||||
{
|
||||
@@ -249,7 +247,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
{
|
||||
if (_audioImagesDataPath == null)
|
||||
{
|
||||
_audioImagesDataPath = Path.Combine(_kernel.ApplicationPaths.DataPath, "ffmpeg-audio-images");
|
||||
_audioImagesDataPath = Path.Combine(_appPaths.DataPath, "ffmpeg-audio-images");
|
||||
|
||||
if (!Directory.Exists(_audioImagesDataPath))
|
||||
{
|
||||
@@ -275,7 +273,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
{
|
||||
if (_subtitleCachePath == null)
|
||||
{
|
||||
_subtitleCachePath = Path.Combine(_kernel.ApplicationPaths.CachePath, "ffmpeg-subtitles");
|
||||
_subtitleCachePath = Path.Combine(_appPaths.CachePath, "ffmpeg-subtitles");
|
||||
|
||||
if (!Directory.Exists(_subtitleCachePath))
|
||||
{
|
||||
@@ -302,7 +300,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
|
||||
var filename = resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length);
|
||||
|
||||
var versionedDirectoryPath = Path.Combine(_kernel.ApplicationPaths.MediaToolsPath, Path.GetFileNameWithoutExtension(filename));
|
||||
var versionedDirectoryPath = Path.Combine(_appPaths.MediaToolsPath, Path.GetFileNameWithoutExtension(filename));
|
||||
|
||||
if (!Directory.Exists(versionedDirectoryPath))
|
||||
{
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
using MediaBrowser.Common.Security;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Mediabrowser.Model.Entities;
|
||||
using Mediabrowser.PluginSecurity;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Net;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Class PluginSecurityManager
|
||||
/// </summary>
|
||||
public class PluginSecurityManager : ISecurityManager
|
||||
{
|
||||
/// <summary>
|
||||
/// The _is MB supporter
|
||||
/// </summary>
|
||||
private bool? _isMBSupporter;
|
||||
/// <summary>
|
||||
/// The _is MB supporter initialized
|
||||
/// </summary>
|
||||
private bool _isMBSupporterInitialized;
|
||||
/// <summary>
|
||||
/// The _is MB supporter sync lock
|
||||
/// </summary>
|
||||
private object _isMBSupporterSyncLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is MB supporter.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is MB supporter; otherwise, <c>false</c>.</value>
|
||||
public bool IsMBSupporter
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _isMBSupporter, ref _isMBSupporterInitialized, ref _isMBSupporterSyncLock, () => GetRegistrationStatus("MBSupporter").Result.IsRegistered);
|
||||
return _isMBSupporter.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private IHttpClient _httpClient;
|
||||
private IJsonSerializer _jsonSerializer;
|
||||
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
/// </summary>
|
||||
private readonly IKernel _kernel;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginSecurityManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
public PluginSecurityManager(IKernel kernel, IHttpClient httpClient, IJsonSerializer jsonSerializer, IApplicationPaths appPaths)
|
||||
{
|
||||
if (kernel == null)
|
||||
{
|
||||
throw new ArgumentNullException("kernel");
|
||||
}
|
||||
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
|
||||
_kernel = kernel;
|
||||
_httpClient = httpClient;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
MBRegistration.Init(appPaths);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the registration status.
|
||||
/// </summary>
|
||||
/// <param name="feature">The feature.</param>
|
||||
/// <param name="mb2Equivalent">The MB2 equivalent.</param>
|
||||
/// <returns>Task{MBRegistrationRecord}.</returns>
|
||||
public async Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null)
|
||||
{
|
||||
return await MBRegistration.GetRegistrationStatus(_httpClient, _jsonSerializer, feature, mb2Equivalent).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the supporter key.
|
||||
/// </summary>
|
||||
/// <value>The supporter key.</value>
|
||||
public string SupporterKey
|
||||
{
|
||||
get { return MBRegistration.SupporterKey; }
|
||||
set
|
||||
{
|
||||
if (value != MBRegistration.SupporterKey)
|
||||
{
|
||||
MBRegistration.SupporterKey = value;
|
||||
// Clear this so it will re-evaluate
|
||||
ResetSupporterInfo();
|
||||
// And we'll need to restart to re-evaluate the status of plug-ins
|
||||
_kernel.NotifyPendingRestart();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the legacy key.
|
||||
/// </summary>
|
||||
/// <value>The legacy key.</value>
|
||||
public string LegacyKey
|
||||
{
|
||||
get { return MBRegistration.LegacyKey; }
|
||||
set
|
||||
{
|
||||
MBRegistration.LegacyKey = value;
|
||||
// And we'll need to restart to re-evaluate the status of plug-ins
|
||||
_kernel.NotifyPendingRestart();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the supporter info.
|
||||
/// </summary>
|
||||
private void ResetSupporterInfo()
|
||||
{
|
||||
_isMBSupporter = null;
|
||||
_isMBSupporterInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
@@ -19,6 +21,12 @@ namespace MediaBrowser.Controller.Providers
|
||||
protected ILogger Logger { get; set; }
|
||||
protected ILogManager LogManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration manager.
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
protected IServerConfigurationManager ConfigurationManager { get; private set; }
|
||||
|
||||
// Cache these since they will be used a lot
|
||||
/// <summary>
|
||||
/// The false task result
|
||||
@@ -103,10 +111,11 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseMetadataProvider" /> class.
|
||||
/// </summary>
|
||||
protected BaseMetadataProvider(ILogManager logManager)
|
||||
protected BaseMetadataProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
{
|
||||
Logger = logManager.GetLogger(GetType().Name);
|
||||
LogManager = logManager;
|
||||
ConfigurationManager = configurationManager;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -50,8 +51,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
protected const string APIKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
|
||||
|
||||
protected FanartBaseProvider(ILogManager logManager)
|
||||
: base(logManager)
|
||||
protected FanartBaseProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
return DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(Kernel.Instance.Configuration.MetadataRefreshDays))
|
||||
&& ShouldFetch(item, providerInfo);
|
||||
return DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays))
|
||||
&& ShouldFetch(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public class FolderProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public FolderProviderFromXml(ILogManager logManager) : base(logManager)
|
||||
public FolderProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -16,7 +17,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public class ImageFromMediaLocationProvider : BaseMetadataProvider
|
||||
{
|
||||
public ImageFromMediaLocationProvider(ILogManager logManager) : base(logManager)
|
||||
public ImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
@@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public class ImagesByNameProvider : ImageFromMediaLocationProvider
|
||||
{
|
||||
public ImagesByNameProvider(ILogManager logManager) : base(logManager)
|
||||
public ImagesByNameProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
var name = item.Name ?? string.Empty;
|
||||
name = invalid.Aggregate(name, (current, c) => current.Replace(c.ToString(UsCulture), string.Empty));
|
||||
|
||||
return Path.Combine(Kernel.Instance.ApplicationPaths.GeneralPath, name);
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.GeneralPath, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
@@ -6,7 +7,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
public abstract class BaseFFMpegImageProvider<T> : BaseFFMpegProvider<T>
|
||||
where T : BaseItem
|
||||
{
|
||||
protected BaseFFMpegImageProvider(ILogManager logManager) : base(logManager)
|
||||
protected BaseFFMpegImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
public abstract class BaseFFMpegProvider<T> : BaseMetadataProvider
|
||||
where T : BaseItem
|
||||
{
|
||||
protected BaseFFMpegProvider(ILogManager logManager) : base(logManager)
|
||||
protected BaseFFMpegProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
@@ -19,7 +20,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
public abstract class BaseFFProbeProvider<T> : BaseFFMpegProvider<T>
|
||||
where T : BaseItem
|
||||
{
|
||||
protected BaseFFProbeProvider(ILogManager logManager) : base(logManager)
|
||||
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
FFProbeCache = new FileSystemRepository(Path.Combine(Kernel.Instance.ApplicationPaths.CachePath, CacheDirectoryName));
|
||||
FFProbeCache = new FileSystemRepository(Path.Combine(ConfigurationManager.ApplicationPaths.CachePath, CacheDirectoryName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
/// </summary>
|
||||
public class FFMpegAudioImageProvider : BaseFFMpegImageProvider<Audio>
|
||||
{
|
||||
public FFMpegAudioImageProvider(ILogManager logManager) : base(logManager)
|
||||
public FFMpegAudioImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
{
|
||||
@@ -22,8 +23,10 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
/// Initializes a new instance of the <see cref="FfMpegVideoImageProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="isoManager">The iso manager.</param>
|
||||
public FfMpegVideoImageProvider(IIsoManager isoManager, ILogManager logManager)
|
||||
: base(logManager)
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public FfMpegVideoImageProvider(IIsoManager isoManager, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
_isoManager = isoManager;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
@@ -17,7 +18,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
/// </summary>
|
||||
public class FFProbeAudioInfoProvider : BaseFFProbeProvider<Audio>
|
||||
{
|
||||
public FFProbeAudioInfoProvider(ILogManager logManager) : base(logManager)
|
||||
public FFProbeAudioInfoProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
@@ -20,6 +21,29 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
/// </summary>
|
||||
public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
|
||||
{
|
||||
public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (isoManager == null)
|
||||
{
|
||||
throw new ArgumentNullException("isoManager");
|
||||
}
|
||||
if (blurayExaminer == null)
|
||||
{
|
||||
throw new ArgumentNullException("blurayExaminer");
|
||||
}
|
||||
if (protobufSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("protobufSerializer");
|
||||
}
|
||||
|
||||
_blurayExaminer = blurayExaminer;
|
||||
_isoManager = isoManager;
|
||||
_protobufSerializer = protobufSerializer;
|
||||
|
||||
BdInfoCache = new FileSystemRepository(Path.Combine(ConfigurationManager.ApplicationPaths.CachePath, "bdinfo"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bd info cache.
|
||||
/// </summary>
|
||||
@@ -42,36 +66,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
/// </summary>
|
||||
private readonly IProtobufSerializer _protobufSerializer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FFProbeVideoInfoProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="isoManager">The iso manager.</param>
|
||||
/// <param name="blurayExaminer">The bluray examiner.</param>
|
||||
/// <param name="protobufSerializer">The protobuf serializer.</param>
|
||||
/// <exception cref="System.ArgumentNullException">blurayExaminer</exception>
|
||||
public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer, ILogManager logManager)
|
||||
: base(logManager)
|
||||
{
|
||||
if (isoManager == null)
|
||||
{
|
||||
throw new ArgumentNullException("isoManager");
|
||||
}
|
||||
if (blurayExaminer == null)
|
||||
{
|
||||
throw new ArgumentNullException("blurayExaminer");
|
||||
}
|
||||
if (protobufSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("protobufSerializer");
|
||||
}
|
||||
|
||||
_blurayExaminer = blurayExaminer;
|
||||
_isoManager = isoManager;
|
||||
_protobufSerializer = protobufSerializer;
|
||||
|
||||
BdInfoCache = new FileSystemRepository(Path.Combine(Kernel.Instance.ApplicationPaths.CachePath, "bdinfo"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true or false indicating if the provider should refresh when the contents of it's directory changes
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -18,14 +19,28 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
class FanArtMovieProvider : FanartBaseProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The fan art
|
||||
/// </summary>
|
||||
internal readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(5, 5);
|
||||
|
||||
internal static FanArtMovieProvider Current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP client.
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FanArtMovieProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
||||
public FanArtMovieProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (httpClient == null)
|
||||
{
|
||||
@@ -34,6 +49,19 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
HttpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <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 override void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
FanArtResourcePool.Dispose();
|
||||
}
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fan art base URL
|
||||
/// </summary>
|
||||
@@ -63,9 +91,9 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE);
|
||||
var discExists = item.ResolveArgs.ContainsMetaFileByName(DISC_FILE);
|
||||
|
||||
return (!artExists && Kernel.Instance.Configuration.DownloadMovieArt)
|
||||
|| (!logoExists && Kernel.Instance.Configuration.DownloadMovieLogo)
|
||||
|| (!discExists && Kernel.Instance.Configuration.DownloadMovieDisc);
|
||||
return (!artExists && ConfigurationManager.Configuration.DownloadMovieArt)
|
||||
|| (!logoExists && ConfigurationManager.Configuration.DownloadMovieLogo)
|
||||
|| (!discExists && ConfigurationManager.Configuration.DownloadMovieDisc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,13 +110,13 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
var movie = item;
|
||||
if (ShouldFetch(movie, movie.ProviderData.GetValueOrDefault(Id, new BaseProviderInfo { ProviderId = Id })))
|
||||
{
|
||||
var language = Kernel.Instance.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
var url = string.Format(FanArtBaseUrl, APIKey, movie.GetProviderId(MetadataProviders.Tmdb));
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
|
||||
using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
doc.Load(xml);
|
||||
}
|
||||
@@ -102,8 +130,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
string path;
|
||||
var hd = Kernel.Instance.Configuration.DownloadHDFanArt ? "hd" : "";
|
||||
if (Kernel.Instance.Configuration.DownloadMovieLogo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
||||
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
|
||||
if (ConfigurationManager.Configuration.DownloadMovieLogo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
||||
{
|
||||
var node =
|
||||
doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ??
|
||||
@@ -119,7 +147,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, LOGO_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
movie.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -132,7 +160,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadMovieArt && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadMovieArt && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
|
||||
{
|
||||
var node =
|
||||
doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ??
|
||||
@@ -145,7 +173,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, ART_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
movie.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -158,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadMovieDisc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadMovieDisc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url");
|
||||
@@ -168,7 +196,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, DISC_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
movie.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, DISC_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -182,7 +210,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadMovieBanner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadMovieBanner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url");
|
||||
@@ -192,7 +220,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Banner, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, BANNER_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
movie.SetImage(ImageType.Banner, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -206,7 +234,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadMovieThumb && !item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadMovieThumb && !item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url");
|
||||
@@ -216,7 +244,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Thumb, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, THUMB_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
movie.SetImage(ImageType.Thumb, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(movie, path, THUMB_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
using System.Net;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
@@ -31,6 +32,13 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
public class MovieDbProvider : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The movie db
|
||||
/// </summary>
|
||||
internal readonly SemaphoreSlim MovieDbResourcePool = new SemaphoreSlim(5, 5);
|
||||
|
||||
internal static MovieDbProvider Current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the json serializer.
|
||||
/// </summary>
|
||||
@@ -46,23 +54,29 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MovieDbProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The Log manager</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
public MovieDbProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
public MovieDbProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("jsonSerializer");
|
||||
}
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
JsonSerializer = jsonSerializer;
|
||||
HttpClient = httpClient;
|
||||
Current = 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 override void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
MovieDbResourcePool.Dispose();
|
||||
}
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -103,7 +117,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
get
|
||||
{
|
||||
return Kernel.Instance.Configuration.SaveLocalMeta;
|
||||
return ConfigurationManager.Configuration.SaveLocalMeta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +155,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var json = await httpClient.Get(String.Format(TmdbConfigUrl, ApiKey), Kernel.Instance.ResourcePools.MovieDb, CancellationToken.None).ConfigureAwait(false))
|
||||
using (var json = await httpClient.Get(String.Format(TmdbConfigUrl, ApiKey), MovieDbProvider.Current.MovieDbResourcePool, CancellationToken.None).ConfigureAwait(false))
|
||||
{
|
||||
return jsonSerializer.DeserializeFromStream<TmdbSettingsResult>(json);
|
||||
}
|
||||
@@ -200,11 +214,11 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
base.SetLastRefreshed(item, value, status);
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
//in addition to ours, we need to set the last refreshed time for the local data provider
|
||||
//so it won't see the new files we download and process them all over again
|
||||
if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(HttpClient, JsonSerializer, LogManager);
|
||||
if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(LogManager, ConfigurationManager, JsonSerializer, HttpClient);
|
||||
var data = item.ProviderData.GetValueOrDefault(JsonProvider.Id, new BaseProviderInfo { ProviderId = JsonProvider.Id });
|
||||
data.LastRefreshed = value;
|
||||
item.ProviderData[JsonProvider.Id] = data;
|
||||
@@ -233,7 +247,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta && HasFileSystemStampChanged(item, providerInfo))
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta && HasFileSystemStampChanged(item, providerInfo))
|
||||
{
|
||||
//If they deleted something from file system, chances are, this item was mis-identified the first time
|
||||
item.SetProviderId(MetadataProviders.Tmdb, null);
|
||||
@@ -250,7 +264,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (Kernel.Instance.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -258,7 +272,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
if (DateTime.Today.Subtract(item.DateCreated).TotalDays > 180 && downloadDate != DateTime.MinValue)
|
||||
return false; // don't trigger a refresh data for item that are more than 6 months old and have been refreshed before
|
||||
|
||||
if (DateTime.Today.Subtract(downloadDate).TotalDays < Kernel.Instance.Configuration.MetadataRefreshDays) // only refresh every n days
|
||||
if (DateTime.Today.Subtract(downloadDate).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days
|
||||
return false;
|
||||
|
||||
if (HasAltMeta(item))
|
||||
@@ -266,7 +280,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
|
||||
|
||||
Logger.Debug("MovieDbProvider - " + item.Name + " needs refresh. Download date: " + downloadDate + " item created date: " + item.DateCreated + " Check for Update age: " + Kernel.Instance.Configuration.MetadataRefreshDays);
|
||||
Logger.Debug("MovieDbProvider - " + item.Name + " needs refresh. Download date: " + downloadDate + " item created date: " + item.DateCreated + " Check for Update age: " + ConfigurationManager.Configuration.MetadataRefreshDays);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -293,7 +307,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (!Kernel.Instance.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)))
|
||||
if (!ConfigurationManager.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -407,7 +421,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
}
|
||||
|
||||
Logger.Info("MovieDbProvider: Finding id for movie: " + name);
|
||||
string language = Kernel.Instance.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
|
||||
//if we are a boxset - look at our first child
|
||||
var boxset = item as BoxSet;
|
||||
@@ -478,7 +492,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url3, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
@@ -510,7 +524,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await HttpClient.Get(url3, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
@@ -545,11 +559,11 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
if (matchedName == null)
|
||||
{
|
||||
//that title didn't match - look for alternatives
|
||||
url3 = string.Format(AltTitleSearch, id, ApiKey, Kernel.Instance.Configuration.MetadataCountryCode);
|
||||
url3 = string.Format(AltTitleSearch, id, ApiKey, ConfigurationManager.Configuration.MetadataCountryCode);
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await HttpClient.Get(url3, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var response = JsonSerializer.DeserializeFromStream<TmdbAltTitleResults>(json);
|
||||
|
||||
@@ -630,7 +644,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
var movieResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
|
||||
@@ -703,7 +717,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
}
|
||||
|
||||
//and save locally
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
JsonSerializer.SerializeToStream(mainResult, ms);
|
||||
@@ -724,14 +738,14 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
protected async Task<CompleteMovieData> FetchMainResult(BaseItem item, string id, CancellationToken cancellationToken)
|
||||
{
|
||||
ItemType = item is BoxSet ? "collection" : "movie";
|
||||
string url = string.Format(GetInfo3, id, ApiKey, Kernel.Instance.Configuration.PreferredMetadataLanguage, ItemType);
|
||||
string url = string.Format(GetInfo3, id, ApiKey, ConfigurationManager.Configuration.PreferredMetadataLanguage, ItemType);
|
||||
CompleteMovieData mainResult;
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
@@ -756,14 +770,14 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
if (mainResult != null && string.IsNullOrEmpty(mainResult.overview))
|
||||
{
|
||||
if (Kernel.Instance.Configuration.PreferredMetadataLanguage.ToLower() != "en")
|
||||
if (ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower() != "en")
|
||||
{
|
||||
Logger.Info("MovieDbProvider couldn't find meta for language " + Kernel.Instance.Configuration.PreferredMetadataLanguage + ". Trying English...");
|
||||
Logger.Info("MovieDbProvider couldn't find meta for language " + ConfigurationManager.Configuration.PreferredMetadataLanguage + ". Trying English...");
|
||||
url = string.Format(GetInfo3, id, ApiKey, "en", ItemType);
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
@@ -799,7 +813,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
cast = JsonSerializer.DeserializeFromStream<TmdbCastResult>(json);
|
||||
}
|
||||
@@ -826,7 +840,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
releases = JsonSerializer.DeserializeFromStream<TmdbReleasesResult>(json);
|
||||
}
|
||||
@@ -855,7 +869,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
images = JsonSerializer.DeserializeFromStream<TmdbImages>(json);
|
||||
}
|
||||
@@ -883,7 +897,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
movie.SetProviderId(MetadataProviders.Imdb, movieData.imdb_id);
|
||||
float rating;
|
||||
string voteAvg = movieData.vote_average.ToString();
|
||||
string cultureStr = Kernel.Instance.Configuration.PreferredMetadataLanguage + "-" + Kernel.Instance.Configuration.MetadataCountryCode;
|
||||
string cultureStr = ConfigurationManager.Configuration.PreferredMetadataLanguage + "-" + ConfigurationManager.Configuration.MetadataCountryCode;
|
||||
CultureInfo culture;
|
||||
try
|
||||
{
|
||||
@@ -900,7 +914,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
//release date and certification are retrieved based on configured country and we fall back on US if not there
|
||||
if (movieData.countries != null)
|
||||
{
|
||||
var ourRelease = movieData.countries.FirstOrDefault(c => c.iso_3166_1.Equals(Kernel.Instance.Configuration.MetadataCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new Country();
|
||||
var ourRelease = movieData.countries.FirstOrDefault(c => c.iso_3166_1.Equals(ConfigurationManager.Configuration.MetadataCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new Country();
|
||||
var usRelease = movieData.countries.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)) ?? new Country();
|
||||
|
||||
movie.OfficialRating = ourRelease.certification ?? usRelease.certification;
|
||||
@@ -975,17 +989,17 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// poster
|
||||
if (images.posters != null && images.posters.Count > 0 && (Kernel.Instance.Configuration.RefreshItemImages || !item.HasLocalImage("folder")))
|
||||
if (images.posters != null && images.posters.Count > 0 && (ConfigurationManager.Configuration.RefreshItemImages || !item.HasLocalImage("folder")))
|
||||
{
|
||||
var tmdbSettings = await TmdbSettings.ConfigureAwait(false);
|
||||
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + Kernel.Instance.Configuration.TmdbFetchedPosterSize;
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
|
||||
// get highest rated poster for our language
|
||||
|
||||
var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
|
||||
|
||||
var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(Kernel.Instance.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
|
||||
if (poster == null && !Kernel.Instance.Configuration.PreferredMetadataLanguage.Equals("en"))
|
||||
var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
|
||||
if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
|
||||
{
|
||||
// couldn't find our specific language, find english (if that wasn't our language)
|
||||
poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase));
|
||||
@@ -1004,7 +1018,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
try
|
||||
{
|
||||
item.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false);
|
||||
item.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -1025,18 +1039,18 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
var tmdbSettings = await TmdbSettings.ConfigureAwait(false);
|
||||
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + Kernel.Instance.Configuration.TmdbFetchedBackdropSize;
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
|
||||
//backdrops should be in order of rating. get first n ones
|
||||
var numToFetch = Math.Min(Kernel.Instance.Configuration.MaxBackdrops, images.backdrops.Count);
|
||||
var numToFetch = Math.Min(ConfigurationManager.Configuration.MaxBackdrops, images.backdrops.Count);
|
||||
for (var i = 0; i < numToFetch; i++)
|
||||
{
|
||||
var bdName = "backdrop" + (i == 0 ? "" : i.ToString());
|
||||
|
||||
if (Kernel.Instance.Configuration.RefreshItemImages || !item.HasLocalImage(bdName))
|
||||
if (ConfigurationManager.Configuration.RefreshItemImages || !item.HasLocalImage(bdName))
|
||||
{
|
||||
try
|
||||
{
|
||||
item.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false));
|
||||
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));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
@@ -14,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
public class MovieProviderFromJson : MovieDbProvider
|
||||
{
|
||||
public MovieProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager)
|
||||
: base(jsonSerializer, httpClient, logManager)
|
||||
public MovieProviderFromJson(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient) :
|
||||
base(logManager, configurationManager, jsonSerializer, httpClient)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
public class MovieProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public MovieProviderFromXml(ILogManager logManager) : base(logManager)
|
||||
public MovieProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
@@ -14,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
class PersonProviderFromJson : TmdbPersonProvider
|
||||
{
|
||||
public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager)
|
||||
: base(httpClient, jsonSerializer, logManager)
|
||||
public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager) :
|
||||
base(httpClient, jsonSerializer, logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -25,26 +26,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// </summary>
|
||||
protected const string MetaFileName = "MBPerson.json";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the json serializer.
|
||||
/// </summary>
|
||||
/// <value>The json serializer.</value>
|
||||
protected IJsonSerializer JsonSerializer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP client.
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MovieDbProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
public TmdbPersonProvider(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager)
|
||||
: base(logManager)
|
||||
public TmdbPersonProvider(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
@@ -58,6 +41,18 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
JsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the json serializer.
|
||||
/// </summary>
|
||||
/// <value>The json serializer.</value>
|
||||
protected IJsonSerializer JsonSerializer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP client.
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
/// </summary>
|
||||
@@ -78,7 +73,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
//we fetch if either info or image needed and haven't already tried recently
|
||||
return (string.IsNullOrEmpty(item.PrimaryImagePath) || !item.ResolveArgs.ContainsMetaFileByName(MetaFileName))
|
||||
&& DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > Kernel.Instance.Configuration.MetadataRefreshDays;
|
||||
&& DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,7 +160,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<PersonSearchResults>(json);
|
||||
}
|
||||
@@ -191,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (json != null)
|
||||
{
|
||||
@@ -254,7 +249,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (Stream json = await HttpClient.Get(url, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (json != null)
|
||||
{
|
||||
@@ -273,7 +268,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
searchResult.Profiles.FirstOrDefault(
|
||||
p =>
|
||||
!string.IsNullOrEmpty(p.Iso_639_1) &&
|
||||
p.Iso_639_1.Equals(Kernel.Instance.Configuration.PreferredMetadataLanguage,
|
||||
p.Iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
if (profile == null)
|
||||
{
|
||||
@@ -282,7 +277,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
searchResult.Profiles.FirstOrDefault(
|
||||
p =>
|
||||
!string.IsNullOrEmpty(p.Iso_639_1) &&
|
||||
p.Iso_639_1.Equals(Kernel.Instance.Configuration.PreferredMetadataLanguage,
|
||||
p.Iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
}
|
||||
@@ -295,7 +290,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
var tmdbSettings = await Kernel.Instance.MetadataProviders.OfType<MovieDbProvider>().First().TmdbSettings.ConfigureAwait(false);
|
||||
|
||||
var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + Kernel.Instance.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);
|
||||
|
||||
if (!string.IsNullOrEmpty(img))
|
||||
@@ -322,7 +317,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
var localPath = Path.Combine(item.MetaLocation, targetName);
|
||||
if (!item.ResolveArgs.ContainsMetaFileByName(targetName))
|
||||
{
|
||||
using (var sourceStream = await HttpClient.GetMemoryStream(source, Kernel.Instance.ResourcePools.MovieDb, 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);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -17,8 +18,10 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
{
|
||||
public class LastfmArtistProvider : LastfmBaseArtistProvider
|
||||
{
|
||||
public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager)
|
||||
: base(jsonSerializer, httpClient, logManager)
|
||||
internal readonly SemaphoreSlim LastfmResourcePool = new SemaphoreSlim(5, 5);
|
||||
|
||||
public LastfmArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(jsonSerializer, httpClient, logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,7 +34,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<LastfmArtistSearchResults>(json);
|
||||
}
|
||||
@@ -62,7 +65,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.Lastfm, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
result = JsonSerializer.DeserializeFromStream<LastfmGetArtistResult>(json);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
@@ -14,8 +15,8 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
{
|
||||
public abstract class LastfmBaseArtistProvider : LastfmBaseProvider
|
||||
{
|
||||
protected LastfmBaseArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager)
|
||||
: base(jsonSerializer, httpClient, logManager)
|
||||
protected LastfmBaseArtistProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(jsonSerializer, httpClient, logManager, configurationManager)
|
||||
{
|
||||
LocalMetaFileName = "MBArtist.json";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Net;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -23,6 +24,29 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
/// </summary>
|
||||
public abstract class LastfmBaseProvider : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LastfmBaseProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
protected LastfmBaseProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("jsonSerializer");
|
||||
}
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
JsonSerializer = jsonSerializer;
|
||||
HttpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the json serializer.
|
||||
/// </summary>
|
||||
@@ -40,28 +64,6 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
/// </summary>
|
||||
protected string LocalMetaFileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LastfmBaseProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The Log manager</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
public LastfmBaseProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("jsonSerializer");
|
||||
}
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
JsonSerializer = jsonSerializer;
|
||||
HttpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
@@ -90,7 +92,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
{
|
||||
get
|
||||
{
|
||||
return Kernel.Instance.Configuration.SaveLocalMeta;
|
||||
return ConfigurationManager.Configuration.SaveLocalMeta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +103,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
{
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta && HasFileSystemStampChanged(item, providerInfo))
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta && HasFileSystemStampChanged(item, providerInfo))
|
||||
{
|
||||
//If they deleted something from file system, chances are, this item was mis-identified the first time
|
||||
item.SetProviderId(MetadataProviders.Musicbrainz, null);
|
||||
@@ -118,7 +120,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (Kernel.Instance.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -126,11 +128,11 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (DateTime.Today.Subtract(item.DateCreated).TotalDays > 180 && downloadDate != DateTime.MinValue)
|
||||
return false; // don't trigger a refresh data for item that are more than 6 months old and have been refreshed before
|
||||
|
||||
if (DateTime.Today.Subtract(downloadDate).TotalDays < Kernel.Instance.Configuration.MetadataRefreshDays) // only refresh every n days
|
||||
if (DateTime.Today.Subtract(downloadDate).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days
|
||||
return false;
|
||||
|
||||
|
||||
Logger.Debug("LastfmProvider - " + item.Name + " needs refresh. Download date: " + downloadDate + " item created date: " + item.DateCreated + " Check for Update age: " + Kernel.Instance.Configuration.MetadataRefreshDays);
|
||||
Logger.Debug("LastfmProvider - " + item.Name + " needs refresh. Download date: " + downloadDate + " item created date: " + item.DateCreated + " Check for Update age: " + ConfigurationManager.Configuration.MetadataRefreshDays);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -151,7 +153,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (!Kernel.Instance.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)))
|
||||
if (!ConfigurationManager.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
@@ -39,18 +41,37 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger)
|
||||
public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger, IServerConfigurationManager configurationManager)
|
||||
: base(kernel)
|
||||
{
|
||||
_logger = logger;
|
||||
_httpClient = httpClient;
|
||||
ConfigurationManager = configurationManager;
|
||||
_remoteImageCache = new FileSystemRepository(ImagesDataPath);
|
||||
|
||||
configurationManager.ConfigurationUpdated += configurationManager_ConfigurationUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ConfigurationUpdated event of the configurationManager control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void configurationManager_ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
// Validate currently executing providers, in the background
|
||||
Task.Run(() =>
|
||||
{
|
||||
ValidateCurrentlyRunningProviders();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +88,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
if (_imagesDataPath == null)
|
||||
{
|
||||
_imagesDataPath = Path.Combine(Kernel.ApplicationPaths.DataPath, "remote-images");
|
||||
_imagesDataPath = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "remote-images");
|
||||
|
||||
if (!Directory.Exists(_imagesDataPath))
|
||||
{
|
||||
@@ -145,7 +166,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// Skip if internet providers are currently disabled
|
||||
if (provider.RequiresInternet && !Kernel.Configuration.EnableInternetProviders)
|
||||
if (provider.RequiresInternet && !ConfigurationManager.Configuration.EnableInternetProviders)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -157,7 +178,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
|
||||
// Skip if internet provider and this type is not allowed
|
||||
if (provider.RequiresInternet && Kernel.Configuration.EnableInternetProviders && Kernel.Configuration.InternetProviderExcludeTypes.Contains(item.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
if (provider.RequiresInternet && ConfigurationManager.Configuration.EnableInternetProviders && ConfigurationManager.Configuration.InternetProviderExcludeTypes.Contains(item.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -249,8 +270,8 @@ namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
_logger.Info("Validing currently running providers");
|
||||
|
||||
var enableInternetProviders = Kernel.Configuration.EnableInternetProviders;
|
||||
var internetProviderExcludeTypes = Kernel.Configuration.InternetProviderExcludeTypes;
|
||||
var enableInternetProviders = ConfigurationManager.Configuration.EnableInternetProviders;
|
||||
var internetProviderExcludeTypes = ConfigurationManager.Configuration.InternetProviderExcludeTypes;
|
||||
|
||||
foreach (var tuple in _currentlyRunningProviders.Values
|
||||
.Where(p => p.Item1.RequiresInternet && (!enableInternetProviders || internetProviderExcludeTypes.Contains(p.Item2.GetType().Name, StringComparer.OrdinalIgnoreCase)))
|
||||
@@ -290,13 +311,13 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
|
||||
//download and save locally
|
||||
var localPath = Kernel.Configuration.SaveLocalMeta ?
|
||||
var localPath = ConfigurationManager.Configuration.SaveLocalMeta ?
|
||||
Path.Combine(item.MetaLocation, targetName) :
|
||||
_remoteImageCache.GetResourcePath(item.GetType().FullName + item.Path.ToLower(), targetName);
|
||||
|
||||
var img = await _httpClient.GetMemoryStream(source, resourcePool, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (Kernel.Configuration.SaveLocalMeta) // queue to media directories
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta) // queue to media directories
|
||||
{
|
||||
await Kernel.FileSystemManager.SaveToLibraryFilesystem(item, localPath, img, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
@@ -13,7 +14,8 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public class SortNameProvider : BaseMetadataProvider
|
||||
{
|
||||
public SortNameProvider(ILogManager logManager) : base(logManager)
|
||||
public SortNameProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -99,14 +101,14 @@ namespace MediaBrowser.Controller.Providers
|
||||
if (item.Name == null) return false; //some items may not have name filled in properly
|
||||
|
||||
var sortable = item.Name.Trim().ToLower();
|
||||
sortable = Kernel.Instance.Configuration.SortRemoveCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), string.Empty));
|
||||
sortable = ConfigurationManager.Configuration.SortRemoveCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), string.Empty));
|
||||
|
||||
sortable = Kernel.Instance.Configuration.SortReplaceCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), " "));
|
||||
sortable = ConfigurationManager.Configuration.SortReplaceCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), " "));
|
||||
|
||||
foreach (var search in Kernel.Instance.Configuration.SortRemoveWords)
|
||||
foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
var searchLower = search.ToLower();
|
||||
// Remove from beginning if a space follows
|
||||
if (sortable.StartsWith(searchLower + " "))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
public class EpisodeImageFromMediaLocationProvider : BaseMetadataProvider
|
||||
{
|
||||
public EpisodeImageFromMediaLocationProvider(ILogManager logManager) : base(logManager)
|
||||
public EpisodeImageFromMediaLocationProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
public class EpisodeProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public EpisodeProviderFromXml(ILogManager logManager) : base(logManager)
|
||||
public EpisodeProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers.Movies;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
@@ -23,8 +25,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
public FanArtTvProvider(IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
public FanArtTvProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (httpClient == null)
|
||||
{
|
||||
@@ -46,9 +48,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
var thumbExists = item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE);
|
||||
|
||||
|
||||
return (!artExists && Kernel.Instance.Configuration.DownloadTVArt)
|
||||
|| (!logoExists && Kernel.Instance.Configuration.DownloadTVLogo)
|
||||
|| (!thumbExists && Kernel.Instance.Configuration.DownloadTVThumb);
|
||||
return (!artExists && ConfigurationManager.Configuration.DownloadTVArt)
|
||||
|| (!logoExists && ConfigurationManager.Configuration.DownloadTVLogo)
|
||||
|| (!thumbExists && ConfigurationManager.Configuration.DownloadTVThumb);
|
||||
}
|
||||
|
||||
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||
@@ -58,13 +60,13 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
var series = (Series)item;
|
||||
if (ShouldFetch(series, series.ProviderData.GetValueOrDefault(Id, new BaseProviderInfo { ProviderId = Id })))
|
||||
{
|
||||
string language = Kernel.Instance.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
string url = string.Format(FanArtBaseUrl, APIKey, series.GetProviderId(MetadataProviders.Tvdb));
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
|
||||
using (var xml = await HttpClient.Get(url, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
doc.Load(xml);
|
||||
}
|
||||
@@ -78,7 +80,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
string path;
|
||||
if (Kernel.Instance.Configuration.DownloadTVLogo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadTVLogo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo/@url");
|
||||
@@ -88,7 +90,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, LOGO_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
series.SetImage(ImageType.Logo, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, LOGO_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -102,7 +104,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadTVArt && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadTVArt && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/cleararts/clearart/@url");
|
||||
@@ -112,7 +114,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, ART_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
series.SetImage(ImageType.Art, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, ART_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -126,7 +128,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadTVThumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
|
||||
if (ConfigurationManager.Configuration.DownloadTVThumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url");
|
||||
@@ -136,7 +138,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, THUMB_FILE, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false));
|
||||
series.SetImage(ImageType.Disc, await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, path, THUMB_FILE, FanArtMovieProvider.Current.FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
@@ -27,13 +28,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteEpisodeProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
public RemoteEpisodeProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
HttpClient = httpClient;
|
||||
}
|
||||
|
||||
@@ -94,15 +97,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
var episode = (Episode)item;
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (Kernel.Instance.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item.DontFetchMeta && !HasLocalMeta(episode))
|
||||
{
|
||||
fetch = Kernel.Instance.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.Today.Subtract(downloadDate).TotalDays > Kernel.Instance.Configuration.MetadataRefreshDays;
|
||||
fetch = ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.Today.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
||||
}
|
||||
|
||||
return fetch;
|
||||
@@ -183,12 +186,12 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
seasonNumber = "0"; // Specials
|
||||
}
|
||||
|
||||
var url = string.Format(episodeQuery, TVUtils.TVDBApiKey, seriesId, seasonNumber, episodeNumber, Kernel.Instance.Configuration.PreferredMetadataLanguage);
|
||||
var url = string.Format(episodeQuery, TVUtils.TVDBApiKey, seriesId, seasonNumber, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var result = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var result = await HttpClient.Get(url, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
doc.Load(result);
|
||||
}
|
||||
@@ -202,11 +205,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
//this is basicly just for anime.
|
||||
if (!doc.HasChildNodes && Int32.Parse(seasonNumber) == 1)
|
||||
{
|
||||
url = string.Format(absEpisodeQuery, TVUtils.TVDBApiKey, seriesId, episodeNumber, Kernel.Instance.Configuration.PreferredMetadataLanguage);
|
||||
url = string.Format(absEpisodeQuery, TVUtils.TVDBApiKey, seriesId, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
|
||||
try
|
||||
{
|
||||
using (var result = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var result = await HttpClient.Get(url, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (result != null) doc.Load(result);
|
||||
usingAbsoluteData = true;
|
||||
@@ -226,7 +229,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
episode.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), Kernel.Instance.ResourcePools.TvDb, cancellationToken);
|
||||
episode.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -273,7 +276,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Writer", Name = str }));
|
||||
}
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
if (!Directory.Exists(episode.MetaLocation)) Directory.CreateDirectory(episode.MetaLocation);
|
||||
var ms = new MemoryStream();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -24,9 +25,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
|
||||
public RemoteSeasonProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (httpClient == null)
|
||||
{
|
||||
@@ -77,13 +78,13 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
bool fetch = false;
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (Kernel.Instance.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
return false;
|
||||
|
||||
if (!HasLocalMeta(item))
|
||||
{
|
||||
fetch = Kernel.Instance.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.UtcNow.Subtract(downloadDate).TotalDays > Kernel.Instance.Configuration.MetadataRefreshDays;
|
||||
fetch = ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.UtcNow.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
||||
}
|
||||
|
||||
return fetch;
|
||||
@@ -152,7 +153,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
using (var imgs = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var imgs = await HttpClient.Get(url, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
images.Load(imgs);
|
||||
}
|
||||
@@ -163,7 +164,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
if (images.HasChildNodes)
|
||||
{
|
||||
if (Kernel.Instance.Configuration.RefreshItemImages || !season.HasLocalImage("folder"))
|
||||
if (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("folder"))
|
||||
{
|
||||
var n = images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='season'][Season='" + seasonNumber + "']");
|
||||
if (n != null)
|
||||
@@ -173,7 +174,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
try
|
||||
{
|
||||
if (n != null)
|
||||
season.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false);
|
||||
season.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -185,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
}
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadTVSeasonBanner && (Kernel.Instance.Configuration.RefreshItemImages || !season.HasLocalImage("banner")))
|
||||
if (ConfigurationManager.Configuration.DownloadTVSeasonBanner && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("banner")))
|
||||
{
|
||||
var n = images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='seasonwide'][Season='" + seasonNumber + "']");
|
||||
if (n != null)
|
||||
@@ -201,7 +202,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
TVUtils.BannerUrl + n.InnerText,
|
||||
"banner" +
|
||||
Path.GetExtension(n.InnerText),
|
||||
Kernel.Instance.ResourcePools.TvDb, cancellationToken).
|
||||
RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).
|
||||
ConfigureAwait(false);
|
||||
|
||||
season.SetImage(ImageType.Banner, bannerImagePath);
|
||||
@@ -217,7 +218,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
}
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadTVSeasonBackdrops && (Kernel.Instance.Configuration.RefreshItemImages || !season.HasLocalImage("backdrop")))
|
||||
if (ConfigurationManager.Configuration.DownloadTVSeasonBackdrops && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("backdrop")))
|
||||
{
|
||||
var n = images.SelectSingleNode("//Banner[BannerType='fanart'][Season='" + seasonNumber + "']");
|
||||
if (n != null)
|
||||
@@ -228,7 +229,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
try
|
||||
{
|
||||
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), Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false));
|
||||
season.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -239,7 +240,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!Kernel.Instance.Configuration.SaveLocalMeta) //if saving local - season will inherit from series
|
||||
else if (!ConfigurationManager.Configuration.SaveLocalMeta) //if saving local - season will inherit from series
|
||||
{
|
||||
// not necessarily accurate but will give a different bit of art to each season
|
||||
var lst = images.SelectNodes("//Banner[BannerType='fanart']");
|
||||
@@ -263,7 +264,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
"backdrop" +
|
||||
Path.GetExtension(
|
||||
n.InnerText),
|
||||
Kernel.Instance.ResourcePools.TvDb, cancellationToken)
|
||||
RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken)
|
||||
.ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
@@ -23,20 +24,48 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
class RemoteSeriesProvider : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The tv db
|
||||
/// </summary>
|
||||
internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(5, 5);
|
||||
|
||||
internal static RemoteSeriesProvider Current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP client.
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager)
|
||||
: base(logManager)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteSeriesProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <exception cref="System.ArgumentNullException">httpClient</exception>
|
||||
public RemoteSeriesProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
if (httpClient == null)
|
||||
{
|
||||
throw new ArgumentNullException("httpClient");
|
||||
}
|
||||
HttpClient = httpClient;
|
||||
Current = 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 override void Dispose(bool dispose)
|
||||
{
|
||||
if (dispose)
|
||||
{
|
||||
TvDbResourcePool.Dispose();
|
||||
}
|
||||
base.Dispose(dispose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,15 +131,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (Kernel.Instance.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
return !HasLocalMeta(item) && (Kernel.Instance.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.UtcNow.Subtract(downloadDate).TotalDays > Kernel.Instance.Configuration.MetadataRefreshDays);
|
||||
return !HasLocalMeta(item) && (ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.UtcNow.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,12 +194,12 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
|
||||
string url = string.Format(seriesGet, TVUtils.TVDBApiKey, seriesId, Kernel.Instance.Configuration.PreferredMetadataLanguage);
|
||||
string url = string.Format(seriesGet, TVUtils.TVDBApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var xml = await HttpClient.Get(url, TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
doc.Load(xml);
|
||||
}
|
||||
@@ -219,7 +248,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
//wait for other tasks
|
||||
await Task.WhenAll(actorTask, imageTask).ConfigureAwait(false);
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
doc.Save(ms);
|
||||
@@ -249,7 +278,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
using (var actors = await HttpClient.Get(urlActors, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var actors = await HttpClient.Get(urlActors, TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
docActors.Load(actors);
|
||||
}
|
||||
@@ -261,7 +290,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (docActors.HasChildNodes)
|
||||
{
|
||||
XmlNode actorsNode = null;
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
//add to the main doc for saving
|
||||
var seriesNode = doc.SelectSingleNode("//Series");
|
||||
@@ -282,7 +311,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
series.AddPerson(new PersonInfo { Type = PersonType.Actor, Name = actorName, Role = actorRole });
|
||||
|
||||
if (Kernel.Instance.Configuration.SaveLocalMeta && actorsNode != null)
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta && actorsNode != null)
|
||||
{
|
||||
//create in main doc
|
||||
var personNode = doc.CreateNode(XmlNodeType.Element, "Person", null);
|
||||
@@ -316,7 +345,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
using (var imgs = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var imgs = await HttpClient.Get(url, TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
images.Load(imgs);
|
||||
}
|
||||
@@ -327,7 +356,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
if (images.HasChildNodes)
|
||||
{
|
||||
if (Kernel.Instance.Configuration.RefreshItemImages || !series.HasLocalImage("folder"))
|
||||
if (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage("folder"))
|
||||
{
|
||||
var n = images.SelectSingleNode("//Banner[BannerType='poster']");
|
||||
if (n != null)
|
||||
@@ -337,7 +366,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
try
|
||||
{
|
||||
series.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false);
|
||||
series.PrimaryImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -350,7 +379,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
}
|
||||
|
||||
if (Kernel.Instance.Configuration.DownloadTVBanner && (Kernel.Instance.Configuration.RefreshItemImages || !series.HasLocalImage("banner")))
|
||||
if (ConfigurationManager.Configuration.DownloadTVBanner && (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage("banner")))
|
||||
{
|
||||
var n = images.SelectSingleNode("//Banner[BannerType='series']");
|
||||
if (n != null)
|
||||
@@ -360,7 +389,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
try
|
||||
{
|
||||
var bannerImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), Kernel.Instance.ResourcePools.TvDb, cancellationToken);
|
||||
var bannerImagePath = await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken);
|
||||
|
||||
series.SetImage(ImageType.Banner, bannerImagePath);
|
||||
}
|
||||
@@ -385,11 +414,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (p != null)
|
||||
{
|
||||
var bdName = "backdrop" + (bdNo > 0 ? bdNo.ToString() : "");
|
||||
if (Kernel.Instance.Configuration.RefreshItemImages || !series.HasLocalImage(bdName))
|
||||
if (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage(bdName))
|
||||
{
|
||||
try
|
||||
{
|
||||
series.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false));
|
||||
series.BackdropImagePaths.Add(await Kernel.Instance.ProviderManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
@@ -400,7 +429,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
}
|
||||
bdNo++;
|
||||
if (bdNo >= Kernel.Instance.Configuration.MaxBackdrops) break;
|
||||
if (bdNo >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -463,7 +492,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
using (var results = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
|
||||
using (var results = await HttpClient.Get(url, TvDbResourcePool, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
doc.Load(results);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
@@ -14,7 +15,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
public class SeriesProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public SeriesProviderFromXml(ILogManager logManager) : base(logManager)
|
||||
public SeriesProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
@@ -182,7 +183,7 @@ namespace MediaBrowser.Controller.Updates
|
||||
PackageType? packageType = null,
|
||||
Version applicationVersion = null)
|
||||
{
|
||||
var packages = (await _packageManager.GetAvailablePackages(HttpClient, _networkManager, Kernel.SecurityManager, Kernel.ResourcePools, JsonSerializer, cancellationToken).ConfigureAwait(false)).ToList();
|
||||
var packages = (await _packageManager.GetAvailablePackages(cancellationToken).ConfigureAwait(false)).ToList();
|
||||
|
||||
if (packageType.HasValue)
|
||||
{
|
||||
@@ -418,7 +419,7 @@ namespace MediaBrowser.Controller.Updates
|
||||
private async Task InstallPackageInternal(PackageVersionInfo package, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
// Do the install
|
||||
await _packageManager.InstallPackage(HttpClient, _logger, Kernel.ResourcePools, progress, Kernel.ApplicationPaths, package, cancellationToken).ConfigureAwait(false);
|
||||
await _packageManager.InstallPackage(progress, package, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Do plugin-specific processing
|
||||
if (!(Path.GetExtension(package.targetFilename) ?? "").Equals(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
Reference in New Issue
Block a user