diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 484942946..e15cb68e9 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -200,7 +200,7 @@ namespace Emby.Server.Implementations
///
/// The disposable parts
///
- protected readonly List _disposableParts = new List();
+ private readonly List _disposableParts = new List();
///
/// Gets the configuration manager.
@@ -216,8 +216,9 @@ namespace Emby.Server.Implementations
{
#if BETA
return PackageVersionClass.Beta;
-#endif
+#else
return PackageVersionClass.Release;
+#endif
}
}
@@ -340,7 +341,6 @@ namespace Emby.Server.Implementations
protected IProcessFactory ProcessFactory { get; private set; }
- protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
protected readonly IXmlSerializer XmlSerializer;
protected ISocketFactory SocketFactory { get; private set; }
@@ -369,9 +369,6 @@ namespace Emby.Server.Implementations
{
_configuration = configuration;
- // hack alert, until common can target .net core
- BaseExtensions.CryptographyProvider = CryptographyProvider;
-
XmlSerializer = new MyXmlSerializer(fileSystem, loggerFactory);
NetworkManager = networkManager;
@@ -735,13 +732,12 @@ namespace Emby.Server.Implementations
ApplicationHost.StreamHelper = new StreamHelper();
serviceCollection.AddSingleton(StreamHelper);
- serviceCollection.AddSingleton(CryptographyProvider);
+ serviceCollection.AddSingleton(typeof(ICryptoProvider), typeof(CryptographyProvider));
SocketFactory = new SocketFactory();
serviceCollection.AddSingleton(SocketFactory);
- InstallationManager = new InstallationManager(LoggerFactory, this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, ZipClient, PackageRuntime);
- serviceCollection.AddSingleton(InstallationManager);
+ serviceCollection.AddSingleton(typeof(IInstallationManager), typeof(InstallationManager));
ZipClient = new ZipClient();
serviceCollection.AddSingleton(ZipClient);
@@ -908,8 +904,6 @@ namespace Emby.Server.Implementations
_serviceProvider = serviceCollection.BuildServiceProvider();
}
- public virtual string PackageRuntime => "netcore";
-
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
{
// Distinct these to prevent users from reporting problems that aren't actually problems
@@ -1049,6 +1043,8 @@ namespace Emby.Server.Implementations
///
protected void FindParts()
{
+ InstallationManager = _serviceProvider.GetService();
+
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
{
ServerConfigurationManager.Configuration.IsPortAuthorized = true;
diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
index 982bba625..6d7193ce2 100644
--- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
+++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
@@ -4,7 +4,6 @@ using System.Globalization;
using System.IO;
using System.Security.Cryptography;
using System.Text;
-using System.Linq;
using MediaBrowser.Model.Cryptography;
namespace Emby.Server.Implementations.Cryptography
@@ -136,7 +135,7 @@ namespace Emby.Server.Implementations.Cryptography
{
return PBKDF2(DefaultHashMethod, bytes, salt, _defaultIterations);
}
-
+
public byte[] ComputeHash(PasswordHash hash)
{
int iterations = _defaultIterations;
diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
index 3d60925da..47552806d 100644
--- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs
@@ -90,9 +90,10 @@ namespace Emby.Server.Implementations.Data
{
throw new ArgumentNullException(nameof(displayPreferences));
}
+
if (string.IsNullOrEmpty(displayPreferences.Id))
{
- throw new ArgumentNullException(nameof(displayPreferences.Id));
+ throw new ArgumentException("Display preferences has an invalid Id", nameof(displayPreferences));
}
cancellationToken.ThrowIfCancellationRequested();
diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
index 038965647..8369f4f59 100644
--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
@@ -388,7 +388,7 @@ namespace Emby.Server.Implementations.EntryPoints
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(),
- CollectionFolders = GetTopParentIds(newAndRemoved, user, allUserRootChildren).ToArray()
+ CollectionFolders = GetTopParentIds(newAndRemoved, allUserRootChildren).ToArray()
};
}
@@ -407,7 +407,7 @@ namespace Emby.Server.Implementations.EntryPoints
return item.SourceType == SourceType.Library;
}
- private IEnumerable GetTopParentIds(List items, User user, List allUserRootChildren)
+ private IEnumerable GetTopParentIds(List items, List allUserRootChildren)
{
var list = new List();
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
index 499a334fc..1027883ed 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
// This code is executed before the service
var auth = AuthorizationContext.GetAuthorizationInfo(request);
- if (!IsExemptFromAuthenticationToken(auth, authAttribtues, request))
+ if (!IsExemptFromAuthenticationToken(authAttribtues, request))
{
ValidateSecurityToken(request, auth.Token);
}
@@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
}
}
- private bool IsExemptFromAuthenticationToken(AuthorizationInfo auth, IAuthenticationAttributes authAttribtues, IRequest request)
+ private bool IsExemptFromAuthenticationToken(IAuthenticationAttributes authAttribtues, IRequest request)
{
if (!_config.Configuration.IsStartupWizardCompleted && authAttribtues.AllowBeforeStartupWizard)
{
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
index cf30bbc32..324f9085e 100644
--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -14,8 +13,6 @@ namespace Emby.Server.Implementations.HttpServer
///
public class StreamWriter : IAsyncStreamWriter, IHasHeaders
{
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
///
/// Gets or sets the source stream.
///
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 58b3b6a69..7b210d231 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public string HomePageUrl => "https://github.com/jellyfin/jellyfin";
- public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress progress)
+ public async Task RefreshSeriesTimers(CancellationToken cancellationToken)
{
var seriesTimers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
@@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- public async Task RefreshTimers(CancellationToken cancellationToken, IProgress progress)
+ public async Task RefreshTimers(CancellationToken cancellationToken)
{
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index f7ef16fb0..9093d9740 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1087,8 +1087,8 @@ namespace Emby.Server.Implementations.LiveTv
if (coreService != null)
{
- await coreService.RefreshSeriesTimers(cancellationToken, new SimpleProgress()).ConfigureAwait(false);
- await coreService.RefreshTimers(cancellationToken, new SimpleProgress()).ConfigureAwait(false);
+ await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false);
+ await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false);
}
// Load these now which will prefetch metadata
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
index 588dcb843..2d9bec53f 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
@@ -10,14 +10,12 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
@@ -52,9 +50,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var channelIdPrefix = GetFullChannelIdPrefix(info);
- var result = await new M3uParser(Logger, _httpClient, _appHost).Parse(info.Url, channelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
-
- return result.Cast().ToList();
+ return await new M3uParser(Logger, _httpClient, _appHost).Parse(info.Url, channelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
}
public Task> GetTunerInfos(CancellationToken cancellationToken)
@@ -73,7 +69,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return Task.FromResult(list);
}
- private string[] _disallowedSharedStreamExtensions = new string[]
+ private static readonly string[] _disallowedSharedStreamExtensions = new string[]
{
".mkv",
".mp4",
@@ -88,9 +84,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
if (tunerCount > 0)
{
var tunerHostId = info.Id;
- var liveStreams = currentLiveStreams.Where(i => string.Equals(i.TunerHostId, tunerHostId, StringComparison.OrdinalIgnoreCase)).ToList();
+ var liveStreams = currentLiveStreams.Where(i => string.Equals(i.TunerHostId, tunerHostId, StringComparison.OrdinalIgnoreCase));
- if (liveStreams.Count >= tunerCount)
+ if (liveStreams.Count() >= tunerCount)
{
throw new LiveTvConflictException("M3U simultaneous stream limit has been reached.");
}
@@ -98,7 +94,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var sources = await GetChannelStreamMediaSources(info, channelInfo, cancellationToken).ConfigureAwait(false);
- var mediaSource = sources.First();
+ var mediaSource = sources[0];
if (mediaSource.Protocol == MediaProtocol.Http && !mediaSource.RequiresLooping)
{
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index ad124bb0f..814031b12 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -11,7 +11,6 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
@@ -62,12 +61,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return Task.FromResult((Stream)File.OpenRead(url));
}
- const string ExtInfPrefix = "#EXTINF:";
+ private const string ExtInfPrefix = "#EXTINF:";
+
private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId)
{
var channels = new List();
string line;
- string extInf = "";
+ string extInf = string.Empty;
while ((line = reader.ReadLine()) != null)
{
@@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
channel.Path = line;
channels.Add(channel);
- extInf = "";
+ extInf = string.Empty;
}
}
@@ -110,8 +110,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl)
{
- var channel = new ChannelInfo();
- channel.TunerHostId = tunerHostId;
+ var channel = new ChannelInfo()
+ {
+ TunerHostId = tunerHostId
+ };
extInf = extInf.Trim();
@@ -137,13 +139,15 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
channelIdValues.Add(channelId);
}
+
if (!string.IsNullOrWhiteSpace(tvgId))
{
channelIdValues.Add(tvgId);
}
+
if (channelIdValues.Count > 0)
{
- channel.Id = string.Join("_", channelIdValues.ToArray());
+ channel.Id = string.Join("_", channelIdValues);
}
return channel;
@@ -152,7 +156,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private string GetChannelNumber(string extInf, Dictionary attributes, string mediaUrl)
{
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
+ var nameInExtInf = nameParts.Length > 1 ? nameParts[nameParts.Length - 1].Trim() : null;
string numberString = null;
string attributeValue;
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 301802b8a..7310de55d 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -12,7 +12,6 @@ using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Progress;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
@@ -39,11 +38,10 @@ namespace Emby.Server.Implementations.Updates
///
/// The completed installations
///
- private ConcurrentBag CompletedInstallationsInternal { get; set; }
+ private ConcurrentBag _completedInstallationsInternal;
- public IEnumerable CompletedInstallations => CompletedInstallationsInternal;
+ public IEnumerable CompletedInstallations => _completedInstallationsInternal;
- #region PluginUninstalled Event
///
/// Occurs when [plugin uninstalled].
///
@@ -57,9 +55,7 @@ namespace Emby.Server.Implementations.Updates
{
PluginUninstalled?.Invoke(this, new GenericEventArgs { Argument = plugin });
}
- #endregion
- #region PluginUpdated Event
///
/// Occurs when [plugin updated].
///
@@ -77,9 +73,7 @@ namespace Emby.Server.Implementations.Updates
_applicationHost.NotifyPendingRestart();
}
- #endregion
- #region PluginInstalled Event
///
/// Occurs when [plugin updated].
///
@@ -96,7 +90,6 @@ namespace Emby.Server.Implementations.Updates
_applicationHost.NotifyPendingRestart();
}
- #endregion
///
/// The _logger
@@ -115,12 +108,8 @@ namespace Emby.Server.Implementations.Updates
/// The application host.
private readonly IApplicationHost _applicationHost;
- private readonly ICryptoProvider _cryptographyProvider;
private readonly IZipClient _zipClient;
- // netframework or netcore
- private readonly string _packageRuntime;
-
public InstallationManager(
ILoggerFactory loggerFactory,
IApplicationHost appHost,
@@ -129,9 +118,7 @@ namespace Emby.Server.Implementations.Updates
IJsonSerializer jsonSerializer,
IServerConfigurationManager config,
IFileSystem fileSystem,
- ICryptoProvider cryptographyProvider,
- IZipClient zipClient,
- string packageRuntime)
+ IZipClient zipClient)
{
if (loggerFactory == null)
{
@@ -139,18 +126,16 @@ namespace Emby.Server.Implementations.Updates
}
CurrentInstallations = new List>();
- CompletedInstallationsInternal = new ConcurrentBag();
+ _completedInstallationsInternal = new ConcurrentBag();
+ _logger = loggerFactory.CreateLogger(nameof(InstallationManager));
_applicationHost = appHost;
_appPaths = appPaths;
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_config = config;
_fileSystem = fileSystem;
- _cryptographyProvider = cryptographyProvider;
_zipClient = zipClient;
- _packageRuntime = packageRuntime;
- _logger = loggerFactory.CreateLogger(nameof(InstallationManager));
}
private static Version GetPackageVersion(PackageVersionInfo version)
@@ -222,11 +207,6 @@ namespace Emby.Server.Implementations.Updates
continue;
}
- if (string.IsNullOrEmpty(version.runtimes) || version.runtimes.IndexOf(_packageRuntime, StringComparison.OrdinalIgnoreCase) == -1)
- {
- continue;
- }
-
versions.Add(version);
}
@@ -448,7 +428,7 @@ namespace Emby.Server.Implementations.Updates
CurrentInstallations.Remove(tuple);
}
- CompletedInstallationsInternal.Add(installationInfo);
+ _completedInstallationsInternal.Add(installationInfo);
PackageInstallationCompleted?.Invoke(this, installationEventArgs);
}
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 82a76c637..d4b10c8c8 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -19,7 +19,6 @@ using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
-using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs
index db0514bb1..40c16b957 100644
--- a/MediaBrowser.Common/Extensions/BaseExtensions.cs
+++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs
@@ -1,6 +1,7 @@
using System;
+using System.Text;
using System.Text.RegularExpressions;
-using MediaBrowser.Model.Cryptography;
+using System.Security.Cryptography;
namespace MediaBrowser.Common.Extensions
{
@@ -9,8 +10,6 @@ namespace MediaBrowser.Common.Extensions
///
public static class BaseExtensions
{
- public static ICryptoProvider CryptographyProvider { get; set; }
-
///
/// Strips the HTML.
///
@@ -31,7 +30,10 @@ namespace MediaBrowser.Common.Extensions
/// Guid.
public static Guid GetMD5(this string str)
{
- return CryptographyProvider.GetMD5(str);
+ using (var provider = MD5.Create())
+ {
+ return new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(str)));
+ }
}
}
}
diff --git a/jellyfin.ruleset b/jellyfin.ruleset
index 0a04b4c55..262121a32 100644
--- a/jellyfin.ruleset
+++ b/jellyfin.ruleset
@@ -20,6 +20,9 @@
+
+
+