aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-02-16 17:03:15 +0100
committerGitHub <noreply@github.com>2019-02-16 17:03:15 +0100
commitbdfd042d705ec25ef37516ea7495f71eaee53d2e (patch)
tree463809b0be8f2a8995ca7648f2425d19c3bfa8a7 /Emby.Server.Implementations
parenta6a4cd5667fbb5a793cb9e551ce9c9a9bfb0d44b (diff)
parent25c2267a89af5c2e82774c638cdad0defcc894b5 (diff)
Merge branch 'master' into fields
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs103
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs19
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs540
-rw-r--r--Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs2
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj6
-rw-r--r--Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs74
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs2
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs2
-rw-r--r--Emby.Server.Implementations/ServerApplicationPaths.cs15
-rw-r--r--Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs2
-rw-r--r--Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs2
13 files changed, 230 insertions, 541 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index 701c04f9e..f26cc4f62 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -1,3 +1,4 @@
+using System;
using System.IO;
using MediaBrowser.Common.Configuration;
@@ -14,50 +15,44 @@ namespace Emby.Server.Implementations.AppBase
/// </summary>
protected BaseApplicationPaths(
string programDataPath,
- string appFolderPath,
- string logDirectoryPath = null,
- string configurationDirectoryPath = null,
- string cacheDirectoryPath = null)
+ string logDirectoryPath,
+ string configurationDirectoryPath,
+ string cacheDirectoryPath)
{
ProgramDataPath = programDataPath;
- ProgramSystemPath = appFolderPath;
LogDirectoryPath = logDirectoryPath;
ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
+
+ DataPath = Path.Combine(ProgramDataPath, "data");
}
+ /// <summary>
+ /// Gets the path to the program data folder
+ /// </summary>
+ /// <value>The program data path.</value>
public string ProgramDataPath { get; private set; }
/// <summary>
/// Gets the path to the system folder
/// </summary>
- public string ProgramSystemPath { get; private set; }
+ public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
/// <summary>
- /// The _data directory
- /// </summary>
- private string _dataDirectory;
- /// <summary>
/// Gets the folder path to the data directory
/// </summary>
/// <value>The data directory.</value>
+ private string _dataPath;
public string DataPath
{
- get
- {
- if (_dataDirectory == null)
- {
- _dataDirectory = Path.Combine(ProgramDataPath, "data");
-
- Directory.CreateDirectory(_dataDirectory);
- }
-
- return _dataDirectory;
- }
+ get => _dataPath;
+ private set => _dataPath = Directory.CreateDirectory(value).FullName;
}
- private const string _virtualDataPath = "%AppDataPath%";
- public string VirtualDataPath => _virtualDataPath;
+ /// <summary>
+ /// Gets the magic strings used for virtual path manipulation.
+ /// </summary>
+ public string VirtualDataPath { get; } = "%AppDataPath%";
/// <summary>
/// Gets the image cache path.
@@ -84,54 +79,16 @@ namespace Emby.Server.Implementations.AppBase
public string TempUpdatePath => Path.Combine(ProgramDataPath, "updates");
/// <summary>
- /// The _log directory
- /// </summary>
- private string _logDirectoryPath;
-
- /// <summary>
/// Gets the path to the log directory
/// </summary>
/// <value>The log directory path.</value>
- public string LogDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_logDirectoryPath))
- {
- _logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
-
- Directory.CreateDirectory(_logDirectoryPath);
- }
-
- return _logDirectoryPath;
- }
- set => _logDirectoryPath = value;
- }
-
- /// <summary>
- /// The _config directory
- /// </summary>
- private string _configurationDirectoryPath;
+ public string LogDirectoryPath { get; private set; }
/// <summary>
/// Gets the path to the application configuration root directory
/// </summary>
/// <value>The configuration directory path.</value>
- public string ConfigurationDirectoryPath
- {
- get
- {
- if (string.IsNullOrEmpty(_configurationDirectoryPath))
- {
- _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
-
- Directory.CreateDirectory(_configurationDirectoryPath);
- }
-
- return _configurationDirectoryPath;
- }
- set => _configurationDirectoryPath = value;
- }
+ public string ConfigurationDirectoryPath { get; private set; }
/// <summary>
/// Gets the path to the system configuration file
@@ -140,28 +97,10 @@ namespace Emby.Server.Implementations.AppBase
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
/// <summary>
- /// The _cache directory
- /// </summary>
- private string _cachePath;
- /// <summary>
/// Gets the folder path to the cache directory
/// </summary>
/// <value>The cache directory.</value>
- public string CachePath
- {
- get
- {
- if (string.IsNullOrEmpty(_cachePath))
- {
- _cachePath = Path.Combine(ProgramDataPath, "cache");
-
- Directory.CreateDirectory(_cachePath);
- }
-
- return _cachePath;
- }
- set => _cachePath = value;
- }
+ public string CachePath { get; set; }
/// <summary>
/// Gets the folder path to the temp directory within the cache folder
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index d7fa4d4c2..af60a8dce 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -171,16 +171,29 @@ namespace Emby.Server.Implementations.AppBase
private void UpdateCachePath()
{
string cachePath;
-
+ // If the configuration file has no entry (i.e. not set in UI)
if (string.IsNullOrWhiteSpace(CommonConfiguration.CachePath))
{
- cachePath = null;
+ // If the current live configuration has no entry (i.e. not set on CLI/envvars, during startup)
+ if (string.IsNullOrWhiteSpace(((BaseApplicationPaths)CommonApplicationPaths).CachePath))
+ {
+ // Set cachePath to a default value under ProgramDataPath
+ cachePath = Path.Combine(((BaseApplicationPaths)CommonApplicationPaths).ProgramDataPath, "cache");
+ }
+ else
+ {
+ // Set cachePath to the existing live value; will require restart if UI value is removed (but not replaced)
+ // TODO: Figure out how to re-grab this from the CLI/envvars while running
+ cachePath = ((BaseApplicationPaths)CommonApplicationPaths).CachePath;
+ }
}
else
{
- cachePath = Path.Combine(CommonConfiguration.CachePath, "cache");
+ // Set cachePath to the new UI-set value
+ cachePath = CommonConfiguration.CachePath;
}
+ Logger.LogInformation("Setting cache path to " + cachePath);
((BaseApplicationPaths)CommonApplicationPaths).CachePath = cachePath;
}
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 5c7133d05..5ec311036 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -105,6 +105,7 @@ using MediaBrowser.Providers.Subtitles;
using MediaBrowser.WebDashboard.Api;
using MediaBrowser.XbmcMetadata.Providers;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.DependencyInjection;
using ServiceStack;
using ServiceStack.Text.Jsv;
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
@@ -202,7 +203,7 @@ namespace Emby.Server.Implementations
/// Gets all concrete types.
/// </summary>
/// <value>All concrete types.</value>
- public Tuple<Type, string>[] AllConcreteTypes { get; protected set; }
+ public Type[] AllConcreteTypes { get; protected set; }
/// <summary>
/// The disposable parts
@@ -219,8 +220,6 @@ namespace Emby.Server.Implementations
protected IEnvironmentInfo EnvironmentInfo { get; set; }
- private IBlurayExaminer BlurayExaminer { get; set; }
-
public PackageVersionClass SystemUpdateLevel
{
get
@@ -232,12 +231,7 @@ namespace Emby.Server.Implementations
}
}
- public virtual string OperatingSystemDisplayName => EnvironmentInfo.OperatingSystemName;
-
- /// <summary>
- /// The container
- /// </summary>
- protected readonly SimpleInjector.Container Container = new SimpleInjector.Container();
+ protected IServiceProvider _serviceProvider;
/// <summary>
/// Gets the server configuration manager.
@@ -309,7 +303,6 @@ namespace Emby.Server.Implementations
/// <value>The user data repository.</value>
private IUserDataManager UserDataManager { get; set; }
private IUserRepository UserRepository { get; set; }
- internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
internal SqliteItemRepository ItemRepository { get; set; }
private INotificationManager NotificationManager { get; set; }
@@ -453,138 +446,58 @@ namespace Emby.Server.Implementations
/// <value>The name.</value>
public string Name => ApplicationProductName;
- private static Tuple<Assembly, string> GetAssembly(Type type)
- {
- var assembly = type.GetTypeInfo().Assembly;
-
- return new Tuple<Assembly, string>(assembly, null);
- }
-
- public virtual IStreamHelper CreateStreamHelper()
- {
- return new StreamHelper();
- }
-
/// <summary>
- /// Creates an instance of type and resolves all constructor dependancies
+ /// Creates an instance of type and resolves all constructor dependencies
/// </summary>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
public object CreateInstance(Type type)
- {
- return Container.GetInstance(type);
- }
+ => ActivatorUtilities.CreateInstance(_serviceProvider, type);
+
+ /// <summary>
+ /// Creates an instance of type and resolves all constructor dependencies
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <returns>System.Object.</returns>
+ public T CreateInstance<T>()
+ => ActivatorUtilities.CreateInstance<T>(_serviceProvider);
/// <summary>
/// Creates the instance safe.
/// </summary>
/// <param name="typeInfo">The type information.</param>
/// <returns>System.Object.</returns>
- protected object CreateInstanceSafe(Tuple<Type, string> typeInfo)
+ protected object CreateInstanceSafe(Type type)
{
- var type = typeInfo.Item1;
-
try
{
- return Container.GetInstance(type);
+ Logger.LogWarning("Creating instance of {Type}", type);
+ return ActivatorUtilities.CreateInstance(_serviceProvider, type);
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error creating {type}", type.FullName);
- // Don't blow up in release mode
+ Logger.LogError(ex, "Error creating {Type}", type);
return null;
}
}
/// <summary>
- /// Registers the specified obj.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="obj">The obj.</param>
- /// <param name="manageLifetime">if set to <c>true</c> [manage lifetime].</param>
- protected void RegisterSingleInstance<T>(T obj, bool manageLifetime = true)
- where T : class
- {
- Container.RegisterInstance<T>(obj);
-
- if (manageLifetime)
- {
- var disposable = obj as IDisposable;
-
- if (disposable != null)
- {
- DisposableParts.Add(disposable);
- }
- }
- }
-
- /// <summary>
- /// Registers the single instance.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="func">The func.</param>
- protected void RegisterSingleInstance<T>(Func<T> func)
- where T : class
- {
- Container.RegisterSingleton(func);
- }
-
- /// <summary>
/// Resolves this instance.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>``0.</returns>
- public T Resolve<T>()
- {
- return (T)Container.GetRegistration(typeof(T), true).GetInstance();
- }
-
- /// <summary>
- /// Resolves this instance.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <returns>``0.</returns>
- public T TryResolve<T>()
- {
- var result = Container.GetRegistration(typeof(T), false);
-
- if (result == null)
- {
- return default(T);
- }
- return (T)result.GetInstance();
- }
-
- /// <summary>
- /// Loads the assembly.
- /// </summary>
- /// <param name="file">The file.</param>
- /// <returns>Assembly.</returns>
- protected Tuple<Assembly, string> LoadAssembly(string file)
- {
- try
- {
- var assembly = Assembly.Load(File.ReadAllBytes(file));
-
- return new Tuple<Assembly, string>(assembly, file);
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error loading assembly {File}", file);
- return null;
- }
- }
+ public T Resolve<T>() => _serviceProvider.GetService<T>();
/// <summary>
/// Gets the export types.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>IEnumerable{Type}.</returns>
- public IEnumerable<Tuple<Type, string>> GetExportTypes<T>()
+ public IEnumerable<Type> GetExportTypes<T>()
{
var currentType = typeof(T);
- return AllConcreteTypes.Where(i => currentType.IsAssignableFrom(i.Item1));
+ return AllConcreteTypes.Where(i => currentType.IsAssignableFrom(i));
}
/// <summary>
@@ -596,9 +509,10 @@ namespace Emby.Server.Implementations
public IEnumerable<T> GetExports<T>(bool manageLifetime = true)
{
var parts = GetExportTypes<T>()
- .Select(CreateInstanceSafe)
+ .Select(x => CreateInstanceSafe(x))
.Where(i => i != null)
- .Cast<T>();
+ .Cast<T>()
+ .ToList(); // Convert to list so this isn't executed for each iteration
if (manageLifetime)
{
@@ -611,33 +525,6 @@ namespace Emby.Server.Implementations
return parts;
}
- public List<Tuple<T, string>> GetExportsWithInfo<T>(bool manageLifetime = true)
- {
- var parts = GetExportTypes<T>()
- .Select(i =>
- {
- var obj = CreateInstanceSafe(i);
-
- if (obj == null)
- {
- return null;
- }
- return new Tuple<T, string>((T)obj, i.Item2);
- })
- .Where(i => i != null)
- .ToList();
-
- if (manageLifetime)
- {
- lock (DisposableParts)
- {
- DisposableParts.AddRange(parts.Select(i => i.Item1).OfType<IDisposable>());
- }
- }
-
- return parts;
- }
-
/// <summary>
/// Runs the startup tasks.
/// </summary>
@@ -691,7 +578,7 @@ namespace Emby.Server.Implementations
}
}
- public async Task Init()
+ public async Task Init(IServiceCollection serviceCollection)
{
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
@@ -721,7 +608,7 @@ namespace Emby.Server.Implementations
SetHttpLimit();
- await RegisterResources();
+ await RegisterResources(serviceCollection);
FindParts();
}
@@ -736,104 +623,103 @@ namespace Emby.Server.Implementations
/// <summary>
/// Registers resources that classes will depend on
/// </summary>
- protected async Task RegisterResources()
+ protected async Task RegisterResources(IServiceCollection serviceCollection)
{
- RegisterSingleInstance(ConfigurationManager);
- RegisterSingleInstance<IApplicationHost>(this);
+ serviceCollection.AddSingleton(ConfigurationManager);
+ serviceCollection.AddSingleton<IApplicationHost>(this);
+
+ serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
- RegisterSingleInstance<IApplicationPaths>(ApplicationPaths);
- RegisterSingleInstance(JsonSerializer);
+ serviceCollection.AddSingleton(JsonSerializer);
- RegisterSingleInstance(LoggerFactory, false);
- RegisterSingleInstance(Logger);
+ serviceCollection.AddSingleton(LoggerFactory);
+ serviceCollection.AddLogging();
+ serviceCollection.AddSingleton(Logger);
- RegisterSingleInstance(EnvironmentInfo);
+ serviceCollection.AddSingleton(EnvironmentInfo);
- RegisterSingleInstance(FileSystemManager);
+ serviceCollection.AddSingleton(FileSystemManager);
HttpClient = CreateHttpClient();
- RegisterSingleInstance(HttpClient);
+ serviceCollection.AddSingleton(HttpClient);
- RegisterSingleInstance(NetworkManager);
+ serviceCollection.AddSingleton(NetworkManager);
IsoManager = new IsoManager();
- RegisterSingleInstance(IsoManager);
+ serviceCollection.AddSingleton(IsoManager);
TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager);
- RegisterSingleInstance(TaskManager);
+ serviceCollection.AddSingleton(TaskManager);
- RegisterSingleInstance(XmlSerializer);
+ serviceCollection.AddSingleton(XmlSerializer);
ProcessFactory = new ProcessFactory();
- RegisterSingleInstance(ProcessFactory);
+ serviceCollection.AddSingleton(ProcessFactory);
- var streamHelper = CreateStreamHelper();
- ApplicationHost.StreamHelper = streamHelper;
- RegisterSingleInstance(streamHelper);
+ ApplicationHost.StreamHelper = new StreamHelper();
+ serviceCollection.AddSingleton(StreamHelper);
- RegisterSingleInstance(CryptographyProvider);
+ serviceCollection.AddSingleton(CryptographyProvider);
SocketFactory = new SocketFactory();
- RegisterSingleInstance(SocketFactory);
+ serviceCollection.AddSingleton(SocketFactory);
InstallationManager = new InstallationManager(LoggerFactory, this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime);
- RegisterSingleInstance(InstallationManager);
+ serviceCollection.AddSingleton(InstallationManager);
ZipClient = new ZipClient();
- RegisterSingleInstance(ZipClient);
+ serviceCollection.AddSingleton(ZipClient);
HttpResultFactory = new HttpResultFactory(LoggerFactory, FileSystemManager, JsonSerializer, CreateBrotliCompressor());
- RegisterSingleInstance(HttpResultFactory);
+ serviceCollection.AddSingleton(HttpResultFactory);
- RegisterSingleInstance<IServerApplicationHost>(this);
- RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
+ serviceCollection.AddSingleton<IServerApplicationHost>(this);
+ serviceCollection.AddSingleton<IServerApplicationPaths>(ApplicationPaths);
- RegisterSingleInstance(ServerConfigurationManager);
+ serviceCollection.AddSingleton(ServerConfigurationManager);
- IAssemblyInfo assemblyInfo = new AssemblyInfo();
- RegisterSingleInstance(assemblyInfo);
+ var assemblyInfo = new AssemblyInfo();
+ serviceCollection.AddSingleton<IAssemblyInfo>(assemblyInfo);
LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory);
await LocalizationManager.LoadAll();
- RegisterSingleInstance<ILocalizationManager>(LocalizationManager);
+ serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager);
- BlurayExaminer = new BdInfoExaminer(FileSystemManager);
- RegisterSingleInstance(BlurayExaminer);
+ serviceCollection.AddSingleton<IBlurayExaminer>(new BdInfoExaminer(FileSystemManager));
- RegisterSingleInstance<IXmlReaderSettingsFactory>(new XmlReaderSettingsFactory());
+ serviceCollection.AddSingleton<IXmlReaderSettingsFactory>(new XmlReaderSettingsFactory());
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
- RegisterSingleInstance(UserDataManager);
+ serviceCollection.AddSingleton(UserDataManager);
UserRepository = GetUserRepository();
// This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it
- RegisterSingleInstance(UserRepository);
+ serviceCollection.AddSingleton(UserRepository);
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
- DisplayPreferencesRepository = displayPreferencesRepo;
- RegisterSingleInstance(DisplayPreferencesRepository);
+ serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo);
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, assemblyInfo);
- RegisterSingleInstance<IItemRepository>(ItemRepository);
+ serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
AuthenticationRepository = GetAuthenticationRepository();
- RegisterSingleInstance(AuthenticationRepository);
+ serviceCollection.AddSingleton(AuthenticationRepository);
UserManager = new UserManager(LoggerFactory, ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager);
- RegisterSingleInstance(UserManager);
+ serviceCollection.AddSingleton(UserManager);
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
- RegisterSingleInstance(LibraryManager);
+ serviceCollection.AddSingleton(LibraryManager);
// TODO wtaylor: investigate use of second music manager
var musicManager = new MusicManager(LibraryManager);
- RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));
+ serviceCollection.AddSingleton<IMusicManager>(new MusicManager(LibraryManager));
LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager, EnvironmentInfo);
- RegisterSingleInstance(LibraryMonitor);
+ serviceCollection.AddSingleton(LibraryMonitor);
- RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LoggerFactory, LibraryManager, UserManager));
+ serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(LoggerFactory, LibraryManager, UserManager));
CertificateInfo = GetCertificateInfo(true);
Certificate = GetCertificate(CertificateInfo);
@@ -848,81 +734,82 @@ namespace Emby.Server.Implementations
GetParseFn);
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
- RegisterSingleInstance(HttpServer);
+ serviceCollection.AddSingleton(HttpServer);
ImageProcessor = GetImageProcessor();
- RegisterSingleInstance(ImageProcessor);
+ serviceCollection.AddSingleton(ImageProcessor);
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
- RegisterSingleInstance(TVSeriesManager);
+ serviceCollection.AddSingleton(TVSeriesManager);
var encryptionManager = new EncryptionManager();
- RegisterSingleInstance<IEncryptionManager>(encryptionManager);
+ serviceCollection.AddSingleton<IEncryptionManager>(encryptionManager);
DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager);
- RegisterSingleInstance(DeviceManager);
+ serviceCollection.AddSingleton(DeviceManager);
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);
- RegisterSingleInstance(MediaSourceManager);
+ serviceCollection.AddSingleton(MediaSourceManager);
SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager);
- RegisterSingleInstance(SubtitleManager);
+ serviceCollection.AddSingleton(SubtitleManager);
ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LoggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer);
- RegisterSingleInstance(ProviderManager);
+ serviceCollection.AddSingleton(ProviderManager);
DtoService = new DtoService(LoggerFactory, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ProviderManager, this, () => MediaSourceManager, () => LiveTvManager);
- RegisterSingleInstance(DtoService);
+ serviceCollection.AddSingleton(DtoService);
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);
- RegisterSingleInstance(ChannelManager);
+ serviceCollection.AddSingleton(ChannelManager);
SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
- RegisterSingleInstance(SessionManager);
+ serviceCollection.AddSingleton(SessionManager);
- var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo);
- RegisterSingleInstance<IDlnaManager>(dlnaManager);
+ serviceCollection.AddSingleton<IDlnaManager>(
+ new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo));
CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager);
- RegisterSingleInstance(CollectionManager);
+ serviceCollection.AddSingleton(CollectionManager);
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory, UserManager, ProviderManager);
- RegisterSingleInstance(PlaylistManager);
+ serviceCollection.AddSingleton(PlaylistManager);
LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, FileSystemManager, () => ChannelManager);
- RegisterSingleInstance(LiveTvManager);
+ serviceCollection.AddSingleton(LiveTvManager);
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
- RegisterSingleInstance(UserViewManager);
+ serviceCollection.AddSingleton(UserViewManager);
NotificationManager = new NotificationManager(LoggerFactory, UserManager, ServerConfigurationManager);
- RegisterSingleInstance(NotificationManager);
+ serviceCollection.AddSingleton(NotificationManager);
- RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory));
+ serviceCollection.AddSingleton<IDeviceDiscovery>(
+ new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory));
ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);
- RegisterSingleInstance(ChapterManager);
+ serviceCollection.AddSingleton(ChapterManager);
- RegisterMediaEncoder(assemblyInfo);
+ RegisterMediaEncoder(serviceCollection);
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager);
- RegisterSingleInstance(EncodingManager);
+ serviceCollection.AddSingleton(EncodingManager);
var activityLogRepo = GetActivityLogRepository();
- RegisterSingleInstance(activityLogRepo);
- RegisterSingleInstance<IActivityManager>(new ActivityManager(LoggerFactory, activityLogRepo, UserManager));
+ serviceCollection.AddSingleton(activityLogRepo);
+ serviceCollection.AddSingleton<IActivityManager>(new ActivityManager(LoggerFactory, activityLogRepo, UserManager));
var authContext = new AuthorizationContext(AuthenticationRepository, UserManager);
- RegisterSingleInstance<IAuthorizationContext>(authContext);
- RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
+ serviceCollection.AddSingleton<IAuthorizationContext>(authContext);
+ serviceCollection.AddSingleton<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, SessionManager, NetworkManager);
- RegisterSingleInstance(AuthService);
+ serviceCollection.AddSingleton(AuthService);
SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory);
- RegisterSingleInstance(SubtitleEncoder);
+ serviceCollection.AddSingleton(SubtitleEncoder);
- RegisterSingleInstance(CreateResourceFileManager());
+ serviceCollection.AddSingleton(CreateResourceFileManager());
displayPreferencesRepo.Initialize();
@@ -935,6 +822,8 @@ namespace Emby.Server.Implementations
((UserDataManager)UserDataManager).Repository = userDataRepo;
ItemRepository.Initialize(userDataRepo, UserManager);
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
+
+ _serviceProvider = serviceCollection.BuildServiceProvider();
}
protected virtual IBrotliCompressor CreateBrotliCompressor()
@@ -1066,7 +955,7 @@ namespace Emby.Server.Implementations
/// Registers the media encoder.
/// </summary>
/// <returns>Task.</returns>
- private void RegisterMediaEncoder(IAssemblyInfo assemblyInfo)
+ private void RegisterMediaEncoder(IServiceCollection serviceCollection)
{
string encoderPath = null;
string probePath = null;
@@ -1098,7 +987,7 @@ namespace Emby.Server.Implementations
5000);
MediaEncoder = mediaEncoder;
- RegisterSingleInstance(MediaEncoder);
+ serviceCollection.AddSingleton(MediaEncoder);
}
/// <summary>
@@ -1174,7 +1063,10 @@ namespace Emby.Server.Implementations
}
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
- Plugins = GetExportsWithInfo<IPlugin>().Select(LoadPlugin).Where(i => i != null).ToArray();
+ Plugins = GetExports<IPlugin>()
+ .Select(LoadPlugin)
+ .Where(i => i != null)
+ .ToArray();
HttpServer.Init(GetExports<IService>(false), GetExports<IWebSocketListener>());
@@ -1208,19 +1100,15 @@ namespace Emby.Server.Implementations
IsoManager.AddParts(GetExports<IIsoMounter>());
}
- private IPlugin LoadPlugin(Tuple<IPlugin, string> info)
+ private IPlugin LoadPlugin(IPlugin plugin)
{
- var plugin = info.Item1;
- var assemblyFilePath = info.Item2;
-
try
{
- var assemblyPlugin = plugin as IPluginAssembly;
-
- if (assemblyPlugin != null)
+ if (plugin is IPluginAssembly assemblyPlugin)
{
var assembly = plugin.GetType().Assembly;
var assemblyName = assembly.GetName();
+ var assemblyFilePath = assembly.Location;
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
@@ -1264,78 +1152,15 @@ namespace Emby.Server.Implementations
{
Logger.LogInformation("Loading assemblies");
- var assemblyInfos = GetComposablePartAssemblies();
-
- foreach (var assemblyInfo in assemblyInfos)
- {
- var assembly = assemblyInfo.Item1;
- var path = assemblyInfo.Item2;
-
- if (path == null)
- {
- Logger.LogInformation("Loading {assemblyName}", assembly.FullName);
- }
- else
+ AllConcreteTypes = GetComposablePartAssemblies()
+ .SelectMany(x => x.ExportedTypes)
+ .Where(type =>
{
- Logger.LogInformation("Loading {assemblyName} from {path}", assembly.FullName, path);
- }
- }
-
- AllConcreteTypes = assemblyInfos
- .SelectMany(GetTypes)
- .Where(info =>
- {
- var t = info.Item1;
- return t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType;
+ return type.IsClass && !type.IsAbstract && !type.IsInterface && !type.IsGenericType;
})
.ToArray();
}
- /// <summary>
- /// Gets a list of types within an assembly
- /// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
- /// </summary>
- protected List<Tuple<Type, string>> GetTypes(Tuple<Assembly, string> assemblyInfo)
- {
- if (assemblyInfo == null)
- {
- return new List<Tuple<Type, string>>();
- }
-
- var assembly = assemblyInfo.Item1;
-
- try
- {
- // This null checking really shouldn't be needed but adding it due to some
- // unhandled exceptions in mono 5.0 that are a little hard to hunt down
- var types = assembly.GetTypes() ?? new Type[] { };
- return types.Where(t => t != null).Select(i => new Tuple<Type, string>(i, assemblyInfo.Item2)).ToList();
- }
- catch (ReflectionTypeLoadException ex)
- {
- if (ex.LoaderExceptions != null)
- {
- foreach (var loaderException in ex.LoaderExceptions)
- {
- if (loaderException != null)
- {
- Logger.LogError("LoaderException: " + loaderException.Message);
- }
- }
- }
-
- // If it fails we can still get a list of the Types it was able to resolve
- var types = ex.Types ?? new Type[] { };
- return types.Where(t => t != null).Select(i => new Tuple<Type, string>(i, assemblyInfo.Item2)).ToList();
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error loading types from assembly");
-
- return new List<Tuple<Type, string>>();
- }
- }
-
private CertificateInfo CertificateInfo { get; set; }
protected X509Certificate Certificate { get; private set; }
@@ -1546,150 +1371,63 @@ namespace Emby.Server.Implementations
/// Gets the composable part assemblies.
/// </summary>
/// <returns>IEnumerable{Assembly}.</returns>
- protected List<Tuple<Assembly, string>> GetComposablePartAssemblies()
+ protected IEnumerable<Assembly> GetComposablePartAssemblies()
{
- var list = GetPluginAssemblies(ApplicationPaths.PluginsPath);
-
- // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
- // This will prevent the .dll file from getting locked, and allow us to replace it when needed
+ if (Directory.Exists(ApplicationPaths.PluginsPath))
+ {
+ foreach (var file in Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly))
+ {
+ Logger.LogInformation("Loading assembly {Path}", file);
+ yield return Assembly.LoadFrom(file);
+ }
+ }
// Include composable parts in the Api assembly
- list.Add(GetAssembly(typeof(ApiEntryPoint)));
+ yield return typeof(ApiEntryPoint).Assembly;
// Include composable parts in the Dashboard assembly
- list.Add(GetAssembly(typeof(DashboardService)));
+ yield return typeof(DashboardService).Assembly;
// Include composable parts in the Model assembly
- list.Add(GetAssembly(typeof(SystemInfo)));
+ yield return typeof(SystemInfo).Assembly;
// Include composable parts in the Common assembly
- list.Add(GetAssembly(typeof(IApplicationHost)));
+ yield return typeof(IApplicationHost).Assembly;
// Include composable parts in the Controller assembly
- list.Add(GetAssembly(typeof(IServerApplicationHost)));
+ yield return typeof(IServerApplicationHost).Assembly;
// Include composable parts in the Providers assembly
- list.Add(GetAssembly(typeof(ProviderUtils)));
+ yield return typeof(ProviderUtils).Assembly;
// Include composable parts in the Photos assembly
- list.Add(GetAssembly(typeof(PhotoProvider)));
+ yield return typeof(PhotoProvider).Assembly;
// Emby.Server implementations
- list.Add(GetAssembly(typeof(InstallationManager)));
+ yield return typeof(InstallationManager).Assembly;
// MediaEncoding
- list.Add(GetAssembly(typeof(MediaBrowser.MediaEncoding.Encoder.MediaEncoder)));
+ yield return typeof(MediaBrowser.MediaEncoding.Encoder.MediaEncoder).Assembly;
// Dlna
- list.Add(GetAssembly(typeof(DlnaEntryPoint)));
+ yield return typeof(DlnaEntryPoint).Assembly;
// Local metadata
- list.Add(GetAssembly(typeof(BoxSetXmlSaver)));
+ yield return typeof(BoxSetXmlSaver).Assembly;
// Notifications
- list.Add(GetAssembly(typeof(NotificationManager)));
+ yield return typeof(NotificationManager).Assembly;
// Xbmc
- list.Add(GetAssembly(typeof(ArtistNfoProvider)));
-
- list.AddRange(GetAssembliesWithPartsInternal().Select(i => new Tuple<Assembly, string>(i, null)));
+ yield return typeof(ArtistNfoProvider).Assembly;
- return list.ToList();
- }
-
- protected abstract IEnumerable<Assembly> GetAssembliesWithPartsInternal();
-
- private List<Tuple<Assembly, string>> GetPluginAssemblies(string path)
- {
- try
+ foreach (var i in GetAssembliesWithPartsInternal())
{
- return FilterAssembliesToLoad(Directory.EnumerateFiles(path, "*.dll", SearchOption.TopDirectoryOnly))
- .Select(LoadAssembly)
- .Where(a => a != null)
- .ToList();
- }
- catch (DirectoryNotFoundException)
- {
- return new List<Tuple<Assembly, string>>();
+ yield return i;
}
}
- private IEnumerable<string> FilterAssembliesToLoad(IEnumerable<string> paths)
- {
-
- var exclude = new[]
- {
- "mbplus.dll",
- "mbintros.dll",
- "embytv.dll",
- "Messenger.dll",
- "Messages.dll",
- "MediaBrowser.Plugins.TvMazeProvider.dll",
- "MBBookshelf.dll",
- "MediaBrowser.Channels.Adult.YouJizz.dll",
- "MediaBrowser.Channels.Vine-co.dll",
- "MediaBrowser.Plugins.Vimeo.dll",
- "MediaBrowser.Channels.Vevo.dll",
- "MediaBrowser.Plugins.Twitch.dll",
- "MediaBrowser.Channels.SvtPlay.dll",
- "MediaBrowser.Plugins.SoundCloud.dll",
- "MediaBrowser.Plugins.SnesBox.dll",
- "MediaBrowser.Plugins.RottenTomatoes.dll",
- "MediaBrowser.Plugins.Revision3.dll",
- "MediaBrowser.Plugins.NesBox.dll",
- "MBChapters.dll",
- "MediaBrowser.Channels.LeagueOfLegends.dll",
- "MediaBrowser.Plugins.ADEProvider.dll",
- "MediaBrowser.Channels.BallStreams.dll",
- "MediaBrowser.Channels.Adult.Beeg.dll",
- "ChannelDownloader.dll",
- "Hamstercat.Emby.EmbyBands.dll",
- "EmbyTV.dll",
- "MediaBrowser.Channels.HitboxTV.dll",
- "MediaBrowser.Channels.HockeyStreams.dll",
- "MediaBrowser.Plugins.ITV.dll",
- "MediaBrowser.Plugins.Lastfm.dll",
- "ServerRestart.dll",
- "MediaBrowser.Plugins.NotifyMyAndroidNotifications.dll",
- "MetadataViewer.dll"
- };
-
- var minRequiredVersions = new Dictionary<string, Version>(StringComparer.OrdinalIgnoreCase)
- {
- { "moviethemesongs.dll", new Version(1, 6) },
- { "themesongs.dll", new Version(1, 2) }
- };
-
- return paths.Where(path =>
- {
- var filename = Path.GetFileName(path);
- if (exclude.Contains(filename ?? string.Empty, StringComparer.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (minRequiredVersions.TryGetValue(filename, out Version minRequiredVersion))
- {
- try
- {
- var version = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);
-
- if (version < minRequiredVersion)
- {
- Logger.LogInformation("Not loading {filename} {version} because the minimum supported version is {minRequiredVersion}. Please update to the newer version", filename, version, minRequiredVersion);
- return false;
- }
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error getting version number from {path}", path);
-
- return false;
- }
- }
- return true;
- });
- }
+ protected abstract IEnumerable<Assembly> GetAssembliesWithPartsInternal();
/// <summary>
/// Gets the system status.
@@ -1718,7 +1456,7 @@ namespace Emby.Server.Implementations
SupportsHttps = SupportsHttps,
HttpsPortNumber = HttpsPort,
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
- OperatingSystemDisplayName = OperatingSystemDisplayName,
+ OperatingSystemDisplayName = EnvironmentInfo.OperatingSystemName,
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
CanLaunchWebBrowser = CanLaunchWebBrowser,
@@ -1788,7 +1526,7 @@ namespace Emby.Server.Implementations
public async Task<string> GetWanApiUrl(CancellationToken cancellationToken)
{
- var url = "http://ipv4.icanhazip.com";
+ const string url = "http://ipv4.icanhazip.com";
try
{
using (var response = await HttpClient.Get(new HttpRequestOptions
diff --git a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
index 844f77a1a..303a8ac7b 100644
--- a/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
+++ b/Emby.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs
@@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Channels
{
- class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
+ public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
{
private readonly IChannelManager _channelManager;
private readonly IUserManager _userManager;
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index af01001a5..6bf776f53 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -22,11 +22,11 @@
</ItemGroup>
<ItemGroup>
+ <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
<PackageReference Include="sharpcompress" Version="0.22.0" />
- <PackageReference Include="SimpleInjector" Version="4.4.2" />
- <PackageReference Include="SQLitePCL.pretty.core" Version="1.1.8" />
- <PackageReference Include="SQLitePCLRaw.core" Version="1.1.11" />
+ <PackageReference Include="SQLitePCL.pretty.netstandard" Version="1.0.0" />
<PackageReference Include="UTF.Unknown" Version="1.0.0-beta1" />
</ItemGroup>
diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
index 774ed09da..a5badacee 100644
--- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
@@ -14,7 +14,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.EntryPoints
{
- class UserDataChangeNotifier : IServerEntryPoint
+ public class UserDataChangeNotifier : IServerEntryPoint
{
private readonly ISessionManager _sessionManager;
private readonly ILogger _logger;
diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
index fa8c89e88..7e4b38b4c 100644
--- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
@@ -9,7 +9,7 @@ using MediaBrowser.Model.IO;
namespace Emby.Server.Implementations.Library.Resolvers
{
- class SpecialFolderResolver : FolderResolver<Folder>
+ public class SpecialFolderResolver : FolderResolver<Folder>
{
private readonly IFileSystem _fileSystem;
private readonly IServerApplicationPaths _appPaths;
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index e66f5b42e..ad124bb0f 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -155,56 +155,56 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
string numberString = null;
+ string attributeValue;
+ double doubleValue;
- // Check for channel number with the format from SatIp
- // #EXTINF:0,84. VOX Schweiz
- // #EXTINF:0,84.0 - VOX Schweiz
- if (!string.IsNullOrWhiteSpace(nameInExtInf))
+ if (attributes.TryGetValue("tvg-chno", out attributeValue))
{
- var numberIndex = nameInExtInf.IndexOf(' ');
- if (numberIndex > 0)
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
{
- var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
-
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
- {
- numberString = numberPart;
- }
+ numberString = attributeValue;
}
}
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
- }
-
if (!IsValidChannelNumber(numberString))
{
- if (attributes.TryGetValue("tvg-id", out string value))
+ if (attributes.TryGetValue("tvg-id", out attributeValue))
{
- if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue))
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
{
- numberString = value;
+ numberString = attributeValue;
+ }
+ else if (attributes.TryGetValue("channel-id", out attributeValue))
+ {
+ if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
+ {
+ numberString = attributeValue;
+ }
}
}
- }
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
- }
-
- if (!IsValidChannelNumber(numberString))
- {
- if (attributes.TryGetValue("channel-id", out string value))
+ if (String.IsNullOrWhiteSpace(numberString))
{
- numberString = value;
+ // Using this as a fallback now as this leads to Problems with channels like "5 USA"
+ // where 5 isnt ment to be the channel number
+ // Check for channel number with the format from SatIp
+ // #EXTINF:0,84. VOX Schweiz
+ // #EXTINF:0,84.0 - VOX Schweiz
+ if (!string.IsNullOrWhiteSpace(nameInExtInf))
+ {
+ var numberIndex = nameInExtInf.IndexOf(' ');
+ if (numberIndex > 0)
+ {
+ var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
+
+ if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
+ {
+ numberString = numberPart;
+ }
+ }
+ }
}
- }
- if (!string.IsNullOrWhiteSpace(numberString))
- {
- numberString = numberString.Trim();
}
if (!IsValidChannelNumber(numberString))
@@ -212,7 +212,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
numberString = null;
}
- if (string.IsNullOrWhiteSpace(numberString))
+ if (!string.IsNullOrWhiteSpace(numberString))
+ {
+ numberString = numberString.Trim();
+ }
+ else
{
if (string.IsNullOrWhiteSpace(mediaUrl))
{
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
index 4eff9252e..d74cf3be2 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
@@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var now = DateTime.UtcNow;
- var _ = StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);
+ _ = StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);
//OpenedMediaSource.Protocol = MediaProtocol.File;
//OpenedMediaSource.Path = tempFile;
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
index 81fdb96d2..2f07ff15a 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
@@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary>
/// Class ChapterImagesTask
/// </summary>
- class ChapterImagesTask : IScheduledTask
+ public class ChapterImagesTask : IScheduledTask
{
/// <summary>
/// The _logger
diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs
index 36975df50..05f6469ec 100644
--- a/Emby.Server.Implementations/ServerApplicationPaths.cs
+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs
@@ -15,21 +15,17 @@ namespace Emby.Server.Implementations
/// </summary>
public ServerApplicationPaths(
string programDataPath,
- string appFolderPath,
- string applicationResourcesPath,
- string logDirectoryPath = null,
- string configurationDirectoryPath = null,
- string cacheDirectoryPath = null)
+ string logDirectoryPath,
+ string configurationDirectoryPath,
+ string cacheDirectoryPath)
: base(programDataPath,
- appFolderPath,
logDirectoryPath,
configurationDirectoryPath,
cacheDirectoryPath)
{
- ApplicationResourcesPath = applicationResourcesPath;
}
- public string ApplicationResourcesPath { get; private set; }
+ public string ApplicationResourcesPath { get; } = AppContext.BaseDirectory;
/// <summary>
/// Gets the path to the base root media directory
@@ -148,7 +144,6 @@ namespace Emby.Server.Implementations
set => _internalMetadataPath = value;
}
- private const string _virtualInternalMetadataPath = "%MetadataPath%";
- public string VirtualInternalMetadataPath => _virtualInternalMetadataPath;
+ public string VirtualInternalMetadataPath { get; } = "%MetadataPath%";
}
}
diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
index 271188314..16507466f 100644
--- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
@@ -6,7 +6,7 @@ using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Sorting
{
- class AiredEpisodeOrderComparer : IBaseItemComparer
+ public class AiredEpisodeOrderComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
index 942e84704..46e0dd918 100644
--- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
@@ -5,7 +5,7 @@ using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Sorting
{
- class SeriesSortNameComparer : IBaseItemComparer
+ public class SeriesSortNameComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.