Merge branch 'master' into httpclient

This commit is contained in:
Bond-009
2019-03-27 16:34:26 +01:00
committed by GitHub
236 changed files with 4786 additions and 9298 deletions

View File

@@ -11,6 +11,12 @@ namespace MediaBrowser.Common.Configuration
/// <value>The program data path.</value>
string ProgramDataPath { get; }
/// <summary>
/// Gets the path to the web UI resources folder
/// </summary>
/// <value>The web UI resources path.</value>
string WebPath { get; }
/// <summary>
/// Gets the path to the program system folder
/// </summary>

View File

@@ -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
/// </summary>
public static class BaseExtensions
{
public static ICryptoProvider CryptographyProvider { get; set; }
/// <summary>
/// Strips the HTML.
/// </summary>
@@ -31,7 +30,10 @@ namespace MediaBrowser.Common.Extensions
/// <returns>Guid.</returns>
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)));
}
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Events;
@@ -72,6 +71,12 @@ namespace MediaBrowser.Common
/// <value>The application user agent.</value>
string ApplicationUserAgent { get; }
/// <summary>
/// Gets the email address for use within a comment section of a user agent field.
/// Presently used to provide contact information to MusicBrainz service.
/// </summary>
string ApplicationUserAgentAddress { get; }
/// <summary>
/// Gets the exports.
/// </summary>
@@ -107,7 +112,7 @@ namespace MediaBrowser.Common
/// <summary>
/// Inits this instance.
/// </summary>
Task Init(IServiceCollection serviceCollection);
Task InitAsync(IServiceCollection serviceCollection);
/// <summary>
/// Creates the instance.

View File

@@ -9,8 +9,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Jellyfin Project")]
[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")]
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")]
[assembly: AssemblyProduct("Jellyfin Server")]
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]

View File

@@ -0,0 +1,18 @@
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Providers;
namespace MediaBrowser.Common.Providers
{
public class SubtitleConfigurationFactory : IConfigurationFactory
{
public IEnumerable<ConfigurationStore> GetConfigurations()
{
yield return new ConfigurationStore()
{
Key = "subtitles",
ConfigurationType = typeof(SubtitleOptions)
};
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using MediaBrowser.Model.System;
namespace MediaBrowser.Common.System
{
public static class OperatingSystem
{
// We can't use Interlocked.CompareExchange for enums
private static int _id = int.MaxValue;
public static OperatingSystemId Id
{
get
{
if (_id == int.MaxValue)
{
Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
}
return (OperatingSystemId)_id;
}
}
public static string Name
{
get
{
switch (Id)
{
case OperatingSystemId.BSD: return "BSD";
case OperatingSystemId.Linux: return "Linux";
case OperatingSystemId.Darwin: return "macOS";
case OperatingSystemId.Windows: return "Windows";
default: throw new Exception($"Unknown OS {Id}");
}
}
}
private static OperatingSystemId GetId()
{
switch (Environment.OSVersion.Platform)
{
// On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
case PlatformID.MacOSX:
return OperatingSystemId.Darwin;
case PlatformID.Win32NT:
return OperatingSystemId.Windows;
case PlatformID.Unix:
default:
{
string osDescription = RuntimeInformation.OSDescription;
if (osDescription.IndexOf("linux", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.Linux;
}
else if (osDescription.IndexOf("darwin", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.Darwin;
}
else if (osDescription.IndexOf("bsd", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.BSD;
}
throw new Exception($"Can't resolve OS with description: '{osDescription}'");
}
}
}
}
}