From 36f3e933a23d802d154c16fd304a82c3fe3f453d Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Wed, 15 Apr 2020 14:28:42 -0500
Subject: Add quick connect
---
.../QuickConnect/QuickConnectResult.cs | 50 ++++++++++++++++++++
.../QuickConnect/QuickConnectResultDto.cs | 53 ++++++++++++++++++++++
.../QuickConnect/QuickConnectState.cs | 23 ++++++++++
3 files changed, 126 insertions(+)
create mode 100644 MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
create mode 100644 MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
create mode 100644 MediaBrowser.Model/QuickConnect/QuickConnectState.cs
(limited to 'MediaBrowser.Model')
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
new file mode 100644
index 000000000..bc3fd0046
--- /dev/null
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
@@ -0,0 +1,50 @@
+using System;
+
+namespace MediaBrowser.Model.QuickConnect
+{
+ ///
+ /// Stores the result of an incoming quick connect request.
+ ///
+ public class QuickConnectResult
+ {
+ ///
+ /// Gets a value indicating whether this request is authorized.
+ ///
+ public bool Authenticated => !string.IsNullOrEmpty(Authentication);
+
+ ///
+ /// Gets or sets the secret value used to uniquely identify this request. Can be used to retrieve authentication information.
+ ///
+ public string Secret { get; set; }
+
+ ///
+ /// Gets or sets the public value used to uniquely identify this request. Can only be used to authorize the request.
+ ///
+ public string Lookup { get; set; }
+
+ ///
+ /// Gets or sets the user facing code used so the user can quickly differentiate this request from others.
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// Gets or sets the device friendly name.
+ ///
+ public string FriendlyName { get; set; }
+
+ ///
+ /// Gets or sets the private access token.
+ ///
+ public string Authentication { get; set; }
+
+ ///
+ /// Gets or sets an error message.
+ ///
+ public string Error { get; set; }
+
+ ///
+ /// Gets or sets the DateTime that this request was created.
+ ///
+ public DateTime DateAdded { get; set; }
+ }
+}
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
new file mode 100644
index 000000000..671b7cc94
--- /dev/null
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
@@ -0,0 +1,53 @@
+using System;
+
+namespace MediaBrowser.Model.QuickConnect
+{
+ ///
+ /// Stores the non-sensitive results of an incoming quick connect request.
+ ///
+ public class QuickConnectResultDto
+ {
+ ///
+ /// Gets a value indicating whether this request is authorized.
+ ///
+ public bool Authenticated { get; private set; }
+
+ ///
+ /// Gets the user facing code used so the user can quickly differentiate this request from others.
+ ///
+ public string Code { get; private set; }
+
+ ///
+ /// Gets the public value used to uniquely identify this request. Can only be used to authorize the request.
+ ///
+ public string Lookup { get; private set; }
+
+ ///
+ /// Gets the device friendly name.
+ ///
+ public string FriendlyName { get; private set; }
+
+ ///
+ /// Gets the DateTime that this request was created.
+ ///
+ public DateTime DateAdded { get; private set; }
+
+ ///
+ /// Cast an internal quick connect result to a DTO by removing all sensitive properties.
+ ///
+ /// QuickConnectResult object to cast
+ public static implicit operator QuickConnectResultDto(QuickConnectResult result)
+ {
+ QuickConnectResultDto resultDto = new QuickConnectResultDto
+ {
+ Authenticated = result.Authenticated,
+ Code = result.Code,
+ FriendlyName = result.FriendlyName,
+ DateAdded = result.DateAdded,
+ Lookup = result.Lookup
+ };
+
+ return resultDto;
+ }
+ }
+}
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectState.cs b/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
new file mode 100644
index 000000000..9f250519b
--- /dev/null
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
@@ -0,0 +1,23 @@
+namespace MediaBrowser.Model.QuickConnect
+{
+ ///
+ /// Quick connect state.
+ ///
+ public enum QuickConnectState
+ {
+ ///
+ /// This feature has not been opted into and is unavailable until the server administrator chooses to opt-in.
+ ///
+ Unavailable,
+
+ ///
+ /// The feature is enabled for use on the server but is not currently accepting connection requests.
+ ///
+ Available,
+
+ ///
+ /// The feature is actively accepting connection requests.
+ ///
+ Active
+ }
+}
--
cgit v1.2.3
From 70e50dfa90575cc5e906be1509d3ed363eb1ada4 Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Fri, 24 Apr 2020 18:51:19 -0500
Subject: Apply suggestions from code review
---
.../QuickConnect/ConfigurationExtension.cs | 2 --
Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs | 8 +++-----
MediaBrowser.Model/QuickConnect/QuickConnectState.cs | 6 +++---
3 files changed, 6 insertions(+), 10 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
index 0e35ba80a..458bb7614 100644
--- a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
+++ b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index e24dc3a67..b8b51adb6 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.QuickConnect
/// Should only be called at server startup when a singleton is created.
///
/// Configuration.
- /// Logger.
+ /// Logger.
/// User manager.
/// Localization.
/// JSON serializer.
@@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.QuickConnect
/// Task scheduler.
public QuickConnectManager(
IServerConfigurationManager config,
- ILoggerFactory loggerFactory,
+ ILogger logger,
IUserManager userManager,
ILocalizationManager localization,
IJsonSerializer jsonSerializer,
@@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.QuickConnect
ITaskManager taskManager)
{
_config = config;
- _logger = loggerFactory.CreateLogger(nameof(QuickConnectManager));
+ _logger = logger;
_userManager = userManager;
_localizationManager = localization;
_jsonSerializer = jsonSerializer;
@@ -196,8 +196,6 @@ namespace Emby.Server.Implementations.QuickConnect
///
public string GenerateCode()
{
- // TODO: output may be biased
-
int min = (int)Math.Pow(10, CodeLength - 1);
int max = (int)Math.Pow(10, CodeLength);
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectState.cs b/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
index 9f250519b..f1074f25f 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectState.cs
@@ -8,16 +8,16 @@ namespace MediaBrowser.Model.QuickConnect
///
/// This feature has not been opted into and is unavailable until the server administrator chooses to opt-in.
///
- Unavailable,
+ Unavailable = 0,
///
/// The feature is enabled for use on the server but is not currently accepting connection requests.
///
- Available,
+ Available = 1,
///
/// The feature is actively accepting connection requests.
///
- Active
+ Active = 2
}
}
--
cgit v1.2.3
From 0d6a63bf84d7ad971128c6ba6cad77e76e023536 Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Mon, 8 Jun 2020 15:48:18 -0500
Subject: Make all properties nullable
---
.../QuickConnect/ConfigurationExtension.cs | 2 ++
.../QuickConnect/QuickConnectConfiguration.cs | 2 ++
.../QuickConnect/QuickConnectManager.cs | 10 ++++++----
MediaBrowser.Model/QuickConnect/QuickConnectResult.cs | 14 +++++++-------
MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs | 8 ++++----
5 files changed, 21 insertions(+), 15 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
index 458bb7614..0e35ba80a 100644
--- a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
+++ b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
index befc46379..11e558bae 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
@@ -1,3 +1,5 @@
+#pragma warning disable CS1591
+
using MediaBrowser.Model.QuickConnect;
namespace Emby.Server.Implementations.QuickConnect
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index b8b51adb6..929e021a3 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -234,7 +234,8 @@ namespace Emby.Server.Implementations.QuickConnect
result.Authentication = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
// Advance the time on the request so it expires sooner as the client will pick up the changes in a few seconds
- result.DateAdded = result.DateAdded.Subtract(new TimeSpan(0, RequestExpiry - 1, 0));
+ var added = result.DateAdded ?? DateTime.Now.Subtract(new TimeSpan(0, RequestExpiry, 0));
+ result.DateAdded = added.Subtract(new TimeSpan(0, RequestExpiry - 1, 0));
_authenticationRepository.Create(new AuthenticationInfo
{
@@ -284,7 +285,7 @@ namespace Emby.Server.Implementations.QuickConnect
{
bool expireAll = false;
- // check if quick connect should be deactivated
+ // Check if quick connect should be deactivated
if (TemporaryActivation && DateTime.Now > DateActivated.AddMinutes(10) && State == QuickConnectState.Active)
{
_logger.LogDebug("Quick connect time expired, deactivating");
@@ -293,13 +294,14 @@ namespace Emby.Server.Implementations.QuickConnect
TemporaryActivation = false;
}
- // expire stale connection requests
+ // Expire stale connection requests
var delete = new List();
var values = _currentRequests.Values.ToList();
for (int i = 0; i < _currentRequests.Count; i++)
{
- if (DateTime.Now > values[i].DateAdded.AddMinutes(RequestExpiry) || expireAll)
+ var added = values[i].DateAdded ?? DateTime.UnixEpoch;
+ if (DateTime.Now > added.AddMinutes(RequestExpiry) || expireAll)
{
delete.Add(values[i].Lookup);
}
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
index bc3fd0046..32d7f6aba 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
@@ -15,36 +15,36 @@ namespace MediaBrowser.Model.QuickConnect
///
/// Gets or sets the secret value used to uniquely identify this request. Can be used to retrieve authentication information.
///
- public string Secret { get; set; }
+ public string? Secret { get; set; }
///
/// Gets or sets the public value used to uniquely identify this request. Can only be used to authorize the request.
///
- public string Lookup { get; set; }
+ public string? Lookup { get; set; }
///
/// Gets or sets the user facing code used so the user can quickly differentiate this request from others.
///
- public string Code { get; set; }
+ public string? Code { get; set; }
///
/// Gets or sets the device friendly name.
///
- public string FriendlyName { get; set; }
+ public string? FriendlyName { get; set; }
///
/// Gets or sets the private access token.
///
- public string Authentication { get; set; }
+ public string? Authentication { get; set; }
///
/// Gets or sets an error message.
///
- public string Error { get; set; }
+ public string? Error { get; set; }
///
/// Gets or sets the DateTime that this request was created.
///
- public DateTime DateAdded { get; set; }
+ public DateTime? DateAdded { get; set; }
}
}
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
index 671b7cc94..19acc7cd8 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
@@ -15,22 +15,22 @@ namespace MediaBrowser.Model.QuickConnect
///
/// Gets the user facing code used so the user can quickly differentiate this request from others.
///
- public string Code { get; private set; }
+ public string? Code { get; private set; }
///
/// Gets the public value used to uniquely identify this request. Can only be used to authorize the request.
///
- public string Lookup { get; private set; }
+ public string? Lookup { get; private set; }
///
/// Gets the device friendly name.
///
- public string FriendlyName { get; private set; }
+ public string? FriendlyName { get; private set; }
///
/// Gets the DateTime that this request was created.
///
- public DateTime DateAdded { get; private set; }
+ public DateTime? DateAdded { get; private set; }
///
/// Cast an internal quick connect result to a DTO by removing all sensitive properties.
--
cgit v1.2.3
From 4be476ec5312387f87134915d0fd132b2ad5fa3f Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Thu, 18 Jun 2020 01:29:47 -0500
Subject: Move all settings into the main server configuration
Decreased the timeout from 30 minutes to 5.
Public lookup values have been replaced with the short code.
---
.../QuickConnect/ConfigurationExtension.cs | 20 -------
.../QuickConnect/QuickConnectConfiguration.cs | 15 -----
.../QuickConnectConfigurationFactory.cs | 27 ---------
.../QuickConnect/QuickConnectManager.cs | 66 ++++++++++------------
.../QuickConnect/IQuickConnect.cs | 8 +--
.../Configuration/ServerConfiguration.cs | 6 ++
.../QuickConnect/QuickConnectResult.cs | 5 --
.../QuickConnect/QuickConnectResultDto.cs | 14 +----
8 files changed, 41 insertions(+), 120 deletions(-)
delete mode 100644 Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
delete mode 100644 Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
delete mode 100644 Emby.Server.Implementations/QuickConnect/QuickConnectConfigurationFactory.cs
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
deleted file mode 100644
index 2a19fc36c..000000000
--- a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using MediaBrowser.Common.Configuration;
-
-namespace Emby.Server.Implementations.QuickConnect
-{
- ///
- /// Configuration extension to support persistent quick connect configuration.
- ///
- public static class ConfigurationExtension
- {
- ///
- /// Return the current quick connect configuration.
- ///
- /// Configuration manager.
- /// Current quick connect configuration.
- public static QuickConnectConfiguration GetQuickConnectConfiguration(this IConfigurationManager manager)
- {
- return manager.GetConfiguration("quickconnect");
- }
- }
-}
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
deleted file mode 100644
index 2302ddbc3..000000000
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using MediaBrowser.Model.QuickConnect;
-
-namespace Emby.Server.Implementations.QuickConnect
-{
- ///
- /// Persistent quick connect configuration.
- ///
- public class QuickConnectConfiguration
- {
- ///
- /// Gets or sets persistent quick connect availability state.
- ///
- public QuickConnectState State { get; set; }
- }
-}
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectConfigurationFactory.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectConfigurationFactory.cs
deleted file mode 100644
index d7bc84c5e..000000000
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectConfigurationFactory.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System.Collections.Generic;
-using MediaBrowser.Common.Configuration;
-
-namespace Emby.Server.Implementations.QuickConnect
-{
- ///
- /// Configuration factory for quick connect.
- ///
- public class QuickConnectConfigurationFactory : IConfigurationFactory
- {
- ///
- /// Returns the current quick connect configuration.
- ///
- /// Current quick connect configuration.
- public IEnumerable GetConfigurations()
- {
- return new[]
- {
- new ConfigurationStore
- {
- Key = "quickconnect",
- ConfigurationType = typeof(QuickConnectConfiguration)
- }
- };
- }
- }
-}
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index 7a584c7cd..8d704f32b 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -11,7 +11,9 @@ using MediaBrowser.Controller.QuickConnect;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.QuickConnect;
using MediaBrowser.Model.Services;
+using MediaBrowser.Common;
using Microsoft.Extensions.Logging;
+using MediaBrowser.Common.Extensions;
namespace Emby.Server.Implementations.QuickConnect
{
@@ -64,9 +66,7 @@ namespace Emby.Server.Implementations.QuickConnect
public QuickConnectState State { get; private set; } = QuickConnectState.Unavailable;
///
- public int RequestExpiry { get; set; } = 30;
-
- private bool TemporaryActivation { get; set; } = false;
+ public int Timeout { get; set; } = 5;
private DateTime DateActivated { get; set; }
@@ -82,10 +82,9 @@ namespace Emby.Server.Implementations.QuickConnect
///
public QuickConnectResult Activate()
{
- // This should not call SetEnabled since that would persist the "temporary" activation to the configuration file
- State = QuickConnectState.Active;
+ SetEnabled(QuickConnectState.Active);
+
DateActivated = DateTime.Now;
- TemporaryActivation = true;
return new QuickConnectResult();
}
@@ -96,12 +95,10 @@ namespace Emby.Server.Implementations.QuickConnect
_logger.LogDebug("Changed quick connect state from {0} to {1}", State, newState);
ExpireRequests(true);
- State = newState;
- _config.SaveConfiguration("quickconnect", new QuickConnectConfiguration()
- {
- State = State
- });
+ State = newState;
+ _config.Configuration.QuickConnectAvailable = newState == QuickConnectState.Available || newState == QuickConnectState.Active;
+ _config.SaveConfiguration();
_logger.LogDebug("Configuration saved");
}
@@ -123,17 +120,16 @@ namespace Emby.Server.Implementations.QuickConnect
_logger.LogDebug("Got new quick connect request from {friendlyName}", friendlyName);
- var lookup = GenerateSecureRandom();
+ var code = GenerateCode();
var result = new QuickConnectResult()
{
- Lookup = lookup,
Secret = GenerateSecureRandom(),
FriendlyName = friendlyName,
DateAdded = DateTime.Now,
- Code = GenerateCode()
+ Code = code
};
- _currentRequests[lookup] = result;
+ _currentRequests[code] = result;
return result;
}
@@ -143,17 +139,16 @@ namespace Emby.Server.Implementations.QuickConnect
ExpireRequests();
AssertActive();
- string lookup = _currentRequests.Where(x => x.Value.Secret == secret).Select(x => x.Value.Lookup).DefaultIfEmpty(string.Empty).First();
+ string code = _currentRequests.Where(x => x.Value.Secret == secret).Select(x => x.Value.Code).DefaultIfEmpty(string.Empty).First();
- if (!_currentRequests.TryGetValue(lookup, out QuickConnectResult result))
+ if (!_currentRequests.TryGetValue(code, out QuickConnectResult result))
{
- throw new KeyNotFoundException("Unable to find request with provided identifier");
+ throw new ResourceNotFoundException("Unable to find request with provided secret");
}
return result;
}
- ///
public List GetCurrentRequests()
{
return GetCurrentRequestsInternal().Select(x => (QuickConnectResultDto)x).ToList();
@@ -186,16 +181,16 @@ namespace Emby.Server.Implementations.QuickConnect
}
///
- public bool AuthorizeRequest(IRequest request, string lookup)
+ public bool AuthorizeRequest(IRequest request, string code)
{
ExpireRequests();
AssertActive();
var auth = _authContext.GetAuthorizationInfo(request);
- if (!_currentRequests.TryGetValue(lookup, out QuickConnectResult result))
+ if (!_currentRequests.TryGetValue(code, out QuickConnectResult result))
{
- throw new KeyNotFoundException("Unable to find request");
+ throw new ResourceNotFoundException("Unable to find request");
}
if (result.Authenticated)
@@ -205,9 +200,9 @@ namespace Emby.Server.Implementations.QuickConnect
result.Authentication = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
- // Advance the time on the request so it expires sooner as the client will pick up the changes in a few seconds
- var added = result.DateAdded ?? DateTime.Now.Subtract(new TimeSpan(0, RequestExpiry, 0));
- result.DateAdded = added.Subtract(new TimeSpan(0, RequestExpiry - 1, 0));
+ // Change the time on the request so it expires one minute into the future. It can't expire immediately as otherwise some clients wouldn't ever see that they have been authenticated.
+ var added = result.DateAdded ?? DateTime.Now.Subtract(new TimeSpan(0, Timeout, 0));
+ result.DateAdded = added.Subtract(new TimeSpan(0, Timeout - 1, 0));
_authenticationRepository.Create(new AuthenticationInfo
{
@@ -271,7 +266,7 @@ namespace Emby.Server.Implementations.QuickConnect
var bytes = new byte[length];
_rng.GetBytes(bytes);
- return string.Join(string.Empty, bytes.Select(x => x.ToString("x2", CultureInfo.InvariantCulture)));
+ return Hex.Encode(bytes);
}
///
@@ -281,12 +276,11 @@ namespace Emby.Server.Implementations.QuickConnect
private void ExpireRequests(bool expireAll = false)
{
// Check if quick connect should be deactivated
- if (TemporaryActivation && DateTime.Now > DateActivated.AddMinutes(10) && State == QuickConnectState.Active && !expireAll)
+ if (State == QuickConnectState.Active && DateTime.Now > DateActivated.AddMinutes(Timeout) && !expireAll)
{
_logger.LogDebug("Quick connect time expired, deactivating");
SetEnabled(QuickConnectState.Available);
expireAll = true;
- TemporaryActivation = false;
}
// Expire stale connection requests
@@ -296,28 +290,28 @@ namespace Emby.Server.Implementations.QuickConnect
for (int i = 0; i < values.Count; i++)
{
var added = values[i].DateAdded ?? DateTime.UnixEpoch;
- if (DateTime.Now > added.AddMinutes(RequestExpiry) || expireAll)
+ if (DateTime.Now > added.AddMinutes(Timeout) || expireAll)
{
- delete.Add(values[i].Lookup);
+ delete.Add(values[i].Code);
}
}
- foreach (var lookup in delete)
+ foreach (var code in delete)
{
- _logger.LogDebug("Removing expired request {lookup}", lookup);
+ _logger.LogDebug("Removing expired request {code}", code);
- if (!_currentRequests.TryRemove(lookup, out _))
+ if (!_currentRequests.TryRemove(code, out _))
{
- _logger.LogWarning("Request {lookup} already expired", lookup);
+ _logger.LogWarning("Request {code} already expired", code);
}
}
}
private void ReloadConfiguration()
{
- var config = _config.GetQuickConnectConfiguration();
+ var available = _config.Configuration.QuickConnectAvailable;
- State = config.State;
+ State = available ? QuickConnectState.Available : QuickConnectState.Unavailable;
}
}
}
diff --git a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
index d44765e11..d31d0e509 100644
--- a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
+++ b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
@@ -26,9 +26,9 @@ namespace MediaBrowser.Controller.QuickConnect
public QuickConnectState State { get; }
///
- /// Gets or sets the time (in minutes) before a pending request will expire.
+ /// Gets or sets the time (in minutes) before quick connect will automatically deactivate.
///
- public int RequestExpiry { get; set; }
+ public int Timeout { get; set; }
///
/// Assert that quick connect is currently active and throws an exception if it is not.
@@ -77,9 +77,9 @@ namespace MediaBrowser.Controller.QuickConnect
/// Authorizes a quick connect request to connect as the calling user.
///
/// HTTP request object.
- /// Public request lookup value.
+ /// Identifying code for the request..
/// A boolean indicating if the authorization completed successfully.
- bool AuthorizeRequest(IRequest request, string lookup);
+ bool AuthorizeRequest(IRequest request, string code);
///
/// Deletes all quick connect access tokens for the provided user.
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index afbe02dd3..76b290606 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -76,6 +76,11 @@ namespace MediaBrowser.Model.Configuration
/// true if this instance is port authorized; otherwise, false.
public bool IsPortAuthorized { get; set; }
+ ///
+ /// Gets or sets if quick connect is available for use on this server.
+ ///
+ public bool QuickConnectAvailable { get; set; }
+
public bool AutoRunWebApp { get; set; }
public bool EnableRemoteAccess { get; set; }
@@ -281,6 +286,7 @@ namespace MediaBrowser.Model.Configuration
AutoRunWebApp = true;
EnableRemoteAccess = true;
+ QuickConnectAvailable = false;
EnableUPnP = false;
MinResumePct = 5;
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
index 32d7f6aba..a10d60d57 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
@@ -17,11 +17,6 @@ namespace MediaBrowser.Model.QuickConnect
///
public string? Secret { get; set; }
- ///
- /// Gets or sets the public value used to uniquely identify this request. Can only be used to authorize the request.
- ///
- public string? Lookup { get; set; }
-
///
/// Gets or sets the user facing code used so the user can quickly differentiate this request from others.
///
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
index 19acc7cd8..26084caf1 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
@@ -17,25 +17,15 @@ namespace MediaBrowser.Model.QuickConnect
///
public string? Code { get; private set; }
- ///
- /// Gets the public value used to uniquely identify this request. Can only be used to authorize the request.
- ///
- public string? Lookup { get; private set; }
-
///
/// Gets the device friendly name.
///
public string? FriendlyName { get; private set; }
- ///
- /// Gets the DateTime that this request was created.
- ///
- public DateTime? DateAdded { get; private set; }
-
///
/// Cast an internal quick connect result to a DTO by removing all sensitive properties.
///
- /// QuickConnectResult object to cast
+ /// QuickConnectResult object to cast.
public static implicit operator QuickConnectResultDto(QuickConnectResult result)
{
QuickConnectResultDto resultDto = new QuickConnectResultDto
@@ -43,8 +33,6 @@ namespace MediaBrowser.Model.QuickConnect
Authenticated = result.Authenticated,
Code = result.Code,
FriendlyName = result.FriendlyName,
- DateAdded = result.DateAdded,
- Lookup = result.Lookup
};
return resultDto;
--
cgit v1.2.3
From 329980c727cf03587ff5f4011a3af3ef2fa5e4f1 Mon Sep 17 00:00:00 2001
From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Thu, 18 Jun 2020 01:58:58 -0500
Subject: API cleanup
---
.../QuickConnect/QuickConnectManager.cs | 35 +++--------
.../QuickConnect/QuickConnectService.cs | 67 ++++------------------
.../QuickConnect/IQuickConnect.cs | 23 +++-----
.../QuickConnect/QuickConnectResultDto.cs | 41 -------------
4 files changed, 27 insertions(+), 139 deletions(-)
delete mode 100644 MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index 8d704f32b..263556e9d 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -75,18 +75,15 @@ namespace Emby.Server.Implementations.QuickConnect
{
if (State != QuickConnectState.Active)
{
- throw new InvalidOperationException("Quick connect is not active on this server");
+ throw new ArgumentException("Quick connect is not active on this server");
}
}
///
- public QuickConnectResult Activate()
+ public void Activate()
{
- SetEnabled(QuickConnectState.Active);
-
DateActivated = DateTime.Now;
-
- return new QuickConnectResult();
+ SetEnabled(QuickConnectState.Active);
}
///
@@ -149,19 +146,6 @@ namespace Emby.Server.Implementations.QuickConnect
return result;
}
- public List GetCurrentRequests()
- {
- return GetCurrentRequestsInternal().Select(x => (QuickConnectResultDto)x).ToList();
- }
-
- ///
- public List GetCurrentRequestsInternal()
- {
- ExpireRequests();
- AssertActive();
- return _currentRequests.Values.ToList();
- }
-
///
public string GenerateCode()
{
@@ -215,7 +199,7 @@ namespace Emby.Server.Implementations.QuickConnect
UserId = auth.UserId
});
- _logger.LogInformation("Allowing device {0} to login as user {1} with quick connect code {2}", result.FriendlyName, auth.User.Name, result.Code);
+ _logger.LogInformation("Allowing device {0} to login as user {1} with quick connect code {2}", result.FriendlyName, auth.User.Username, result.Code);
return true;
}
@@ -269,11 +253,8 @@ namespace Emby.Server.Implementations.QuickConnect
return Hex.Encode(bytes);
}
- ///
- /// Expire quick connect requests that are over the time limit. If is true, all requests are unconditionally expired.
- ///
- /// If true, all requests will be expired.
- private void ExpireRequests(bool expireAll = false)
+ ///
+ public void ExpireRequests(bool expireAll = false)
{
// Check if quick connect should be deactivated
if (State == QuickConnectState.Active && DateTime.Now > DateActivated.AddMinutes(Timeout) && !expireAll)
@@ -309,9 +290,7 @@ namespace Emby.Server.Implementations.QuickConnect
private void ReloadConfiguration()
{
- var available = _config.Configuration.QuickConnectAvailable;
-
- State = available ? QuickConnectState.Available : QuickConnectState.Unavailable;
+ State = _config.Configuration.QuickConnectAvailable ? QuickConnectState.Available : QuickConnectState.Unavailable;
}
}
}
diff --git a/MediaBrowser.Api/QuickConnect/QuickConnectService.cs b/MediaBrowser.Api/QuickConnect/QuickConnectService.cs
index 60d6ac414..9047a1e95 100644
--- a/MediaBrowser.Api/QuickConnect/QuickConnectService.cs
+++ b/MediaBrowser.Api/QuickConnect/QuickConnectService.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
@@ -24,18 +23,12 @@ namespace MediaBrowser.Api.QuickConnect
public string Secret { get; set; }
}
- [Route("/QuickConnect/List", "GET", Summary = "Lists all quick connect requests")]
- [Authenticated]
- public class QuickConnectList : IReturn>
- {
- }
-
[Route("/QuickConnect/Authorize", "POST", Summary = "Authorizes a pending quick connect request")]
[Authenticated]
- public class Authorize : IReturn
+ public class Authorize : IReturn
{
- [ApiMember(Name = "Lookup", Description = "Quick connect public lookup", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
- public string Lookup { get; set; }
+ [ApiMember(Name = "Code", Description = "Quick connect identifying code", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string Code { get; set; }
}
[Route("/QuickConnect/Deauthorize", "POST", Summary = "Deletes all quick connect authorization tokens for the current user")]
@@ -62,8 +55,9 @@ namespace MediaBrowser.Api.QuickConnect
[Route("/QuickConnect/Activate", "POST", Summary = "Temporarily activates quick connect for the time period defined in the server configuration")]
[Authenticated]
- public class Activate : IReturn
+ public class Activate : IReturn
{
+
}
public class QuickConnectService : BaseApiService
@@ -96,18 +90,9 @@ namespace MediaBrowser.Api.QuickConnect
return _quickConnect.CheckRequestStatus(request.Secret);
}
- public object Get(QuickConnectList request)
- {
- if(_quickConnect.State != QuickConnectState.Active)
- {
- return Array.Empty();
- }
-
- return _quickConnect.GetCurrentRequests();
- }
-
public object Get(QuickConnectStatus request)
{
+ _quickConnect.ExpireRequests();
return _quickConnect.State;
}
@@ -120,55 +105,27 @@ namespace MediaBrowser.Api.QuickConnect
public object Post(Authorize request)
{
- bool result = _quickConnect.AuthorizeRequest(Request, request.Lookup);
-
- Logger.LogInformation("Result of authorizing quick connect {0}: {1}", request.Lookup[..10], result);
-
- return result;
+ return _quickConnect.AuthorizeRequest(Request, request.Code);
}
public object Post(Activate request)
{
- string name = _authContext.GetAuthorizationInfo(Request).User.Name;
-
if(_quickConnect.State == QuickConnectState.Unavailable)
{
- return new QuickConnectResult()
- {
- Error = "Quick connect is not enabled on this server"
- };
+ return false;
}
- else if(_quickConnect.State == QuickConnectState.Available)
- {
- var result = _quickConnect.Activate();
-
- if (string.IsNullOrEmpty(result.Error))
- {
- Logger.LogInformation("{name} temporarily activated quick connect", name);
- }
+ string name = _authContext.GetAuthorizationInfo(Request).User.Username;
- return result;
- }
+ Logger.LogInformation("{name} temporarily activated quick connect", name);
+ _quickConnect.Activate();
- else if(_quickConnect.State == QuickConnectState.Active)
- {
- return new QuickConnectResult()
- {
- Error = ""
- };
- }
-
- return new QuickConnectResult()
- {
- Error = "Unknown current state"
- };
+ return true;
}
public object Post(Available request)
{
_quickConnect.SetEnabled(request.Status);
-
return _quickConnect.State;
}
}
diff --git a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
index d31d0e509..10ec9e6cb 100644
--- a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
+++ b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
@@ -38,8 +38,7 @@ namespace MediaBrowser.Controller.QuickConnect
///
/// Temporarily activates quick connect for a short amount of time.
///
- /// A quick connect result object indicating success.
- QuickConnectResult Activate();
+ void Activate();
///
/// Changes the status of quick connect.
@@ -61,26 +60,20 @@ namespace MediaBrowser.Controller.QuickConnect
/// Quick connect result.
QuickConnectResult CheckRequestStatus(string secret);
- ///
- /// Returns all current quick connect requests as DTOs. Does not include sensitive information.
- ///
- /// List of all quick connect results.
- List GetCurrentRequests();
-
- ///
- /// Returns all current quick connect requests (including sensitive information).
- ///
- /// List of all quick connect results.
- List GetCurrentRequestsInternal();
-
///
/// Authorizes a quick connect request to connect as the calling user.
///
/// HTTP request object.
- /// Identifying code for the request..
+ /// Identifying code for the request.
/// A boolean indicating if the authorization completed successfully.
bool AuthorizeRequest(IRequest request, string code);
+ ///
+ /// Expire quick connect requests that are over the time limit. If is true, all requests are unconditionally expired.
+ ///
+ /// If true, all requests will be expired.
+ public void ExpireRequests(bool expireAll = false);
+
///
/// Deletes all quick connect access tokens for the provided user.
///
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
deleted file mode 100644
index 26084caf1..000000000
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResultDto.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-
-namespace MediaBrowser.Model.QuickConnect
-{
- ///
- /// Stores the non-sensitive results of an incoming quick connect request.
- ///
- public class QuickConnectResultDto
- {
- ///
- /// Gets a value indicating whether this request is authorized.
- ///
- public bool Authenticated { get; private set; }
-
- ///
- /// Gets the user facing code used so the user can quickly differentiate this request from others.
- ///
- public string? Code { get; private set; }
-
- ///
- /// Gets the device friendly name.
- ///
- public string? FriendlyName { get; private set; }
-
- ///
- /// Cast an internal quick connect result to a DTO by removing all sensitive properties.
- ///
- /// QuickConnectResult object to cast.
- public static implicit operator QuickConnectResultDto(QuickConnectResult result)
- {
- QuickConnectResultDto resultDto = new QuickConnectResultDto
- {
- Authenticated = result.Authenticated,
- Code = result.Code,
- FriendlyName = result.FriendlyName,
- };
-
- return resultDto;
- }
- }
-}
--
cgit v1.2.3
From a61f6e3308dfc9f84fe2bdfab0194b75c041d2aa Mon Sep 17 00:00:00 2001
From: David
Date: Thu, 13 Aug 2020 15:22:12 +0200
Subject: Fix nuget ci
---
.ci/azure-pipelines-package.yml | 6 +++---
Emby.Naming/Emby.Naming.csproj | 1 +
Jellyfin.Data/Jellyfin.Data.csproj | 8 ++++++++
MediaBrowser.Common/MediaBrowser.Common.csproj | 1 +
.../MediaBrowser.Controller.csproj | 1 +
MediaBrowser.Model/MediaBrowser.Model.csproj | 1 +
bump_version | 23 ++++++++++++++++++++++
7 files changed, 38 insertions(+), 3 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/.ci/azure-pipelines-package.yml b/.ci/azure-pipelines-package.yml
index 003d5baf0..c80ec7b0e 100644
--- a/.ci/azure-pipelines-package.yml
+++ b/.ci/azure-pipelines-package.yml
@@ -153,11 +153,11 @@ jobs:
vmImage: 'ubuntu-latest'
steps:
- - task: NuGetCommand@2
+ - task: DotNetCoreCLI@2
inputs:
command: 'pack'
- packagesToPack: Jellyfin.Data/Jellyfin.Data.csproj;MediaBrowser.Common/MediaBrowser.Common.csproj;MediaBrowser.Controller/MediaBrowser.Controller.csproj;MediaBrowser.Model/MediaBrowser.Model.csproj;Emby.Naming/Emby.Naming.csproj
- packDestination: '$(Build.ArtifactStagingDirectory)'
+ packagesToPack: 'Jellyfin.Data/Jellyfin.Data.csproj;MediaBrowser.Common/MediaBrowser.Common.csproj;MediaBrowser.Controller/MediaBrowser.Controller.csproj;MediaBrowser.Model/MediaBrowser.Model.csproj;Emby.Naming/Emby.Naming.csproj'
+ versioningScheme: 'off'
- task: NuGetCommand@2
inputs:
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index c017e76c7..410492e67 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -23,6 +23,7 @@
Jellyfin ContributorsJellyfin.Naming
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 8ce0f3848..979198353 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -6,6 +6,14 @@
true
+
+ Jellyfin Contributors
+ Jellyfin.Data
+ 10.7.0
+ https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
+ https://github.com/jellyfin/jellyfin
+
+
../jellyfin.ruleset
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 7380f39fd..e7f9a5643 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -8,6 +8,7 @@
Jellyfin ContributorsJellyfin.Common
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 67f17f7a5..9686b4a72 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -8,6 +8,7 @@
Jellyfin ContributorsJellyfin.Controller
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 902e29b20..229a75a46 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -8,6 +8,7 @@
Jellyfin ContributorsJellyfin.Model
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/bump_version b/bump_version
index 1c943f691..1db1f4499 100755
--- a/bump_version
+++ b/bump_version
@@ -20,6 +20,12 @@ fi
shared_version_file="./SharedVersion.cs"
build_file="./build.yaml"
+# csproj files for nuget packages
+mediabrowser_common="MediaBrowser.Common/MediaBrowser.Common.csproj"
+jellyfin_data="Jellyfin.Data/Jellyfin.Data.csproj"
+mediabrowser_controller="MediaBrowser.Controller/MediaBrowser.Controller.csproj"
+mediabrowser_model="MediaBrowser.Model/MediaBrowser.Model.csproj"
+emby_naming="Emby.Naming/Emby.Naming.csproj"
new_version="$1"
@@ -45,6 +51,23 @@ echo $old_version
old_version_sed="$( sed 's/\./\\./g' <<<"${old_version}" )" # Escape the '.' chars
sed -i "s/${old_version_sed}/${new_version}/g" ${build_file}
+# update nuget package version
+for f in ${mediabrowser_common} ${jellyfin_data} ${mediabrowser_controller} ${mediabrowser_model} ${emby_naming}
+do
+ code ${f}
+ echo ${f}
+ # Parse the version from the *.csproj file
+ old_version="$(
+ grep "PackageVersion" ${f} \
+ | awk '{$1=$1};1' \
+ | sed -E 's/([0-9\.]+[-a-z0-9]*)<\/PackageVersion>/\1/'
+ )"
+ echo old nuget version: $old_version
+
+ # Set the nuget version to the specified new_version
+ sed -i "s|${old_version}|${new_version}|g" ${f}
+done
+
if [[ ${new_version} == *"-"* ]]; then
new_version_deb="$( sed 's/-/~/g' <<<"${new_version}" )"
else
--
cgit v1.2.3
From b92fbe4d69975d077737042d13d4fd935bc3e3c7 Mon Sep 17 00:00:00 2001
From: David
Date: Thu, 13 Aug 2020 19:03:24 +0200
Subject: Use VersionPrefix
---
Emby.Naming/Emby.Naming.csproj | 2 +-
Jellyfin.Data/Jellyfin.Data.csproj | 2 +-
MediaBrowser.Common/MediaBrowser.Common.csproj | 2 +-
MediaBrowser.Controller/MediaBrowser.Controller.csproj | 2 +-
MediaBrowser.Model/MediaBrowser.Model.csproj | 2 +-
bump_version | 4 ++--
6 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 410492e67..14aac1a4a 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -23,7 +23,7 @@
Jellyfin ContributorsJellyfin.Naming
- 10.7.0
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 979198353..cef75f890 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -9,7 +9,7 @@
Jellyfin ContributorsJellyfin.Data
- 10.7.0
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index e7f9a5643..04100eba4 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -8,7 +8,7 @@
Jellyfin ContributorsJellyfin.Common
- 10.7.0
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 9686b4a72..6bfe4e403 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -8,7 +8,7 @@
Jellyfin ContributorsJellyfin.Controller
- 10.7.0
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 229a75a46..2cb89f77f 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -8,7 +8,7 @@
Jellyfin ContributorsJellyfin.Model
- 10.7.0
+ 10.7.0https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
diff --git a/bump_version b/bump_version
index 1db1f4499..226e37eec 100755
--- a/bump_version
+++ b/bump_version
@@ -58,9 +58,9 @@ do
echo ${f}
# Parse the version from the *.csproj file
old_version="$(
- grep "PackageVersion" ${f} \
+ grep "VersionPrefix" ${f} \
| awk '{$1=$1};1' \
- | sed -E 's/([0-9\.]+[-a-z0-9]*)<\/PackageVersion>/\1/'
+ | sed -E 's/([0-9\.]+[-a-z0-9]*)<\/VersionPrefix>/\1/'
)"
echo old nuget version: $old_version
--
cgit v1.2.3
From 3ee940f7b306884b748fa06d04f80e8db241bfba Mon Sep 17 00:00:00 2001
From: Patrick Barron
Date: Thu, 13 Aug 2020 19:14:03 -0400
Subject: Clean up GenericEventArgs
---
MediaBrowser.Model/Events/GenericEventArgs.cs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/MediaBrowser.Model/Events/GenericEventArgs.cs b/MediaBrowser.Model/Events/GenericEventArgs.cs
index 44f60f811..347ea2281 100644
--- a/MediaBrowser.Model/Events/GenericEventArgs.cs
+++ b/MediaBrowser.Model/Events/GenericEventArgs.cs
@@ -5,15 +5,9 @@ namespace MediaBrowser.Model.Events
///
/// Provides a generic EventArgs subclass that can hold any kind of object.
///
- ///
+ /// The type of this event.
public class GenericEventArgs : EventArgs
{
- ///
- /// Gets or sets the argument.
- ///
- /// The argument.
- public T Argument { get; set; }
-
///
/// Initializes a new instance of the class.
///
@@ -22,5 +16,11 @@ namespace MediaBrowser.Model.Events
{
Argument = arg;
}
+
+ ///
+ /// Gets the argument.
+ ///
+ /// The argument.
+ public T Argument { get; }
}
}
--
cgit v1.2.3
From ca1f15af19e26f8f610a7b56cd6b15a6a308a58f Mon Sep 17 00:00:00 2001
From: Patrick Barron
Date: Thu, 13 Aug 2020 20:48:28 -0400
Subject: Move GenericEventArgs to Jellyfin.Data.Events
---
Emby.Dlna/PlayTo/PlayToController.cs | 2 +-
Emby.Dlna/PlayTo/PlayToManager.cs | 2 +-
Emby.Dlna/Ssdp/DeviceDiscovery.cs | 2 +-
Emby.Notifications/NotificationEntryPoint.cs | 2 +-
.../Activity/ActivityLogEntryPoint.cs | 2 +-
.../Configuration/ServerConfigurationManager.cs | 2 +-
.../Devices/DeviceManager.cs | 2 +-
.../EntryPoints/ExternalPortForwarding.cs | 2 +-
.../EntryPoints/LibraryChangedNotifier.cs | 2 +-
.../EntryPoints/RecordingNotifier.cs | 9 ++++----
.../EntryPoints/ServerEventNotifier.cs | 2 +-
.../HttpServer/HttpListenerHost.cs | 2 +-
.../LiveTv/EmbyTV/EmbyTV.cs | 2 +-
.../LiveTv/EmbyTV/TimerManager.cs | 2 +-
.../LiveTv/LiveTvManager.cs | 2 +-
.../ScheduledTasks/ScheduledTaskWorker.cs | 3 +--
.../ScheduledTasks/TaskManager.cs | 2 +-
.../Session/SessionManager.cs | 2 +-
.../Session/SessionWebSocketListener.cs | 2 +-
.../ActivityLogWebSocketListener.cs | 2 +-
.../ScheduledTasksWebSocketListener.cs | 2 +-
Jellyfin.Data/Events/GenericEventArgs.cs | 26 ++++++++++++++++++++++
.../Activity/ActivityManager.cs | 2 +-
.../Users/DeviceAccessEntryPoint.cs | 2 +-
.../Users/UserManager.cs | 2 +-
MediaBrowser.Controller/Devices/IDeviceManager.cs | 2 +-
MediaBrowser.Controller/Library/IUserManager.cs | 2 +-
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 2 +-
MediaBrowser.Controller/Net/IHttpServer.cs | 2 +-
.../Providers/IProviderManager.cs | 2 +-
MediaBrowser.Controller/Session/ISessionManager.cs | 2 +-
MediaBrowser.Model/Activity/IActivityManager.cs | 2 +-
MediaBrowser.Model/Dlna/IDeviceDiscovery.cs | 2 +-
MediaBrowser.Model/Events/GenericEventArgs.cs | 26 ----------------------
MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs | 2 +-
MediaBrowser.Model/Tasks/ITaskManager.cs | 2 +-
MediaBrowser.Providers/Manager/ProviderManager.cs | 2 +-
37 files changed, 65 insertions(+), 65 deletions(-)
create mode 100644 Jellyfin.Data/Events/GenericEventArgs.cs
delete mode 100644 MediaBrowser.Model/Events/GenericEventArgs.cs
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index 92a93d434..1f0da8d75 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Emby.Dlna.Didl;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
@@ -18,7 +19,6 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Session;
using Microsoft.AspNetCore.WebUtilities;
diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs
index 512589e4d..00edff1a6 100644
--- a/Emby.Dlna/PlayTo/PlayToManager.cs
+++ b/Emby.Dlna/PlayTo/PlayToManager.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@@ -16,7 +17,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Session;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
index 7daac96d1..18ee188fd 100644
--- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs
+++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs
@@ -3,9 +3,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Events;
using Rssdp;
using Rssdp.Infrastructure;
diff --git a/Emby.Notifications/NotificationEntryPoint.cs b/Emby.Notifications/NotificationEntryPoint.cs
index b923fd26c..ded22d26c 100644
--- a/Emby.Notifications/NotificationEntryPoint.cs
+++ b/Emby.Notifications/NotificationEntryPoint.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
@@ -13,7 +14,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Notifications;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Activity;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Notifications;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
index 39b6361b7..75a791686 100644
--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
@@ -2,6 +2,7 @@ using System;
using System.Globalization;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller.Authentication;
@@ -9,7 +10,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Activity;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Notifications;
using MediaBrowser.Model.Updates;
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index a15295fca..f05a30a89 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -2,11 +2,11 @@ using System;
using System.Globalization;
using System.IO;
using Emby.Server.Implementations.AppBase;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs
index cc4b407f5..f98c694c4 100644
--- a/Emby.Server.Implementations/Devices/DeviceManager.cs
+++ b/Emby.Server.Implementations/Devices/DeviceManager.cs
@@ -7,13 +7,13 @@ using System.IO;
using System.Linq;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.Devices;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Session;
diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
index 9fce49425..2e8cc76d2 100644
--- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
+++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs
@@ -7,11 +7,11 @@ using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
using Mono.Nat;
diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
index 1deef7f72..c9d21d963 100644
--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -15,7 +16,6 @@ using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.EntryPoints
diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
index 632735910..44d2580d6 100644
--- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Plugins;
@@ -43,22 +44,22 @@ namespace Emby.Server.Implementations.EntryPoints
return Task.CompletedTask;
}
- private async void OnLiveTvManagerSeriesTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs e)
+ private async void OnLiveTvManagerSeriesTimerCreated(object sender, GenericEventArgs e)
{
await SendMessage("SeriesTimerCreated", e.Argument).ConfigureAwait(false);
}
- private async void OnLiveTvManagerTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs e)
+ private async void OnLiveTvManagerTimerCreated(object sender, GenericEventArgs e)
{
await SendMessage("TimerCreated", e.Argument).ConfigureAwait(false);
}
- private async void OnLiveTvManagerSeriesTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs e)
+ private async void OnLiveTvManagerSeriesTimerCancelled(object sender, GenericEventArgs e)
{
await SendMessage("SeriesTimerCancelled", e.Argument).ConfigureAwait(false);
}
- private async void OnLiveTvManagerTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs e)
+ private async void OnLiveTvManagerTimerCancelled(object sender, GenericEventArgs e)
{
await SendMessage("TimerCancelled", e.Argument).ConfigureAwait(false);
}
diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
index 826d4d8dc..d023591e1 100644
--- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs
@@ -4,13 +4,13 @@ using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index dafdd5b7b..fe39bb4b2 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -12,13 +12,13 @@ using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.Services;
using Emby.Server.Implementations.SocketSharp;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 80e09f0a3..09c52d95b 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
using System.Xml;
using Emby.Server.Implementations.Library;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
@@ -29,7 +30,6 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo;
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
index 285a59a24..dd479b7d1 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
@@ -5,8 +5,8 @@ using System.Collections.Concurrent;
using System.Globalization;
using System.Linq;
using System.Threading;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 1b075d86a..ef505c78e 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Emby.Server.Implementations.Library;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
@@ -24,7 +25,6 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 8a900f42c..36faae65d 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -6,11 +6,10 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Progress;
-using MediaBrowser.Model.Events;
-using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
index 81096026b..fff52ff88 100644
--- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
@@ -5,8 +5,8 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Configuration;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 862a7296c..6e4124463 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -9,6 +9,7 @@ using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
@@ -24,7 +25,6 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Library;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Session;
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index 8bebd37dc..1da7a6473 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -4,9 +4,9 @@ using System.Linq;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Net;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
diff --git a/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
index 6395b8d62..849b3b709 100644
--- a/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
+++ b/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
@@ -1,8 +1,8 @@
using System;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Activity;
-using MediaBrowser.Model.Events;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Api.WebSocketListeners
diff --git a/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
index 12f815ff7..8a966c137 100644
--- a/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
+++ b/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Net;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
diff --git a/Jellyfin.Data/Events/GenericEventArgs.cs b/Jellyfin.Data/Events/GenericEventArgs.cs
new file mode 100644
index 000000000..7b9a5111e
--- /dev/null
+++ b/Jellyfin.Data/Events/GenericEventArgs.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Jellyfin.Data.Events
+{
+ ///
+ /// Provides a generic EventArgs subclass that can hold any kind of object.
+ ///
+ /// The type of this event.
+ public class GenericEventArgs : EventArgs
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The argument.
+ public GenericEventArgs(T arg)
+ {
+ Argument = arg;
+ }
+
+ ///
+ /// Gets the argument.
+ ///
+ /// The argument.
+ public T Argument { get; }
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 2deefbe81..09f2611e4 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -2,8 +2,8 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Model.Activity;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Querying;
namespace Jellyfin.Server.Implementations.Activity
diff --git a/Jellyfin.Server.Implementations/Users/DeviceAccessEntryPoint.cs b/Jellyfin.Server.Implementations/Users/DeviceAccessEntryPoint.cs
index 140853e52..1fb89c4a6 100644
--- a/Jellyfin.Server.Implementations/Users/DeviceAccessEntryPoint.cs
+++ b/Jellyfin.Server.Implementations/Users/DeviceAccessEntryPoint.cs
@@ -4,12 +4,12 @@
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Events;
namespace Jellyfin.Server.Implementations.Users
{
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index 11402ee05..267c1c103 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -10,6 +10,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Data.Events;
using MediaBrowser.Common;
using MediaBrowser.Common.Cryptography;
using MediaBrowser.Common.Extensions;
@@ -21,7 +22,6 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
diff --git a/MediaBrowser.Controller/Devices/IDeviceManager.cs b/MediaBrowser.Controller/Devices/IDeviceManager.cs
index 7d279230b..a038d84d8 100644
--- a/MediaBrowser.Controller/Devices/IDeviceManager.cs
+++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs
@@ -1,7 +1,7 @@
using System;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Model.Devices;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Session;
diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs
index 6685861a9..c8d8375b3 100644
--- a/MediaBrowser.Controller/Library/IUserManager.cs
+++ b/MediaBrowser.Controller/Library/IUserManager.cs
@@ -2,9 +2,9 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Library
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index f619b011b..d6f629a1b 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Querying;
diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs
index e6609fae3..b04ebda8c 100644
--- a/MediaBrowser.Controller/Net/IHttpServer.cs
+++ b/MediaBrowser.Controller/Net/IHttpServer.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using MediaBrowser.Model.Events;
+using Jellyfin.Data.Events;
using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs
index 955db0278..ef744ee3c 100644
--- a/MediaBrowser.Controller/Providers/IProviderManager.cs
+++ b/MediaBrowser.Controller/Providers/IProviderManager.cs
@@ -4,12 +4,12 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Providers;
namespace MediaBrowser.Controller.Providers
diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs
index e54f21050..d461a9281 100644
--- a/MediaBrowser.Controller/Session/ISessionManager.cs
+++ b/MediaBrowser.Controller/Session/ISessionManager.cs
@@ -2,11 +2,11 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Events;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Session;
using MediaBrowser.Model.SyncPlay;
diff --git a/MediaBrowser.Model/Activity/IActivityManager.cs b/MediaBrowser.Model/Activity/IActivityManager.cs
index 9dab5e77b..2362f7e92 100644
--- a/MediaBrowser.Model/Activity/IActivityManager.cs
+++ b/MediaBrowser.Model/Activity/IActivityManager.cs
@@ -4,7 +4,7 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
-using MediaBrowser.Model.Events;
+using Jellyfin.Data.Events;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Model.Activity
diff --git a/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs b/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs
index 76c9a4b04..05209e53d 100644
--- a/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs
+++ b/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs
@@ -1,7 +1,7 @@
#pragma warning disable CS1591
using System;
-using MediaBrowser.Model.Events;
+using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Dlna
{
diff --git a/MediaBrowser.Model/Events/GenericEventArgs.cs b/MediaBrowser.Model/Events/GenericEventArgs.cs
deleted file mode 100644
index 347ea2281..000000000
--- a/MediaBrowser.Model/Events/GenericEventArgs.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-
-namespace MediaBrowser.Model.Events
-{
- ///
- /// Provides a generic EventArgs subclass that can hold any kind of object.
- ///
- /// The type of this event.
- public class GenericEventArgs : EventArgs
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The argument.
- public GenericEventArgs(T arg)
- {
- Argument = arg;
- }
-
- ///
- /// Gets the argument.
- ///
- /// The argument.
- public T Argument { get; }
- }
-}
diff --git a/MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs b/MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs
index b08acba2c..2f05e08c5 100644
--- a/MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs
+++ b/MediaBrowser.Model/Tasks/IScheduledTaskWorker.cs
@@ -1,6 +1,6 @@
#nullable disable
using System;
-using MediaBrowser.Model.Events;
+using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Tasks
{
diff --git a/MediaBrowser.Model/Tasks/ITaskManager.cs b/MediaBrowser.Model/Tasks/ITaskManager.cs
index 363773ff7..02b29074e 100644
--- a/MediaBrowser.Model/Tasks/ITaskManager.cs
+++ b/MediaBrowser.Model/Tasks/ITaskManager.cs
@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using MediaBrowser.Model.Events;
+using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Tasks
{
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index bbd7166e6..9f63c6046 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -9,6 +9,7 @@ using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller;
@@ -22,7 +23,6 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Providers;
--
cgit v1.2.3
From 5f1a86324170387f12602d77dad7249faf30548f Mon Sep 17 00:00:00 2001
From: Matt Montgomery <33811686+ConfusedPolarBear@users.noreply.github.com>
Date: Mon, 17 Aug 2020 16:36:45 -0500
Subject: Apply suggestions from code review
---
.../QuickConnect/QuickConnectManager.cs | 38 +++++++++-------------
.../Session/SessionManager.cs | 2 +-
Jellyfin.Api/Controllers/QuickConnectController.cs | 34 +++++++++----------
Jellyfin.Api/Controllers/UserController.cs | 4 +--
.../QuickConnect/IQuickConnect.cs | 12 +++----
.../QuickConnect/QuickConnectResult.cs | 5 ---
6 files changed, 40 insertions(+), 55 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index 949c3b505..52e934229 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -3,17 +3,16 @@ using System.Collections.Concurrent;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
+using MediaBrowser.Common;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.QuickConnect;
using MediaBrowser.Controller.Security;
using MediaBrowser.Model.QuickConnect;
-using Microsoft.AspNetCore.Http;
-using MediaBrowser.Common;
using Microsoft.Extensions.Logging;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Authentication;
namespace Emby.Server.Implementations.QuickConnect
{
@@ -60,7 +59,7 @@ namespace Emby.Server.Implementations.QuickConnect
public int CodeLength { get; set; } = 6;
///
- public string TokenNamePrefix { get; set; } = "QuickConnect-";
+ public string TokenName { get; set; } = "QuickConnect";
///
public QuickConnectState State { get; private set; } = QuickConnectState.Unavailable;
@@ -82,7 +81,7 @@ namespace Emby.Server.Implementations.QuickConnect
///
public void Activate()
{
- DateActivated = DateTime.Now;
+ DateActivated = DateTime.UtcNow;
SetState(QuickConnectState.Active);
}
@@ -101,7 +100,7 @@ namespace Emby.Server.Implementations.QuickConnect
}
///
- public QuickConnectResult TryConnect(string friendlyName)
+ public QuickConnectResult TryConnect()
{
ExpireRequests();
@@ -111,14 +110,11 @@ namespace Emby.Server.Implementations.QuickConnect
throw new AuthenticationException("Quick connect is not active on this server");
}
- _logger.LogDebug("Got new quick connect request from {friendlyName}", friendlyName);
-
var code = GenerateCode();
var result = new QuickConnectResult()
{
Secret = GenerateSecureRandom(),
- FriendlyName = friendlyName,
- DateAdded = DateTime.Now,
+ DateAdded = DateTime.UtcNow,
Code = code
};
@@ -162,13 +158,11 @@ namespace Emby.Server.Implementations.QuickConnect
}
///
- public bool AuthorizeRequest(HttpRequest request, string code)
+ public bool AuthorizeRequest(Guid userId, string code)
{
ExpireRequests();
AssertActive();
- var auth = _authContext.GetAuthorizationInfo(request);
-
if (!_currentRequests.TryGetValue(code, out QuickConnectResult result))
{
throw new ResourceNotFoundException("Unable to find request");
@@ -182,21 +176,21 @@ namespace Emby.Server.Implementations.QuickConnect
result.Authentication = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
// Change the time on the request so it expires one minute into the future. It can't expire immediately as otherwise some clients wouldn't ever see that they have been authenticated.
- var added = result.DateAdded ?? DateTime.Now.Subtract(new TimeSpan(0, Timeout, 0));
- result.DateAdded = added.Subtract(new TimeSpan(0, Timeout - 1, 0));
+ var added = result.DateAdded ?? DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(Timeout));
+ result.DateAdded = added.Subtract(TimeSpan.FromMinutes(Timeout - 1));
_authenticationRepository.Create(new AuthenticationInfo
{
- AppName = TokenNamePrefix + result.FriendlyName,
+ AppName = TokenName,
AccessToken = result.Authentication,
DateCreated = DateTime.UtcNow,
DeviceId = _appHost.SystemId,
DeviceName = _appHost.FriendlyName,
AppVersion = _appHost.ApplicationVersionString,
- UserId = auth.UserId
+ UserId = userId
});
- _logger.LogInformation("Allowing device {FriendlyName} to login as user {Username} with quick connect code {Code}", result.FriendlyName, auth.User.Username, result.Code);
+ _logger.LogDebug("Authorizing device with code {Code} to login as user {userId}", code, userId);
return true;
}
@@ -210,7 +204,7 @@ namespace Emby.Server.Implementations.QuickConnect
UserId = user
});
- var tokens = raw.Items.Where(x => x.AppName.StartsWith(TokenNamePrefix, StringComparison.CurrentCulture));
+ var tokens = raw.Items.Where(x => x.AppName.StartsWith(TokenName, StringComparison.CurrentCulture));
var removed = 0;
foreach (var token in tokens)
@@ -256,7 +250,7 @@ namespace Emby.Server.Implementations.QuickConnect
public void ExpireRequests(bool expireAll = false)
{
// Check if quick connect should be deactivated
- if (State == QuickConnectState.Active && DateTime.Now > DateActivated.AddMinutes(Timeout) && !expireAll)
+ if (State == QuickConnectState.Active && DateTime.UtcNow > DateActivated.AddMinutes(Timeout) && !expireAll)
{
_logger.LogDebug("Quick connect time expired, deactivating");
SetState(QuickConnectState.Available);
@@ -270,7 +264,7 @@ namespace Emby.Server.Implementations.QuickConnect
for (int i = 0; i < values.Count; i++)
{
var added = values[i].DateAdded ?? DateTime.UnixEpoch;
- if (DateTime.Now > added.AddMinutes(Timeout) || expireAll)
+ if (DateTime.UtcNow > added.AddMinutes(Timeout) || expireAll)
{
code = values[i].Code;
_logger.LogDebug("Removing expired request {code}", code);
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 8a8223ee7..fbe8e065c 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -1433,7 +1433,7 @@ namespace Emby.Server.Implementations.Session
Limit = 1
});
- if (result.TotalRecordCount < 1)
+ if (result.TotalRecordCount == 0)
{
throw new SecurityException("Unknown quick connect token");
}
diff --git a/Jellyfin.Api/Controllers/QuickConnectController.cs b/Jellyfin.Api/Controllers/QuickConnectController.cs
index 1625bcffe..b1ee2ff53 100644
--- a/Jellyfin.Api/Controllers/QuickConnectController.cs
+++ b/Jellyfin.Api/Controllers/QuickConnectController.cs
@@ -1,8 +1,8 @@
+using System;
using System.ComponentModel.DataAnnotations;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Helpers;
using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.QuickConnect;
using MediaBrowser.Model.QuickConnect;
@@ -18,22 +18,18 @@ namespace Jellyfin.Api.Controllers
public class QuickConnectController : BaseJellyfinApiController
{
private readonly IQuickConnect _quickConnect;
- private readonly IUserManager _userManager;
private readonly IAuthorizationContext _authContext;
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
- /// Instance of the interface.
/// Instance of the interface.
public QuickConnectController(
IQuickConnect quickConnect,
- IUserManager userManager,
IAuthorizationContext authContext)
{
_quickConnect = quickConnect;
- _userManager = userManager;
_authContext = authContext;
}
@@ -53,15 +49,14 @@ namespace Jellyfin.Api.Controllers
///
/// Initiate a new quick connect request.
///
- /// Device friendly name.
/// Quick connect request successfully created.
/// Quick connect is not active on this server.
/// A with a secret and code for future use or an error message.
[HttpGet("Initiate")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult Initiate([FromQuery] string? friendlyName)
+ public ActionResult Initiate()
{
- return _quickConnect.TryConnect(friendlyName);
+ return _quickConnect.TryConnect();
}
///
@@ -74,12 +69,11 @@ namespace Jellyfin.Api.Controllers
[HttpGet("Connect")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult Connect([FromQuery] string? secret)
+ public ActionResult Connect([FromQuery, Required] string secret)
{
try
{
- var result = _quickConnect.CheckRequestStatus(secret);
- return result;
+ return _quickConnect.CheckRequestStatus(secret);
}
catch (ResourceNotFoundException)
{
@@ -117,9 +111,9 @@ namespace Jellyfin.Api.Controllers
[HttpPost("Available")]
[Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult Available([FromQuery] QuickConnectState? status)
+ public ActionResult Available([FromQuery] QuickConnectState status = QuickConnectState.Available)
{
- _quickConnect.SetState(status ?? QuickConnectState.Available);
+ _quickConnect.SetState(status);
return NoContent();
}
@@ -127,16 +121,22 @@ namespace Jellyfin.Api.Controllers
/// Authorizes a pending quick connect request.
///
/// Quick connect code to authorize.
+ /// User id.
/// Quick connect result authorized successfully.
- /// Missing quick connect code.
+ /// User is not allowed to authorize quick connect requests.
/// Boolean indicating if the authorization was successful.
[HttpPost("Authorize")]
[Authorize(Policy = Policies.DefaultAuthorization)]
[ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- public ActionResult Authorize([FromQuery, Required] string? code)
+ [ProducesResponseType(StatusCodes.Status403Forbidden)]
+ public ActionResult Authorize([FromQuery, Required] string code, [FromQuery, Required] Guid userId)
{
- return _quickConnect.AuthorizeRequest(Request, code);
+ if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true))
+ {
+ return Forbid("User is not allowed to authorize quick connect requests.");
+ }
+
+ return _quickConnect.AuthorizeRequest(userId, code);
}
///
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs
index 355816bd3..d67f82219 100644
--- a/Jellyfin.Api/Controllers/UserController.cs
+++ b/Jellyfin.Api/Controllers/UserController.cs
@@ -239,11 +239,9 @@ namespace Jellyfin.Api.Controllers
DeviceName = auth.Device,
};
- var result = await _sessionManager.AuthenticateQuickConnect(
+ return await _sessionManager.AuthenticateQuickConnect(
authRequest,
request.Token).ConfigureAwait(false);
-
- return result;
}
catch (SecurityException e)
{
diff --git a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
index fd7e973f6..959a2d771 100644
--- a/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
+++ b/MediaBrowser.Controller/QuickConnect/IQuickConnect.cs
@@ -1,6 +1,5 @@
using System;
using MediaBrowser.Model.QuickConnect;
-using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.QuickConnect
{
@@ -15,9 +14,9 @@ namespace MediaBrowser.Controller.QuickConnect
int CodeLength { get; set; }
///
- /// Gets or sets the string to prefix internal access tokens with.
+ /// Gets or sets the name of internal access tokens.
///
- string TokenNamePrefix { get; set; }
+ string TokenName { get; set; }
///
/// Gets the current state of quick connect.
@@ -48,9 +47,8 @@ namespace MediaBrowser.Controller.QuickConnect
///
/// Initiates a new quick connect request.
///
- /// Friendly device name to display in the request UI.
/// A quick connect result with tokens to proceed or throws an exception if not active.
- QuickConnectResult TryConnect(string friendlyName);
+ QuickConnectResult TryConnect();
///
/// Checks the status of an individual request.
@@ -62,10 +60,10 @@ namespace MediaBrowser.Controller.QuickConnect
///
/// Authorizes a quick connect request to connect as the calling user.
///
- /// HTTP request object.
+ /// User id.
/// Identifying code for the request.
/// A boolean indicating if the authorization completed successfully.
- bool AuthorizeRequest(HttpRequest request, string code);
+ bool AuthorizeRequest(Guid userId, string code);
///
/// Expire quick connect requests that are over the time limit. If is true, all requests are unconditionally expired.
diff --git a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
index a10d60d57..0fa40b6a7 100644
--- a/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
+++ b/MediaBrowser.Model/QuickConnect/QuickConnectResult.cs
@@ -22,11 +22,6 @@ namespace MediaBrowser.Model.QuickConnect
///
public string? Code { get; set; }
- ///
- /// Gets or sets the device friendly name.
- ///
- public string? FriendlyName { get; set; }
-
///
/// Gets or sets the private access token.
///
--
cgit v1.2.3
From 2b400c99ef946ef1e52e3f01cb18bc008a369c59 Mon Sep 17 00:00:00 2001
From: Bond_009
Date: Fri, 7 Aug 2020 19:26:28 +0200
Subject: Fix warnings
---
Emby.Dlna/DlnaManager.cs | 12 +--
Emby.Dlna/PlayTo/Device.cs | 36 ++++---
Emby.Dlna/PlayTo/TransportCommands.cs | 17 ++--
.../Data/SqliteItemRepository.cs | 4 +-
.../LiveTv/EmbyTV/EncodedRecorder.cs | 2 +-
.../LiveTv/Listings/XmlTvListingsProvider.cs | 5 +-
.../LiveTv/LiveTvManager.cs | 106 +++++++++++----------
.../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 16 ++--
Jellyfin.Api/Controllers/ImageController.cs | 2 +-
MediaBrowser.Controller/Entities/Movies/Movie.cs | 4 +-
MediaBrowser.Controller/Entities/TV/Series.cs | 2 +-
MediaBrowser.Controller/Entities/Trailer.cs | 3 +-
MediaBrowser.Controller/Library/Profiler.cs | 17 +++-
MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 2 +-
MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 2 +-
.../MediaEncoding/EncodingHelper.cs | 8 +-
.../Providers/IProviderManager.cs | 2 +-
.../Encoder/EncodingUtils.cs | 9 +-
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 14 +--
.../Subtitles/SubtitleEncoder.cs | 2 +-
MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 2 +-
MediaBrowser.Model/Dlna/DlnaMaps.cs | 8 +-
.../Dlna/MediaFormatProfileResolver.cs | 21 ++--
MediaBrowser.Model/Dlna/StreamInfo.cs | 12 +--
MediaBrowser.Providers/Manager/ImageSaver.cs | 4 +-
.../Manager/ItemImageProvider.cs | 57 +++++------
MediaBrowser.Providers/Manager/MetadataService.cs | 73 +++++++-------
MediaBrowser.Providers/Manager/ProviderManager.cs | 37 +++++--
.../MediaInfo/FFProbeAudioInfo.cs | 15 +--
.../MediaInfo/FFProbeProvider.cs | 21 +---
MediaBrowser.Providers/Music/Extensions.cs | 4 +-
.../Plugins/MusicBrainz/AlbumProvider.cs | 2 +-
.../Plugins/MusicBrainz/ArtistProvider.cs | 4 +-
.../Plugins/Omdb/OmdbImageProvider.cs | 3 +-
.../Plugins/Omdb/OmdbItemProvider.cs | 2 +-
.../Plugins/Omdb/OmdbProvider.cs | 25 +++--
.../Plugins/TheTvdb/TvdbClientManager.cs | 31 ++----
.../Plugins/TheTvdb/TvdbEpisodeImageProvider.cs | 7 +-
.../Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs | 4 +-
.../Plugins/Tmdb/Movies/GenericTmdbMovieInfo.cs | 2 +-
.../Plugins/Tmdb/Movies/TmdbSearch.cs | 54 +++++++++--
.../Plugins/Tmdb/TV/TmdbEpisodeProvider.cs | 2 +-
.../Plugins/Tmdb/TV/TmdbEpisodeProviderBase.cs | 4 +-
.../Plugins/Tmdb/TV/TmdbSeasonProvider.cs | 4 +-
.../Plugins/Tmdb/TV/TmdbSeriesProvider.cs | 2 +-
.../Studios/StudiosImageProvider.cs | 3 +-
46 files changed, 366 insertions(+), 302 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs
index 269f7ee43..ce4be7b51 100644
--- a/Emby.Dlna/DlnaManager.cs
+++ b/Emby.Dlna/DlnaManager.cs
@@ -54,11 +54,15 @@ namespace Emby.Dlna
_appHost = appHost;
}
+ private string UserProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user");
+
+ private string SystemProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system");
+
public async Task InitProfilesAsync()
{
try
{
- await ExtractSystemProfilesAsync();
+ await ExtractSystemProfilesAsync().ConfigureAwait(false);
LoadProfiles();
}
catch (Exception ex)
@@ -240,7 +244,7 @@ namespace Emby.Dlna
}
else
{
- var headerString = string.Join(", ", headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)).ToArray());
+ var headerString = string.Join(", ", headers.Select(i => string.Format(CultureInfo.InvariantCulture, "{0}={1}", i.Key, i.Value)));
_logger.LogDebug("No matching device profile found. {0}", headerString);
}
@@ -280,10 +284,6 @@ namespace Emby.Dlna
return false;
}
- private string UserProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user");
-
- private string SystemProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system");
-
private IEnumerable GetProfiles(string path, DeviceProfileType type)
{
try
diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs
index 72834c69d..86dd52a1b 100644
--- a/Emby.Dlna/PlayTo/Device.cs
+++ b/Emby.Dlna/PlayTo/Device.cs
@@ -19,6 +19,8 @@ namespace Emby.Dlna.PlayTo
{
public class Device : IDisposable
{
+ private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
+
private Timer _timer;
public DeviceInfo Properties { get; set; }
@@ -55,16 +57,13 @@ namespace Emby.Dlna.PlayTo
private readonly ILogger _logger;
- private readonly IServerConfigurationManager _config;
-
public Action OnDeviceUnavailable { get; set; }
- public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config)
+ public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger)
{
Properties = deviceProperties;
_httpClient = httpClient;
_logger = logger;
- _config = config;
}
public void Start()
@@ -275,7 +274,7 @@ namespace Emby.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service");
}
- await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, string.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME"))
+ await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, string.Format(CultureInfo.InvariantCulture, "{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME"))
.ConfigureAwait(false);
RestartTimer(true);
@@ -285,7 +284,7 @@ namespace Emby.Dlna.PlayTo
{
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
- url = url.Replace("&", "&");
+ url = url.Replace("&", "&", StringComparison.Ordinal);
_logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header);
@@ -297,8 +296,8 @@ namespace Emby.Dlna.PlayTo
var dictionary = new Dictionary
{
- {"CurrentURI", url},
- {"CurrentURIMetaData", CreateDidlMeta(metaData)}
+ { "CurrentURI", url },
+ { "CurrentURIMetaData", CreateDidlMeta(metaData) }
};
var service = GetAvTransportService();
@@ -732,10 +731,10 @@ namespace Emby.Dlna.PlayTo
}
var trackUriElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i != null);
- var trackUri = trackUriElem == null ? null : trackUriElem.Value;
+ var trackUri = trackUriElem?.Value;
var durationElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i != null);
- var duration = durationElem == null ? null : durationElem.Value;
+ var duration = durationElem?.Value;
if (!string.IsNullOrWhiteSpace(duration)
&& !string.Equals(duration, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
@@ -748,7 +747,7 @@ namespace Emby.Dlna.PlayTo
}
var positionElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i != null);
- var position = positionElem == null ? null : positionElem.Value;
+ var position = positionElem?.Value;
if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
{
@@ -819,7 +818,7 @@ namespace Emby.Dlna.PlayTo
// some devices send back invalid xml
try
{
- return XElement.Parse(xml.Replace("&", "&"));
+ return XElement.Parse(xml.Replace("&", "&", StringComparison.Ordinal));
}
catch (XmlException)
{
@@ -848,7 +847,7 @@ namespace Emby.Dlna.PlayTo
ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId),
Title = container.GetValue(uPnpNamespaces.title),
IconUrl = container.GetValue(uPnpNamespaces.Artwork),
- SecondText = "",
+ SecondText = string.Empty,
Url = url,
ProtocolInfo = GetProtocolInfo(container),
MetaData = container.ToString()
@@ -941,12 +940,12 @@ namespace Emby.Dlna.PlayTo
return url;
}
- if (!url.Contains("/"))
+ if (!url.Contains('/', StringComparison.Ordinal))
{
url = "/dmr/" + url;
}
- if (!url.StartsWith("/"))
+ if (!url.StartsWith("/", StringComparison.Ordinal))
{
url = "/" + url;
}
@@ -981,7 +980,7 @@ namespace Emby.Dlna.PlayTo
var deviceProperties = new DeviceInfo()
{
Name = string.Join(" ", friendlyNames),
- BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port)
+ BaseUrl = string.Format(CultureInfo.InvariantCulture, "http://{0}:{1}", url.Host, url.Port)
};
var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
@@ -1068,10 +1067,9 @@ namespace Emby.Dlna.PlayTo
}
}
- return new Device(deviceProperties, httpClient, logger, config);
+ return new Device(deviceProperties, httpClient, logger);
}
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private static DeviceIcon CreateIcon(XElement element)
{
if (element == null)
@@ -1222,7 +1220,7 @@ namespace Emby.Dlna.PlayTo
public override string ToString()
{
- return string.Format("{0} - {1}", Properties.Name, Properties.BaseUrl);
+ return string.Format(CultureInfo.InvariantCulture, "{0} - {1}", Properties.Name, Properties.BaseUrl);
}
}
}
diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.cs
index c0ce3ab6e..dc797a691 100644
--- a/Emby.Dlna/PlayTo/TransportCommands.cs
+++ b/Emby.Dlna/PlayTo/TransportCommands.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using Emby.Dlna.Common;
@@ -11,14 +12,16 @@ namespace Emby.Dlna.PlayTo
{
public class TransportCommands
{
+ private const string CommandBase = "\r\n" + "" + "" + "" + "{2}" + "" + "";
private List _stateVariables = new List();
+ private List _serviceActions = new List();
+
public List StateVariables
{
get => _stateVariables;
set => _stateVariables = value;
}
- private List _serviceActions = new List();
public List ServiceActions
{
get => _serviceActions;
@@ -123,7 +126,7 @@ namespace Emby.Dlna.PlayTo
}
}
- return string.Format(CommandBase, action.Name, xmlNamespace, stateString);
+ return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamespace, stateString);
}
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "")
@@ -147,7 +150,7 @@ namespace Emby.Dlna.PlayTo
}
}
- return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
+ return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString);
}
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary dictionary)
@@ -170,7 +173,7 @@ namespace Emby.Dlna.PlayTo
}
}
- return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
+ return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString);
}
private string BuildArgumentXml(Argument argument, string value, string commandParameter = "")
@@ -183,12 +186,10 @@ namespace Emby.Dlna.PlayTo
state.AllowedValues.FirstOrDefault() ??
value;
- return string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}{0}>", argument.Name, state.DataType ?? "string", sendValue);
+ return string.Format(CultureInfo.InvariantCulture, "<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}{0}>", argument.Name, state.DataType ?? "string", sendValue);
}
- return string.Format("<{0}>{1}{0}>", argument.Name, value);
+ return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}{0}>", argument.Name, value);
}
-
- private const string CommandBase = "\r\n" + "" + "" + "" + "{2}" + "" + "";
}
}
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index d11e5e62e..331ffc134 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -4560,13 +4560,13 @@ namespace Emby.Server.Implementations.Data
if (query.AncestorIds.Length > 1)
{
var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + i.ToString("N", CultureInfo.InvariantCulture) + "'"));
- whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
+ whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
}
if (!string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey))
{
var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
- whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
+ whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
if (statement != null)
{
statement.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index d8ec107ec..612dc5238 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -230,7 +230,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (filters.Count > 0)
{
- output += string.Format(" -vf \"{0}\"", string.Join(",", filters.ToArray()));
+ output += string.Format(CultureInfo.InvariantCulture, " -vf \"{0}\"", string.Join(",", filters.ToArray()));
}
return output;
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 0a93c4674..f33d07174 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -237,7 +237,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
&& !programInfo.IsRepeat
&& (programInfo.EpisodeNumber ?? 0) == 0)
{
- programInfo.ShowId = programInfo.ShowId + programInfo.StartDate.Ticks.ToString(CultureInfo.InvariantCulture);
+ programInfo.ShowId += programInfo.StartDate.Ticks.ToString(CultureInfo.InvariantCulture);
}
}
else
@@ -246,7 +246,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
// Construct an id from the channel and start date
- programInfo.Id = string.Format("{0}_{1:O}", program.ChannelId, program.StartDate);
+ programInfo.Id = string.Format(CultureInfo.InvariantCulture, "{0}_{1:O}", program.ChannelId, program.StartDate);
if (programInfo.IsMovie)
{
@@ -296,7 +296,6 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Name = c.DisplayName,
ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
-
}).ToList();
}
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 1b075d86a..90cbd85a5 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -41,6 +41,7 @@ namespace Emby.Server.Implementations.LiveTv
///
public class LiveTvManager : ILiveTvManager, IDisposable
{
+ private const int MaxGuideDays = 14;
private const string ExternalServiceTag = "ExternalServiceId";
private const string EtagKey = "ProgramEtag";
@@ -560,7 +561,7 @@ namespace Emby.Server.Implementations.LiveTv
item.Audio = info.Audio;
item.ChannelId = channel.Id;
- item.CommunityRating = item.CommunityRating ?? info.CommunityRating;
+ item.CommunityRating ??= info.CommunityRating;
if ((item.CommunityRating ?? 0).Equals(0))
{
item.CommunityRating = null;
@@ -645,8 +646,8 @@ namespace Emby.Server.Implementations.LiveTv
item.IsSeries = isSeries;
item.Name = info.Name;
- item.OfficialRating = item.OfficialRating ?? info.OfficialRating;
- item.Overview = item.Overview ?? info.Overview;
+ item.OfficialRating ??= info.OfficialRating;
+ item.Overview ??= info.Overview;
item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
item.ProviderIds = info.ProviderIds;
@@ -683,19 +684,23 @@ namespace Emby.Server.Implementations.LiveTv
{
if (!string.IsNullOrWhiteSpace(info.ImagePath))
{
- item.SetImage(new ItemImageInfo
- {
- Path = info.ImagePath,
- Type = ImageType.Primary
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = info.ImagePath,
+ Type = ImageType.Primary
+ },
+ 0);
}
else if (!string.IsNullOrWhiteSpace(info.ImageUrl))
{
- item.SetImage(new ItemImageInfo
- {
- Path = info.ImageUrl,
- Type = ImageType.Primary
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = info.ImageUrl,
+ Type = ImageType.Primary
+ },
+ 0);
}
}
@@ -703,11 +708,13 @@ namespace Emby.Server.Implementations.LiveTv
{
if (!string.IsNullOrWhiteSpace(info.ThumbImageUrl))
{
- item.SetImage(new ItemImageInfo
- {
- Path = info.ThumbImageUrl,
- Type = ImageType.Thumb
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = info.ThumbImageUrl,
+ Type = ImageType.Thumb
+ },
+ 0);
}
}
@@ -715,11 +722,13 @@ namespace Emby.Server.Implementations.LiveTv
{
if (!string.IsNullOrWhiteSpace(info.LogoImageUrl))
{
- item.SetImage(new ItemImageInfo
- {
- Path = info.LogoImageUrl,
- Type = ImageType.Logo
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = info.LogoImageUrl,
+ Type = ImageType.Logo
+ },
+ 0);
}
}
@@ -727,11 +736,13 @@ namespace Emby.Server.Implementations.LiveTv
{
if (!string.IsNullOrWhiteSpace(info.BackdropImageUrl))
{
- item.SetImage(new ItemImageInfo
- {
- Path = info.BackdropImageUrl,
- Type = ImageType.Backdrop
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = info.BackdropImageUrl,
+ Type = ImageType.Backdrop
+ },
+ 0);
}
}
@@ -786,7 +797,6 @@ namespace Emby.Server.Implementations.LiveTv
if (query.OrderBy.Count == 0)
{
-
// Unless something else was specified, order by start date to take advantage of a specialized index
query.OrderBy = new[]
{
@@ -824,7 +834,7 @@ namespace Emby.Server.Implementations.LiveTv
if (!string.IsNullOrWhiteSpace(query.SeriesTimerId))
{
- var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery { }, cancellationToken).ConfigureAwait(false);
+ var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false);
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
if (seriesTimer != null)
{
@@ -847,13 +857,11 @@ namespace Emby.Server.Implementations.LiveTv
var returnArray = _dtoService.GetBaseItemDtos(queryResult.Items, options, user);
- var result = new QueryResult
+ return new QueryResult
{
Items = returnArray,
TotalRecordCount = queryResult.TotalRecordCount
};
-
- return result;
}
public QueryResult GetRecommendedProgramsInternal(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken)
@@ -1173,7 +1181,6 @@ namespace Emby.Server.Implementations.LiveTv
var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery
{
-
IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name },
ChannelIds = new Guid[] { currentChannel.Id },
DtoOptions = new DtoOptions(true)
@@ -1298,8 +1305,6 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- private const int MaxGuideDays = 14;
-
private double GetGuideDays()
{
var config = GetConfiguration();
@@ -1712,7 +1717,7 @@ namespace Emby.Server.Implementations.LiveTv
if (timer == null)
{
- throw new ResourceNotFoundException(string.Format("Timer with Id {0} not found", id));
+ throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "Timer with Id {0} not found", id));
}
var service = GetService(timer.ServiceName);
@@ -1731,7 +1736,7 @@ namespace Emby.Server.Implementations.LiveTv
if (timer == null)
{
- throw new ResourceNotFoundException(string.Format("SeriesTimer with Id {0} not found", id));
+ throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "SeriesTimer with Id {0} not found", id));
}
var service = GetService(timer.ServiceName);
@@ -1743,10 +1748,12 @@ namespace Emby.Server.Implementations.LiveTv
public async Task GetTimer(string id, CancellationToken cancellationToken)
{
- var results = await GetTimers(new TimerQuery
- {
- Id = id
- }, cancellationToken).ConfigureAwait(false);
+ var results = await GetTimers(
+ new TimerQuery
+ {
+ Id = id
+ },
+ cancellationToken).ConfigureAwait(false);
return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase));
}
@@ -1794,10 +1801,7 @@ namespace Emby.Server.Implementations.LiveTv
}
var returnArray = timers
- .Select(i =>
- {
- return i.Item1;
- })
+ .Select(i => i.Item1)
.ToArray();
return new QueryResult
@@ -1968,7 +1972,7 @@ namespace Emby.Server.Implementations.LiveTv
if (service == null)
{
- service = _services.First();
+ service = _services[0];
}
var info = await service.GetNewTimerDefaultsAsync(cancellationToken, programInfo).ConfigureAwait(false);
@@ -1994,9 +1998,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var info = await GetNewTimerDefaultsInternal(cancellationToken).ConfigureAwait(false);
- var obj = _tvDtoService.GetSeriesTimerInfoDto(info.Item1, info.Item2, null);
-
- return obj;
+ return _tvDtoService.GetSeriesTimerInfoDto(info.Item1, info.Item2, null);
}
public async Task GetNewTimerDefaults(string programId, CancellationToken cancellationToken)
@@ -2125,6 +2127,7 @@ namespace Emby.Server.Implementations.LiveTv
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
private bool _disposed = false;
@@ -2447,8 +2450,7 @@ namespace Emby.Server.Implementations.LiveTv
.SelectMany(i => i.Locations)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i => _libraryManager.FindByPath(i, true))
- .Where(i => i != null)
- .Where(i => i.IsVisibleStandalone(user))
+ .Where(i => i != null && i.IsVisibleStandalone(user))
.SelectMany(i => _libraryManager.GetCollectionFolders(i))
.GroupBy(x => x.Id)
.Select(x => x.First())
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
index c61189c0a..f1e120a64 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -182,12 +182,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var model = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false);
- using (var response = await _httpClient.SendAsync(new HttpRequestOptions()
- {
- Url = string.Format("{0}/tuners.html", GetApiUrl(info)),
- CancellationToken = cancellationToken,
- BufferContent = false
- }, HttpMethod.Get).ConfigureAwait(false))
+ using (var response = await _httpClient.SendAsync(
+ new HttpRequestOptions()
+ {
+ Url = string.Format(CultureInfo.InvariantCulture, "{0}/tuners.html", GetApiUrl(info)),
+ CancellationToken = cancellationToken,
+ BufferContent = false
+ },
+ HttpMethod.Get).ConfigureAwait(false))
using (var stream = response.Content)
using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8))
{
@@ -730,7 +732,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
// Need a way to set the Receive timeout on the socket otherwise this might never timeout?
try
{
- await udpClient.SendToAsync(discBytes, 0, discBytes.Length, new IPEndPoint(IPAddress.Parse("255.255.255.255"), 65001), cancellationToken);
+ await udpClient.SendToAsync(discBytes, 0, discBytes.Length, new IPEndPoint(IPAddress.Parse("255.255.255.255"), 65001), cancellationToken).ConfigureAwait(false);
var receiveBuffer = new byte[8192];
while (!cancellationToken.IsCancellationRequested)
diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs
index 8f5c6beb3..75734f0af 100644
--- a/Jellyfin.Api/Controllers/ImageController.cs
+++ b/Jellyfin.Api/Controllers/ImageController.cs
@@ -113,7 +113,7 @@ namespace Jellyfin.Api.Controllers
user.ProfileImage = new Data.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)));
await _providerManager
- .SaveImage(user, memoryStream, mimeType, user.ProfileImage.Path)
+ .SaveImage(memoryStream, mimeType, user.ProfileImage.Path)
.ConfigureAwait(false);
await _userManager.UpdateUserAsync(user).ConfigureAwait(false);
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 53badac4d..5ae396e68 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -1,5 +1,7 @@
+
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading;
@@ -179,7 +181,7 @@ namespace MediaBrowser.Controller.Entities.Movies
list.Add(new ExternalUrl
{
Name = "Trakt",
- Url = string.Format("https://trakt.tv/movies/{0}", imdbId)
+ Url = string.Format(CultureInfo.InvariantCulture, "https://trakt.tv/movies/{0}", imdbId)
});
}
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index 45daa8a53..23d960092 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -496,7 +496,7 @@ namespace MediaBrowser.Controller.Entities.TV
list.Add(new ExternalUrl
{
Name = "Trakt",
- Url = string.Format("https://trakt.tv/shows/{0}", imdbId)
+ Url = string.Format(CultureInfo.InvariantCulture, "https://trakt.tv/shows/{0}", imdbId)
});
}
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index 6b544afc6..83e9ce1e7 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Providers;
@@ -86,7 +87,7 @@ namespace MediaBrowser.Controller.Entities
list.Add(new ExternalUrl
{
Name = "Trakt",
- Url = string.Format("https://trakt.tv/movies/{0}", imdbId)
+ Url = string.Format(CultureInfo.InvariantCulture, "https://trakt.tv/movies/{0}", imdbId)
});
}
diff --git a/MediaBrowser.Controller/Library/Profiler.cs b/MediaBrowser.Controller/Library/Profiler.cs
index 399378a09..5efdc6a48 100644
--- a/MediaBrowser.Controller/Library/Profiler.cs
+++ b/MediaBrowser.Controller/Library/Profiler.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Controller.Library
@@ -13,6 +14,7 @@ namespace MediaBrowser.Controller.Library
/// The name.
///
readonly string _name;
+
///
/// The stopwatch.
///
@@ -44,6 +46,7 @@ namespace MediaBrowser.Controller.Library
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
///
@@ -58,13 +61,19 @@ namespace MediaBrowser.Controller.Library
string message;
if (_stopwatch.ElapsedMilliseconds > 300000)
{
- message = string.Format("{0} took {1} minutes.",
- _name, ((float)_stopwatch.ElapsedMilliseconds / 60000).ToString("F"));
+ message = string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} took {1} minutes.",
+ _name,
+ ((float)_stopwatch.ElapsedMilliseconds / 60000).ToString("F", CultureInfo.InvariantCulture));
}
else
{
- message = string.Format("{0} took {1} seconds.",
- _name, ((float)_stopwatch.ElapsedMilliseconds / 1000).ToString("#0.000"));
+ message = string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} took {1} seconds.",
+ _name,
+ ((float)_stopwatch.ElapsedMilliseconds / 1000).ToString("#0.000", CultureInfo.InvariantCulture));
}
_logger.LogInformation(message);
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index 10af98121..aa7c12dd1 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.LiveTv
if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
{
- return string.Format("{0:00000.0}", number) + "-" + (Name ?? string.Empty);
+ return string.Format(CultureInfo.InvariantCulture, "{0:00000.0}", number) + "-" + (Name ?? string.Empty);
}
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
index 472b061e6..e1de01ff0 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
@@ -261,7 +261,7 @@ namespace MediaBrowser.Controller.LiveTv
list.Add(new ExternalUrl
{
Name = "Trakt",
- Url = string.Format("https://trakt.tv/movies/{0}", imdbId)
+ Url = string.Format(CultureInfo.InvariantCulture, "https://trakt.tv/movies/{0}", imdbId)
});
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 2dd21be3c..7b09f489e 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -675,7 +675,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// }
// }
- // fallbackFontParam = string.Format(":force_style='FontName=Droid Sans Fallback':fontsdir='{0}'", _mediaEncoder.EscapeSubtitleFilterPath(_fileSystem.GetDirectoryName(fallbackFontPath)));
+ // fallbackFontParam = string.Format(CultureInfo.InvariantCulture, ":force_style='FontName=Droid Sans Fallback':fontsdir='{0}'", _mediaEncoder.EscapeSubtitleFilterPath(_fileSystem.GetDirectoryName(fallbackFontPath)));
if (state.SubtitleStream.IsExternal)
{
@@ -880,7 +880,7 @@ namespace MediaBrowser.Controller.MediaEncoding
profileScore = Math.Min(profileScore, 2);
// http://www.webmproject.org/docs/encoder-parameters/
- param += string.Format("-speed 16 -quality good -profile:v {0} -slices 8 -crf {1} -qmin {2} -qmax {3}",
+ param += string.Format(CultureInfo.InvariantCulture, "-speed 16 -quality good -profile:v {0} -slices 8 -crf {1} -qmin {2} -qmax {3}",
profileScore.ToString(_usCulture),
crf,
qmin,
@@ -904,7 +904,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var framerate = GetFramerateParam(state);
if (framerate.HasValue)
{
- param += string.Format(" -r {0}", framerate.Value.ToString(_usCulture));
+ param += string.Format(CultureInfo.InvariantCulture, " -r {0}", framerate.Value.ToString(_usCulture));
}
var targetVideoCodec = state.ActualOutputVideoCodec;
@@ -1484,7 +1484,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (time > 0)
{
- return string.Format("-ss {0}", _mediaEncoder.GetTimeParameter(time));
+ return string.Format(CultureInfo.InvariantCulture, "-ss {0}", _mediaEncoder.GetTimeParameter(time));
}
return string.Empty;
diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs
index 8ba01d773..c77349d01 100644
--- a/MediaBrowser.Controller/Providers/IProviderManager.cs
+++ b/MediaBrowser.Controller/Providers/IProviderManager.cs
@@ -72,7 +72,7 @@ namespace MediaBrowser.Controller.Providers
/// Task.
Task SaveImage(BaseItem item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken);
- Task SaveImage(User user, Stream source, string mimeType, string path);
+ Task SaveImage(Stream source, string mimeType, string path);
///
/// Adds the metadata providers.
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs
index 7c2d9f1fd..082ae2888 100644
--- a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using MediaBrowser.Model.MediaInfo;
@@ -14,7 +15,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var url = inputFiles[0];
- return string.Format("\"{0}\"", url);
+ return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", url);
}
return GetConcatInputArgument(inputFiles);
@@ -33,7 +34,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var files = string.Join("|", inputFiles.Select(NormalizePath));
- return string.Format("concat:\"{0}\"", files);
+ return string.Format(CultureInfo.InvariantCulture, "concat:\"{0}\"", files);
}
// Determine the input path for video files
@@ -49,13 +50,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (path.IndexOf("://") != -1)
{
- return string.Format("\"{0}\"", path);
+ return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", path);
}
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
path = NormalizePath(path);
- return string.Format("file:\"{0}\"", path);
+ return string.Format(CultureInfo.InvariantCulture, "file:\"{0}\"", path);
}
///
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index 778c0b18c..b9a6432ad 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -552,8 +552,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
var thumbnail = enableThumbnail ? ",thumbnail=24" : string.Empty;
- var args = useIFrame ? string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) :
- string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg);
+ var args = useIFrame ? string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) :
+ string.Format(CultureInfo.InvariantCulture, "-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg);
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
@@ -570,7 +570,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (offset.HasValue)
{
- args = string.Format("-ss {0} ", GetTimeParameter(offset.Value)) + args;
+ args = string.Format(CultureInfo.InvariantCulture, "-ss {0} ", GetTimeParameter(offset.Value)) + args;
}
if (videoStream != null)
@@ -641,7 +641,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (exitCode == -1 || !file.Exists || file.Length == 0)
{
- var msg = string.Format("ffmpeg image extraction failed for {0}", inputPath);
+ var msg = string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction failed for {0}", inputPath);
_logger.LogError(msg);
@@ -684,13 +684,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var maxWidthParam = maxWidth.Value.ToString(_usCulture);
- vf += string.Format(",scale=min(iw\\,{0}):trunc(ow/dar/2)*2", maxWidthParam);
+ vf += string.Format(CultureInfo.InvariantCulture, ",scale=min(iw\\,{0}):trunc(ow/dar/2)*2", maxWidthParam);
}
Directory.CreateDirectory(targetDirectory);
var outputPath = Path.Combine(targetDirectory, filenamePrefix + "%05d.jpg");
- var args = string.Format("-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf);
+ var args = string.Format(CultureInfo.InvariantCulture, "-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf);
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
@@ -790,7 +790,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (exitCode == -1)
{
- var msg = string.Format("ffmpeg image extraction failed for {0}", inputArgument);
+ var msg = string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction failed for {0}", inputArgument);
_logger.LogError(msg);
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 374e35b96..fbe8bd69f 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -435,7 +435,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
CreateNoWindow = true,
UseShellExecute = false,
FileName = _mediaEncoder.EncoderPath,
- Arguments = string.Format("{0} -i \"{1}\" -c:s srt \"{2}\"", encodingParam, inputPath, outputPath),
+ Arguments = string.Format(CultureInfo.InvariantCulture, "{0} -i \"{1}\" -c:s srt \"{2}\"", encodingParam, inputPath, outputPath),
WindowStyle = ProcessWindowStyle.Hidden,
ErrorDialog = false
},
diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
index a579f8464..93e60753a 100644
--- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
+++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
@@ -157,7 +157,7 @@ namespace MediaBrowser.Model.Dlna
// flagValue = flagValue | DlnaFlags.TimeBasedSeek;
//}
- string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}",
+ string dlnaflags = string.Format(CultureInfo.InvariantCulture, ";DLNA.ORG_FLAGS={0}",
DlnaMaps.FlagsToString(flagValue));
ResponseProfile mediaProfile = _profile.GetVideoMediaProfile(container,
diff --git a/MediaBrowser.Model/Dlna/DlnaMaps.cs b/MediaBrowser.Model/Dlna/DlnaMaps.cs
index 052b4b78b..95cd0ac27 100644
--- a/MediaBrowser.Model/Dlna/DlnaMaps.cs
+++ b/MediaBrowser.Model/Dlna/DlnaMaps.cs
@@ -1,18 +1,20 @@
#pragma warning disable CS1591
+using System.Globalization;
+
namespace MediaBrowser.Model.Dlna
{
public static class DlnaMaps
{
private static readonly string DefaultStreaming =
- FlagsToString(DlnaFlags.StreamingTransferMode |
+ FlagsToString(DlnaFlags.StreamingTransferMode |
DlnaFlags.BackgroundTransferMode |
DlnaFlags.ConnectionStall |
DlnaFlags.ByteBasedSeek |
DlnaFlags.DlnaV15);
private static readonly string DefaultInteractive =
- FlagsToString(DlnaFlags.InteractiveTransferMode |
+ FlagsToString(DlnaFlags.InteractiveTransferMode |
DlnaFlags.BackgroundTransferMode |
DlnaFlags.ConnectionStall |
DlnaFlags.ByteBasedSeek |
@@ -20,7 +22,7 @@ namespace MediaBrowser.Model.Dlna
public static string FlagsToString(DlnaFlags flags)
{
- return string.Format("{0:X8}{1:D24}", (ulong)flags, 0);
+ return string.Format(CultureInfo.InvariantCulture, "{0:X8}{1:D24}", (ulong)flags, 0);
}
public static string GetOrgOpValue(bool hasKnownRuntime, bool isDirectStream, TranscodeSeekInfo profileTranscodeSeekInfo)
diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
index bdc5f8bb7..3c955989a 100644
--- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
+++ b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using MediaBrowser.Model.MediaInfo;
@@ -142,26 +143,26 @@ namespace MediaBrowser.Model.Dlna
{
if (timestampType == TransportStreamTimestamp.None)
{
- return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) };
}
- return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) };
}
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
}
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
}
if (string.IsNullOrEmpty(audioCodec) ||
string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
}
}
else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
@@ -180,29 +181,29 @@ namespace MediaBrowser.Model.Dlna
{
suffix = string.Equals(suffix, "_ISO", StringComparison.OrdinalIgnoreCase) ? suffix : "_T";
- return new MediaFormatProfile[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "VC1_TS_HD_DTS{0}", suffix)) };
}
}
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
}
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
}
if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
}
if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
{
- return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
+ return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
}
}
diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs
index 204340c46..94d53ab70 100644
--- a/MediaBrowser.Model/Dlna/StreamInfo.cs
+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs
@@ -191,7 +191,7 @@ namespace MediaBrowser.Model.Dlna
var encodedValue = pair.Value.Replace(" ", "%20");
- list.Add(string.Format("{0}={1}", pair.Name, encodedValue));
+ list.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}", pair.Name, encodedValue));
}
string queryString = string.Join("&", list.ToArray());
@@ -214,18 +214,18 @@ namespace MediaBrowser.Model.Dlna
{
if (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{
- return string.Format("{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
+ return string.Format(CultureInfo.InvariantCulture, "{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
}
- return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
+ return string.Format(CultureInfo.InvariantCulture, "{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
}
if (string.Equals(SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{
- return string.Format("{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
+ return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
}
- return string.Format("{0}/videos/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
+ return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
}
private static List BuildParams(StreamInfo item, string accessToken)
@@ -457,7 +457,7 @@ namespace MediaBrowser.Model.Dlna
{
if (MediaSource.Protocol == MediaProtocol.File || !string.Equals(stream.Codec, subtitleProfile.Format, StringComparison.OrdinalIgnoreCase) || !stream.IsExternal)
{
- info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
+ info.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
baseUrl,
ItemId,
MediaSourceId,
diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs
index 26b50784b..413d297cb 100644
--- a/MediaBrowser.Providers/Manager/ImageSaver.cs
+++ b/MediaBrowser.Providers/Manager/ImageSaver.cs
@@ -187,7 +187,7 @@ namespace MediaBrowser.Providers.Manager
}
}
- public async Task SaveImage(User user, Stream source, string path)
+ public async Task SaveImage(Stream source, string path)
{
await SaveImageToLocation(source, path, path, CancellationToken.None).ConfigureAwait(false);
}
@@ -355,7 +355,7 @@ namespace MediaBrowser.Providers.Manager
if (string.IsNullOrWhiteSpace(extension))
{
- throw new ArgumentException(string.Format("Unable to determine image file extension from mime type {0}", mimeType));
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unable to determine image file extension from mime type {0}", mimeType));
}
if (type == ImageType.Thumb && saveLocally)
diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs
index a5eb095c4..9227b6d93 100644
--- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs
+++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs
@@ -54,7 +54,12 @@ namespace MediaBrowser.Providers.Manager
return hasChanges;
}
- public async Task RefreshImages(BaseItem item, LibraryOptions libraryOptions, List providers, ImageRefreshOptions refreshOptions, MetadataOptions savedOptions, CancellationToken cancellationToken)
+ public async Task RefreshImages(
+ BaseItem item,
+ LibraryOptions libraryOptions,
+ List providers,
+ ImageRefreshOptions refreshOptions,
+ CancellationToken cancellationToken)
{
if (refreshOptions.IsReplacingImage(ImageType.Backdrop))
{
@@ -78,19 +83,15 @@ namespace MediaBrowser.Providers.Manager
foreach (var provider in providers)
{
- var remoteProvider = provider as IRemoteImageProvider;
-
- if (remoteProvider != null)
+ if (provider is IRemoteImageProvider remoteProvider)
{
await RefreshFromProvider(item, libraryOptions, remoteProvider, refreshOptions, typeOptions, backdropLimit, screenshotLimit, downloadedImages, result, cancellationToken).ConfigureAwait(false);
continue;
}
- var dynamicImageProvider = provider as IDynamicImageProvider;
-
- if (dynamicImageProvider != null)
+ if (provider is IDynamicImageProvider dynamicImageProvider)
{
- await RefreshFromProvider(item, dynamicImageProvider, refreshOptions, typeOptions, libraryOptions, downloadedImages, result, cancellationToken).ConfigureAwait(false);
+ await RefreshFromProvider(item, dynamicImageProvider, refreshOptions, typeOptions, downloadedImages, result, cancellationToken).ConfigureAwait(false);
}
}
@@ -100,11 +101,11 @@ namespace MediaBrowser.Providers.Manager
///
/// Refreshes from provider.
///
- private async Task RefreshFromProvider(BaseItem item,
+ private async Task RefreshFromProvider(
+ BaseItem item,
IDynamicImageProvider provider,
ImageRefreshOptions refreshOptions,
TypeOptions savedOptions,
- LibraryOptions libraryOptions,
ICollection downloadedImages,
RefreshResult result,
CancellationToken cancellationToken)
@@ -115,7 +116,7 @@ namespace MediaBrowser.Providers.Manager
foreach (var imageType in images)
{
- if (!IsEnabled(savedOptions, imageType, item))
+ if (!IsEnabled(savedOptions, imageType))
{
continue;
}
@@ -133,12 +134,13 @@ namespace MediaBrowser.Providers.Manager
if (response.Protocol == MediaProtocol.Http)
{
_logger.LogDebug("Setting image url into item {0}", item.Id);
- item.SetImage(new ItemImageInfo
- {
- Path = response.Path,
- Type = imageType
-
- }, 0);
+ item.SetImage(
+ new ItemImageInfo
+ {
+ Path = response.Path,
+ Type = imageType
+ },
+ 0);
}
else
{
@@ -157,7 +159,7 @@ namespace MediaBrowser.Providers.Manager
}
downloadedImages.Add(imageType);
- result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
+ result.UpdateType |= ItemUpdateType.ImageUpdate;
}
}
}
@@ -279,7 +281,7 @@ namespace MediaBrowser.Providers.Manager
foreach (var imageType in _singularImages)
{
- if (!IsEnabled(savedOptions, imageType, item))
+ if (!IsEnabled(savedOptions, imageType))
{
continue;
}
@@ -299,8 +301,7 @@ namespace MediaBrowser.Providers.Manager
minWidth = savedOptions.GetMinWidth(ImageType.Backdrop);
await DownloadBackdrops(item, libraryOptions, ImageType.Backdrop, backdropLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
- var hasScreenshots = item as IHasScreenshots;
- if (hasScreenshots != null)
+ if (item is IHasScreenshots hasScreenshots)
{
minWidth = savedOptions.GetMinWidth(ImageType.Screenshot);
await DownloadBackdrops(item, libraryOptions, ImageType.Screenshot, screenshotLimit, provider, result, list, minWidth, cancellationToken).ConfigureAwait(false);
@@ -317,7 +318,7 @@ namespace MediaBrowser.Providers.Manager
}
}
- private bool IsEnabled(TypeOptions options, ImageType type, BaseItem item)
+ private bool IsEnabled(TypeOptions options, ImageType type)
{
return options.IsEnabled(type);
}
@@ -452,10 +453,10 @@ namespace MediaBrowser.Providers.Manager
.Where(i => i.Type == type && !(i.Width.HasValue && i.Width.Value < minWidth))
.ToList();
- if (EnableImageStub(item, type, libraryOptions) && eligibleImages.Count > 0)
+ if (EnableImageStub(item, libraryOptions) && eligibleImages.Count > 0)
{
SaveImageStub(item, type, eligibleImages.Select(i => i.Url));
- result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
+ result.UpdateType |= ItemUpdateType.ImageUpdate;
return true;
}
@@ -476,7 +477,7 @@ namespace MediaBrowser.Providers.Manager
null,
cancellationToken).ConfigureAwait(false);
- result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
+ result.UpdateType |= ItemUpdateType.ImageUpdate;
return true;
}
catch (HttpException ex)
@@ -495,7 +496,7 @@ namespace MediaBrowser.Providers.Manager
return false;
}
- private bool EnableImageStub(BaseItem item, ImageType type, LibraryOptions libraryOptions)
+ private bool EnableImageStub(BaseItem item, LibraryOptions libraryOptions)
{
if (item is LiveTvProgram)
{
@@ -563,10 +564,10 @@ namespace MediaBrowser.Providers.Manager
var url = image.Url;
- if (EnableImageStub(item, imageType, libraryOptions))
+ if (EnableImageStub(item, libraryOptions))
{
SaveImageStub(item, imageType, new[] { url });
- result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
+ result.UpdateType |= ItemUpdateType.ImageUpdate;
continue;
}
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index 3b0c7b56c..dcae300fc 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -52,7 +52,6 @@ namespace MediaBrowser.Providers.Manager
public async Task RefreshMetadata(BaseItem item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{
var itemOfType = (TItemType)item;
- var config = ProviderManager.GetMetadataOptions(item);
var updateType = ItemUpdateType.None;
var requiresRefresh = false;
@@ -86,7 +85,7 @@ namespace MediaBrowser.Providers.Manager
// Always validate images and check for new locally stored ones.
if (itemImageProvider.ValidateImages(item, allImageProviders.OfType(), refreshOptions.DirectoryService))
{
- updateType = updateType | ItemUpdateType.ImageUpdate;
+ updateType |= ItemUpdateType.ImageUpdate;
}
}
catch (Exception ex)
@@ -102,7 +101,7 @@ namespace MediaBrowser.Providers.Manager
bool hasRefreshedMetadata = true;
bool hasRefreshedImages = true;
- var isFirstRefresh = item.DateLastRefreshed == default(DateTime);
+ var isFirstRefresh = item.DateLastRefreshed == default;
// Next run metadata providers
if (refreshOptions.MetadataRefreshMode != MetadataRefreshMode.None)
@@ -114,7 +113,7 @@ namespace MediaBrowser.Providers.Manager
{
if (item.BeforeMetadataRefresh(refreshOptions.ReplaceAllMetadata))
{
- updateType = updateType | ItemUpdateType.MetadataImport;
+ updateType |= ItemUpdateType.MetadataImport;
}
}
@@ -132,7 +131,7 @@ namespace MediaBrowser.Providers.Manager
var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, itemImageProvider, cancellationToken).ConfigureAwait(false);
- updateType = updateType | result.UpdateType;
+ updateType |= result.UpdateType;
if (result.Failures > 0)
{
hasRefreshedMetadata = false;
@@ -147,9 +146,9 @@ namespace MediaBrowser.Providers.Manager
if (providers.Count > 0)
{
- var result = await itemImageProvider.RefreshImages(itemOfType, libraryOptions, providers, refreshOptions, config, cancellationToken).ConfigureAwait(false);
+ var result = await itemImageProvider.RefreshImages(itemOfType, libraryOptions, providers, refreshOptions, cancellationToken).ConfigureAwait(false);
- updateType = updateType | result.UpdateType;
+ updateType |= result.UpdateType;
if (result.Failures > 0)
{
hasRefreshedImages = false;
@@ -158,7 +157,7 @@ namespace MediaBrowser.Providers.Manager
}
var beforeSaveResult = BeforeSave(itemOfType, isFirstRefresh || refreshOptions.ReplaceAllMetadata || refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || requiresRefresh || refreshOptions.ForceSave, updateType);
- updateType = updateType | beforeSaveResult;
+ updateType |= beforeSaveResult;
// Save if changes were made, or it's never been saved before
if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || isFirstRefresh || refreshOptions.ReplaceAllMetadata || requiresRefresh)
@@ -175,7 +174,7 @@ namespace MediaBrowser.Providers.Manager
// If any of these properties are set then make sure the updateType is not None, just to force everything to save
if (refreshOptions.ForceSave || refreshOptions.ReplaceAllMetadata)
{
- updateType = updateType | ItemUpdateType.MetadataDownload;
+ updateType |= ItemUpdateType.MetadataDownload;
}
if (hasRefreshedMetadata && hasRefreshedImages)
@@ -184,11 +183,11 @@ namespace MediaBrowser.Providers.Manager
}
else
{
- item.DateLastRefreshed = default(DateTime);
+ item.DateLastRefreshed = default;
}
// Save to database
- SaveItem(metadataResult, libraryOptions, updateType, cancellationToken);
+ await SaveItemAsync(metadataResult, libraryOptions, updateType, cancellationToken).ConfigureAwait(false);
}
await AfterMetadataRefresh(itemOfType, refreshOptions, cancellationToken).ConfigureAwait(false);
@@ -203,26 +202,26 @@ namespace MediaBrowser.Providers.Manager
lookupInfo.Year = result.ProductionYear;
}
- protected void SaveItem(MetadataResult result, LibraryOptions libraryOptions, ItemUpdateType reason, CancellationToken cancellationToken)
+ protected async Task SaveItemAsync(MetadataResult result, LibraryOptions libraryOptions, ItemUpdateType reason, CancellationToken cancellationToken)
{
if (result.Item.SupportsPeople && result.People != null)
{
var baseItem = result.Item;
LibraryManager.UpdatePeople(baseItem, result.People);
- SavePeopleMetadata(result.People, libraryOptions, cancellationToken);
+ await SavePeopleMetadataAsync(result.People, libraryOptions, cancellationToken).ConfigureAwait(false);
}
result.Item.UpdateToRepository(reason, cancellationToken);
}
- private void SavePeopleMetadata(List people, LibraryOptions libraryOptions, CancellationToken cancellationToken)
+ private async Task SavePeopleMetadataAsync(List people, LibraryOptions libraryOptions, CancellationToken cancellationToken)
{
foreach (var person in people)
{
cancellationToken.ThrowIfCancellationRequested();
- if (person.ProviderIds.Any() || !string.IsNullOrWhiteSpace(person.ImageUrl))
+ if (person.ProviderIds.Count > 0 || !string.IsNullOrWhiteSpace(person.ImageUrl))
{
var updateType = ItemUpdateType.MetadataDownload;
@@ -239,10 +238,10 @@ namespace MediaBrowser.Providers.Manager
if (!string.IsNullOrWhiteSpace(person.ImageUrl) && !personEntity.HasImage(ImageType.Primary))
{
- AddPersonImage(personEntity, libraryOptions, person.ImageUrl, cancellationToken);
+ await AddPersonImageAsync(personEntity, libraryOptions, person.ImageUrl, cancellationToken).ConfigureAwait(false);
saveEntity = true;
- updateType = updateType | ItemUpdateType.ImageUpdate;
+ updateType |= ItemUpdateType.ImageUpdate;
}
if (saveEntity)
@@ -253,26 +252,28 @@ namespace MediaBrowser.Providers.Manager
}
}
- private void AddPersonImage(Person personEntity, LibraryOptions libraryOptions, string imageUrl, CancellationToken cancellationToken)
+ private async Task AddPersonImageAsync(Person personEntity, LibraryOptions libraryOptions, string imageUrl, CancellationToken cancellationToken)
{
- // if (libraryOptions.DownloadImagesInAdvance)
- //{
- // try
- // {
- // await ProviderManager.SaveImage(personEntity, imageUrl, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- // return;
- // }
- // catch (Exception ex)
- // {
- // Logger.LogError(ex, "Error in AddPersonImage");
- // }
- //}
-
- personEntity.SetImage(new ItemImageInfo
- {
- Path = imageUrl,
- Type = ImageType.Primary
- }, 0);
+ if (libraryOptions.DownloadImagesInAdvance)
+ {
+ try
+ {
+ await ProviderManager.SaveImage(personEntity, imageUrl, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
+ return;
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex, "Error in AddPersonImage");
+ }
+ }
+
+ personEntity.SetImage(
+ new ItemImageInfo
+ {
+ Path = imageUrl,
+ Type = ImageType.Primary
+ },
+ 0);
}
protected virtual Task AfterMetadataRefresh(TItemType item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index e67d1b8c3..d9a84be5c 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -210,10 +210,10 @@ namespace MediaBrowser.Providers.Manager
}
///
- public Task SaveImage(User user, Stream source, string mimeType, string path)
+ public Task SaveImage(Stream source, string mimeType, string path)
{
return new ImageSaver(_configurationManager, _libraryMonitor, _fileSystem, _logger)
- .SaveImage(user, source, path);
+ .SaveImage(source, path);
}
///
@@ -563,7 +563,7 @@ namespace MediaBrowser.Providers.Manager
var pluginList = summary.Plugins.ToList();
AddMetadataPlugins(pluginList, dummy, libraryOptions, options);
- AddImagePlugins(pluginList, dummy, imageProviders);
+ AddImagePlugins(pluginList, imageProviders);
var subtitleProviders = _subtitleManager.GetSupportedProviders(dummy);
@@ -594,14 +594,14 @@ namespace MediaBrowser.Providers.Manager
var providers = GetMetadataProvidersInternal(item, libraryOptions, options, true, true).ToList();
// Locals
- list.AddRange(providers.Where(i => (i is ILocalMetadataProvider)).Select(i => new MetadataPlugin
+ list.AddRange(providers.Where(i => i is ILocalMetadataProvider).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.LocalMetadataProvider
}));
// Fetchers
- list.AddRange(providers.Where(i => (i is IRemoteMetadataProvider)).Select(i => new MetadataPlugin
+ list.AddRange(providers.Where(i => i is IRemoteMetadataProvider).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.MetadataFetcher
@@ -615,11 +615,10 @@ namespace MediaBrowser.Providers.Manager
}));
}
- private void AddImagePlugins(List list, T item, List imageProviders)
- where T : BaseItem
+ private void AddImagePlugins(List list, List imageProviders)
{
// Locals
- list.AddRange(imageProviders.Where(i => (i is ILocalImageProvider)).Select(i => new MetadataPlugin
+ list.AddRange(imageProviders.Where(i => i is ILocalImageProvider).Select(i => new MetadataPlugin
{
Name = i.Name,
Type = MetadataPluginType.LocalImageProvider
@@ -1166,12 +1165,32 @@ namespace MediaBrowser.Providers.Manager
///
public void Dispose()
{
- _disposed = true;
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases unmanaged and optionally managed resources.
+ ///
+ /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_disposed)
+ {
+ return;
+ }
if (!_disposeCancellationTokenSource.IsCancellationRequested)
{
_disposeCancellationTokenSource.Cancel();
}
+
+ if (disposing)
+ {
+ _disposeCancellationTokenSource.Dispose();
+ }
+
+ _disposed = true;
}
}
}
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
index 69c6fd722..77f03580a 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
@@ -2,11 +2,9 @@
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
@@ -17,7 +15,6 @@ using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.MediaInfo
{
@@ -25,19 +22,17 @@ namespace MediaBrowser.Providers.MediaInfo
{
private readonly IMediaEncoder _mediaEncoder;
private readonly IItemRepository _itemRepo;
- private readonly IApplicationPaths _appPaths;
- private readonly IJsonSerializer _json;
private readonly ILibraryManager _libraryManager;
private readonly IMediaSourceManager _mediaSourceManager;
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
-
- public FFProbeAudioInfo(IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IApplicationPaths appPaths, IJsonSerializer json, ILibraryManager libraryManager)
+ public FFProbeAudioInfo(
+ IMediaSourceManager mediaSourceManager,
+ IMediaEncoder mediaEncoder,
+ IItemRepository itemRepo,
+ ILibraryManager libraryManager)
{
_mediaEncoder = mediaEncoder;
_itemRepo = itemRepo;
- _appPaths = appPaths;
- _json = json;
_libraryManager = libraryManager;
_mediaSourceManager = mediaSourceManager;
}
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
index 4fabe709b..9926275ae 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
@@ -40,19 +40,15 @@ namespace MediaBrowser.Providers.MediaInfo
IHasItemChangeMonitor
{
private readonly ILogger _logger;
- private readonly IIsoManager _isoManager;
private readonly IMediaEncoder _mediaEncoder;
private readonly IItemRepository _itemRepo;
private readonly IBlurayExaminer _blurayExaminer;
private readonly ILocalizationManager _localization;
- private readonly IApplicationPaths _appPaths;
- private readonly IJsonSerializer _json;
private readonly IEncodingManager _encodingManager;
private readonly IServerConfigurationManager _config;
private readonly ISubtitleManager _subtitleManager;
private readonly IChapterManager _chapterManager;
private readonly ILibraryManager _libraryManager;
- private readonly IChannelManager _channelManager;
private readonly IMediaSourceManager _mediaSourceManager;
public string Name => "ffprobe";
@@ -126,14 +122,10 @@ namespace MediaBrowser.Providers.MediaInfo
public FFProbeProvider(
ILogger logger,
IMediaSourceManager mediaSourceManager,
- IChannelManager channelManager,
- IIsoManager isoManager,
IMediaEncoder mediaEncoder,
IItemRepository itemRepo,
IBlurayExaminer blurayExaminer,
ILocalizationManager localization,
- IApplicationPaths appPaths,
- IJsonSerializer json,
IEncodingManager encodingManager,
IServerConfigurationManager config,
ISubtitleManager subtitleManager,
@@ -141,19 +133,15 @@ namespace MediaBrowser.Providers.MediaInfo
ILibraryManager libraryManager)
{
_logger = logger;
- _isoManager = isoManager;
_mediaEncoder = mediaEncoder;
_itemRepo = itemRepo;
_blurayExaminer = blurayExaminer;
_localization = localization;
- _appPaths = appPaths;
- _json = json;
_encodingManager = encodingManager;
_config = config;
_subtitleManager = subtitleManager;
_chapterManager = chapterManager;
_libraryManager = libraryManager;
- _channelManager = channelManager;
_mediaSourceManager = mediaSourceManager;
_subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager);
@@ -211,9 +199,9 @@ namespace MediaBrowser.Providers.MediaInfo
private string NormalizeStrmLine(string line)
{
- return line.Replace("\t", string.Empty)
- .Replace("\r", string.Empty)
- .Replace("\n", string.Empty)
+ return line.Replace("\t", string.Empty, StringComparison.Ordinal)
+ .Replace("\r", string.Empty, StringComparison.Ordinal)
+ .Replace("\n", string.Empty, StringComparison.Ordinal)
.Trim();
}
@@ -242,10 +230,11 @@ namespace MediaBrowser.Providers.MediaInfo
FetchShortcutInfo(item);
}
- var prober = new FFProbeAudioInfo(_mediaSourceManager, _mediaEncoder, _itemRepo, _appPaths, _json, _libraryManager);
+ var prober = new FFProbeAudioInfo(_mediaSourceManager, _mediaEncoder, _itemRepo, _libraryManager);
return prober.Probe(item, options, cancellationToken);
}
+
// Run last
public int Order => 100;
}
diff --git a/MediaBrowser.Providers/Music/Extensions.cs b/MediaBrowser.Providers/Music/Extensions.cs
index b57d35256..dddfd02e4 100644
--- a/MediaBrowser.Providers/Music/Extensions.cs
+++ b/MediaBrowser.Providers/Music/Extensions.cs
@@ -6,7 +6,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Providers.Music
{
- public static class Extensions
+ public static class AlbumInfoExtensions
{
public static string GetAlbumArtist(this AlbumInfo info)
{
@@ -18,7 +18,7 @@ namespace MediaBrowser.Providers.Music
return id;
}
- return info.AlbumArtists.FirstOrDefault();
+ return info.AlbumArtists.Count > 0 ? info.AlbumArtists[0] : default;
}
public static string GetReleaseGroupId(this AlbumInfo info)
diff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs
index 23acb7fd6..3550614dd 100644
--- a/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs
+++ b/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs
@@ -276,7 +276,7 @@ namespace MediaBrowser.Providers.Music
private async Task GetReleaseResult(string albumName, string artistId, CancellationToken cancellationToken)
{
- var url = string.Format("/ws/2/release/?query=\"{0}\" AND arid:{1}",
+ var url = string.Format(CultureInfo.InvariantCulture, "/ws/2/release/?query=\"{0}\" AND arid:{1}",
WebUtility.UrlEncode(albumName),
artistId);
diff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/ArtistProvider.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/ArtistProvider.cs
index b829ed378..781b71640 100644
--- a/MediaBrowser.Providers/Plugins/MusicBrainz/ArtistProvider.cs
+++ b/MediaBrowser.Providers/Plugins/MusicBrainz/ArtistProvider.cs
@@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Music
// They seem to throw bad request failures on any term with a slash
var nameToSearch = searchInfo.Name.Replace('/', ' ');
- var url = string.Format("/ws/2/artist/?query=\"{0}\"&dismax=true", UrlEncode(nameToSearch));
+ var url = string.Format(CultureInfo.InvariantCulture, "/ws/2/artist/?query=\"{0}\"&dismax=true", UrlEncode(nameToSearch));
using (var response = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, cancellationToken).ConfigureAwait(false))
await using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
@@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.Music
if (HasDiacritics(searchInfo.Name))
{
// Try again using the search with accent characters url
- url = string.Format("/ws/2/artist/?query=artistaccent:\"{0}\"", UrlEncode(nameToSearch));
+ url = string.Format(CultureInfo.InvariantCulture, "/ws/2/artist/?query=artistaccent:\"{0}\"", UrlEncode(nameToSearch));
using var response = await MusicBrainzAlbumProvider.Current.GetMusicBrainzResponse(url, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs
index 41e664aac..c18725e0a 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net.Http;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common;
@@ -70,7 +71,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
list.Add(new RemoteImageInfo
{
ProviderName = Name,
- Url = string.Format("https://img.omdbapi.com/?i={0}&apikey=2c9d9507", imdbId)
+ Url = string.Format(CultureInfo.InvariantCulture, "https://img.omdbapi.com/?i={0}&apikey=2c9d9507", imdbId)
});
}
}
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
index d2823a08c..102ad82e1 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs
@@ -127,7 +127,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
}
}
- var url = OmdbProvider.GetOmdbUrl(urlQuery, _appHost, cancellationToken);
+ var url = OmdbProvider.GetOmdbUrl(urlQuery);
using var response = await OmdbProvider.GetOmdbResponse(_httpClientFactory.CreateClient(), url, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
index 6ad5298de..c45149c3a 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
@@ -256,16 +256,16 @@ namespace MediaBrowser.Providers.Plugins.Omdb
return false;
}
- public static string GetOmdbUrl(string query, IApplicationHost appHost, CancellationToken cancellationToken)
+ public static string GetOmdbUrl(string query)
{
- const string url = "https://www.omdbapi.com?apikey=2c9d9507";
+ const string Url = "https://www.omdbapi.com?apikey=2c9d9507";
if (string.IsNullOrWhiteSpace(query))
{
- return url;
+ return Url;
}
- return url + "&" + query;
+ return Url + "&" + query;
}
private async Task EnsureItemInfo(string imdbId, CancellationToken cancellationToken)
@@ -290,7 +290,11 @@ namespace MediaBrowser.Providers.Plugins.Omdb
}
}
- var url = GetOmdbUrl(string.Format("i={0}&plot=short&tomatoes=true&r=json", imdbParam), _appHost, cancellationToken);
+ var url = GetOmdbUrl(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "i={0}&plot=short&tomatoes=true&r=json",
+ imdbParam));
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(), url, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
@@ -323,7 +327,12 @@ namespace MediaBrowser.Providers.Plugins.Omdb
}
}
- var url = GetOmdbUrl(string.Format("i={0}&season={1}&detail=full", imdbParam, seasonId), _appHost, cancellationToken);
+ var url = GetOmdbUrl(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "i={0}&season={1}&detail=full",
+ imdbParam,
+ seasonId));
using var response = await GetOmdbResponse(_httpClientFactory.CreateClient(), url, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
@@ -348,7 +357,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
- var filename = string.Format("{0}.json", imdbId);
+ var filename = string.Format(CultureInfo.InvariantCulture, "{0}.json", imdbId);
return Path.Combine(dataPath, filename);
}
@@ -362,7 +371,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
- var filename = string.Format("{0}_season_{1}.json", imdbId, seasonId);
+ var filename = string.Format(CultureInfo.InvariantCulture, "{0}_season_{1}.json", imdbId, seasonId);
return Path.Combine(dataPath, filename);
}
diff --git a/MediaBrowser.Providers/Plugins/TheTvdb/TvdbClientManager.cs b/MediaBrowser.Providers/Plugins/TheTvdb/TvdbClientManager.cs
index cd2f96f14..f22d484ab 100644
--- a/MediaBrowser.Providers/Plugins/TheTvdb/TvdbClientManager.cs
+++ b/MediaBrowser.Providers/Plugins/TheTvdb/TvdbClientManager.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -19,7 +20,6 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
{
private const string DefaultLanguage = "en";
- private readonly SemaphoreSlim _cacheWriteLock = new SemaphoreSlim(1, 1);
private readonly IMemoryCache _cache;
private readonly TvDbClient _tvDbClient;
private DateTime _tokenCreatedAt;
@@ -176,7 +176,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
string language,
CancellationToken cancellationToken)
{
- searchInfo.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(),
+ searchInfo.SeriesProviderIds.TryGetValue(nameof(MetadataProvider.Tvdb),
out var seriesTvdbId);
var episodeQuery = new EpisodeQuery();
@@ -203,10 +203,10 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
else if (searchInfo.PremiereDate.HasValue)
{
// tvdb expects yyyy-mm-dd format
- episodeQuery.FirstAired = searchInfo.PremiereDate.Value.ToString("yyyy-MM-dd");
+ episodeQuery.FirstAired = searchInfo.PremiereDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
}
- return GetEpisodeTvdbId(Convert.ToInt32(seriesTvdbId), episodeQuery, language, cancellationToken);
+ return GetEpisodeTvdbId(Convert.ToInt32(seriesTvdbId, CultureInfo.InvariantCulture), episodeQuery, language, cancellationToken);
}
public async Task GetEpisodeTvdbId(
@@ -218,7 +218,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
var episodePage =
await GetEpisodesPageAsync(Convert.ToInt32(seriesTvdbId), episodeQuery, language, cancellationToken)
.ConfigureAwait(false);
- return episodePage.Data.FirstOrDefault()?.Id.ToString();
+ return episodePage.Data.FirstOrDefault()?.Id.ToString(CultureInfo.InvariantCulture);
}
public Task> GetEpisodesPageAsync(
@@ -276,23 +276,10 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
return cachedValue;
}
- await _cacheWriteLock.WaitAsync().ConfigureAwait(false);
- try
- {
- if (_cache.TryGetValue(key, out cachedValue))
- {
- return cachedValue;
- }
-
- _tvDbClient.AcceptedLanguage = TvdbUtils.NormalizeLanguage(language) ?? DefaultLanguage;
- var result = await resultFactory.Invoke().ConfigureAwait(false);
- _cache.Set(key, result, TimeSpan.FromHours(1));
- return result;
- }
- finally
- {
- _cacheWriteLock.Release();
- }
+ _tvDbClient.AcceptedLanguage = TvdbUtils.NormalizeLanguage(language) ?? DefaultLanguage;
+ var result = await resultFactory.Invoke().ConfigureAwait(false);
+ _cache.Set(key, result, TimeSpan.FromHours(1));
+ return result;
}
private static string GenerateKey(params object[] objects)
diff --git a/MediaBrowser.Providers/Plugins/TheTvdb/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/Plugins/TheTvdb/TvdbEpisodeImageProvider.cs
index 4d38d38dc..4e7c0e5a6 100644
--- a/MediaBrowser.Providers/Plugins/TheTvdb/TvdbEpisodeImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/TheTvdb/TvdbEpisodeImageProvider.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
@@ -76,7 +77,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
var episodeResult =
await _tvdbClientManager
- .GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), language, cancellationToken)
+ .GetEpisodesAsync(Convert.ToInt32(episodeTvdbId, CultureInfo.InvariantCulture), language, cancellationToken)
.ConfigureAwait(false);
var image = GetImageInfo(episodeResult.Data);
@@ -103,8 +104,8 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
return new RemoteImageInfo
{
- Width = Convert.ToInt32(episode.ThumbWidth),
- Height = Convert.ToInt32(episode.ThumbHeight),
+ Width = Convert.ToInt32(episode.ThumbWidth, CultureInfo.InvariantCulture),
+ Height = Convert.ToInt32(episode.ThumbHeight, CultureInfo.InvariantCulture),
ProviderName = Name,
Url = TvdbUtils.BannerUrl + episode.Filename,
Type = ImageType.Primary
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
index 4f86a0293..4da2c042f 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/BoxSets/TmdbBoxSetProvider.cs
@@ -180,7 +180,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
if (!string.IsNullOrEmpty(language))
{
- url += string.Format("&language={0}", TmdbMovieProvider.NormalizeLanguage(language));
+ url += string.Format(CultureInfo.InvariantCulture, "&language={0}", TmdbMovieProvider.NormalizeLanguage(language));
// Get images in english and with no language
url += "&include_image_language=" + TmdbMovieProvider.GetImageLanguagesParam(language);
@@ -250,7 +250,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
{
var path = GetDataPath(appPaths, tmdbId);
- var filename = string.Format("all-{0}.json", preferredLanguage ?? string.Empty);
+ var filename = string.Format(CultureInfo.InvariantCulture, "all-{0}.json", preferredLanguage ?? string.Empty);
return Path.Combine(path, filename);
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/GenericTmdbMovieInfo.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/GenericTmdbMovieInfo.cs
index 27ca3759e..01a887eed 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/GenericTmdbMovieInfo.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/GenericTmdbMovieInfo.cs
@@ -300,7 +300,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
{
movie.RemoteTrailers = movieData.Trailers.Youtube.Select(i => new MediaUrl
{
- Url = string.Format("https://www.youtube.com/watch?v={0}", i.Source),
+ Url = string.Format(CultureInfo.InvariantCulture, "https://www.youtube.com/watch?v={0}", i.Source),
Name = i.Name
}).ToArray();
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbSearch.cs b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbSearch.cs
index 48f2a68a6..b7c4a5643 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbSearch.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Movies/TmdbSearch.cs
@@ -37,7 +37,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
).* # Match rest of string",
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
- private const string _searchURL = TmdbUtils.BaseTmdbApiUrl + @"3/search/{3}?api_key={1}&query={0}&language={2}";
+ private const string SearchUrl = TmdbUtils.BaseTmdbApiUrl + @"3/search/{3}?api_key={1}&query={0}&language={2}";
+ private const string SearchUrlWithYear = TmdbUtils.BaseTmdbApiUrl + @"3/search/{3}?api_key={1}&query={0}&language={2}&first_air_date_year={4}";
private readonly ILogger _logger;
private readonly IJsonSerializer _json;
@@ -124,7 +125,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
name2 = name2.Trim();
// Search again if the new name is different
- if (!string.Equals(name2, name) && !string.IsNullOrWhiteSpace(name2))
+ if (!string.Equals(name2, name, StringComparison.Ordinal) && !string.IsNullOrWhiteSpace(name2))
{
_logger.LogInformation("TmdbSearch: Finding id for item: {0} ({1})", name2, year);
results = await GetSearchResults(name2, searchType, year, language, tmdbImageUrl, cancellationToken).ConfigureAwait(false);
@@ -164,10 +165,30 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentException("name");
+ throw new ArgumentException("String can't be null or empty.", nameof(name));
}
- var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, type);
+ string url3;
+ if (year != null && string.Equals(type, "movie", StringComparison.OrdinalIgnoreCase))
+ {
+ url3 = string.Format(
+ CultureInfo.InvariantCulture,
+ SearchUrl,
+ WebUtility.UrlEncode(name),
+ TmdbUtils.ApiKey,
+ language,
+ type) + "&primary_release_year=" + year;
+ }
+ else
+ {
+ url3 = string.Format(
+ CultureInfo.InvariantCulture,
+ SearchUrl,
+ WebUtility.UrlEncode(name),
+ TmdbUtils.ApiKey,
+ language,
+ type);
+ }
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
foreach (var header in TmdbUtils.AcceptHeaders)
@@ -207,10 +228,31 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentException("name");
+ throw new ArgumentException("String can't be null or empty.", nameof(name));
}
- var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, "tv");
+ string url3;
+ if (year == null)
+ {
+ url3 = string.Format(
+ CultureInfo.InvariantCulture,
+ SearchUrl,
+ WebUtility.UrlEncode(name),
+ TmdbUtils.ApiKey,
+ language,
+ "tv");
+ }
+ else
+ {
+ url3 = string.Format(
+ CultureInfo.InvariantCulture,
+ SearchUrlWithYear,
+ WebUtility.UrlEncode(name),
+ TmdbUtils.ApiKey,
+ language,
+ "tv",
+ year);
+ }
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
foreach (var header in TmdbUtils.AcceptHeaders)
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
index b4aef4542..90e3cea93 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProvider.cs
@@ -131,7 +131,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
{
if (video.Site.Equals("youtube", System.StringComparison.OrdinalIgnoreCase))
{
- var videoUrl = string.Format("http://www.youtube.com/watch?v={0}", video.Key);
+ var videoUrl = string.Format(CultureInfo.InvariantCulture, "http://www.youtube.com/watch?v={0}", video.Key);
item.AddTrailerUrl(videoUrl);
}
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProviderBase.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProviderBase.cs
index 154664321..5705885b4 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProviderBase.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbEpisodeProviderBase.cs
@@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var path = TmdbSeriesProvider.GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId);
- var filename = string.Format("season-{0}-episode-{1}-{2}.json",
+ var filename = string.Format(CultureInfo.InvariantCulture, "season-{0}-episode-{1}-{2}.json",
seasonNumber.ToString(CultureInfo.InvariantCulture),
episodeNumber.ToString(CultureInfo.InvariantCulture),
preferredLanguage);
@@ -116,7 +116,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
if (!string.IsNullOrEmpty(language))
{
- url += string.Format("&language={0}", language);
+ url += string.Format(CultureInfo.InvariantCulture, "&language={0}", language);
}
var includeImageLanguageParam = TmdbMovieProvider.GetImageLanguagesParam(language);
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
index 2b9077f55..e59504cc6 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeasonProvider.cs
@@ -180,7 +180,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var path = TmdbSeriesProvider.GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId);
- var filename = string.Format("season-{0}-{1}.json",
+ var filename = string.Format(CultureInfo.InvariantCulture, "season-{0}-{1}.json",
seasonNumber.ToString(CultureInfo.InvariantCulture),
preferredLanguage);
@@ -203,7 +203,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
if (!string.IsNullOrEmpty(language))
{
- url += string.Format("&language={0}", TmdbMovieProvider.NormalizeLanguage(language));
+ url += string.Format(CultureInfo.InvariantCulture, "&language={0}", TmdbMovieProvider.NormalizeLanguage(language));
}
var includeImageLanguageParam = TmdbMovieProvider.GetImageLanguagesParam(language);
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
index ac577b125..0eded3233 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TV/TmdbSeriesProvider.cs
@@ -496,7 +496,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
var path = GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId);
- var filename = string.Format("series-{0}.json", preferredLanguage ?? string.Empty);
+ var filename = string.Format(CultureInfo.InvariantCulture, "series-{0}.json", preferredLanguage ?? string.Empty);
return Path.Combine(path, filename);
}
diff --git a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs
index dad155c81..321153c6b 100644
--- a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs
+++ b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
@@ -100,7 +101,7 @@ namespace MediaBrowser.Providers.Studios
private string GetUrl(string image, string filename)
{
- return string.Format("https://raw.github.com/MediaBrowser/MediaBrowser.Resources/master/images/imagesbyname/studios/{0}/{1}.jpg", image, filename);
+ return string.Format(CultureInfo.InvariantCulture, "https://raw.github.com/MediaBrowser/MediaBrowser.Resources/master/images/imagesbyname/studios/{0}/{1}.jpg", image, filename);
}
private Task EnsureThumbsList(string file, CancellationToken cancellationToken)
--
cgit v1.2.3
From 07e7125d07b8440ce01cabc65edec38e2dee0bf2 Mon Sep 17 00:00:00 2001
From: crobibero
Date: Fri, 21 Aug 2020 07:24:44 -0600
Subject: Fix dlna play to
---
Jellyfin.Api/Controllers/SessionController.cs | 16 ++++++----------
MediaBrowser.Model/Session/PlayRequest.cs | 3 ---
2 files changed, 6 insertions(+), 13 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs
index 4795fb0cf..ba8d51598 100644
--- a/Jellyfin.Api/Controllers/SessionController.cs
+++ b/Jellyfin.Api/Controllers/SessionController.cs
@@ -153,7 +153,6 @@ namespace Jellyfin.Api.Controllers
/// The ids of the items to play, comma delimited.
/// The starting position of the first item.
/// The type of play command to issue (PlayNow, PlayNext, PlayLast). Clients who have not yet implemented play next and play last may play now.
- /// The .
/// Instruction sent to session.
/// A .
[HttpPost("Sessions/{sessionId}/Playing")]
@@ -163,17 +162,14 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] string? sessionId,
[FromQuery] Guid[] itemIds,
[FromQuery] long? startPositionTicks,
- [FromQuery] PlayCommand playCommand,
- [FromBody, Required] PlayRequest playRequest)
+ [FromQuery] PlayCommand playCommand)
{
- if (playRequest == null)
+ var playRequest = new PlayRequest
{
- throw new ArgumentException("Request Body may not be null");
- }
-
- playRequest.ItemIds = itemIds;
- playRequest.StartPositionTicks = startPositionTicks;
- playRequest.PlayCommand = playCommand;
+ ItemIds = itemIds,
+ StartPositionTicks = startPositionTicks,
+ PlayCommand = playCommand
+ };
_sessionManager.SendPlayCommand(
RequestHelpers.GetSession(_sessionManager, _authContext, Request).Id,
diff --git a/MediaBrowser.Model/Session/PlayRequest.cs b/MediaBrowser.Model/Session/PlayRequest.cs
index d57bed171..eeb25c2e8 100644
--- a/MediaBrowser.Model/Session/PlayRequest.cs
+++ b/MediaBrowser.Model/Session/PlayRequest.cs
@@ -15,21 +15,18 @@ namespace MediaBrowser.Model.Session
/// Gets or sets the item ids.
///
/// The item ids.
- [ApiMember(Name = "ItemIds", Description = "The ids of the items to play, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST", AllowMultiple = true)]
public Guid[] ItemIds { get; set; }
///
/// Gets or sets the start position ticks that the first item should be played at.
///
/// The start position ticks.
- [ApiMember(Name = "StartPositionTicks", Description = "The starting position of the first item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
public long? StartPositionTicks { get; set; }
///
/// Gets or sets the play command.
///
/// The play command.
- [ApiMember(Name = "PlayCommand", Description = "The type of play command to issue (PlayNow, PlayNext, PlayLast). Clients who have not yet implemented play next and play last may play now.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
public PlayCommand PlayCommand { get; set; }
///
--
cgit v1.2.3
From fa8892fde4282906f4522f033aa88e15b4397a03 Mon Sep 17 00:00:00 2001
From: Patrick Barron
Date: Mon, 24 Aug 2020 20:27:10 -0400
Subject: Make LibraryController.GetDownload async
---
Jellyfin.Api/Controllers/LibraryController.cs | 10 +++++-----
Jellyfin.Server.Implementations/Activity/ActivityManager.cs | 10 ----------
MediaBrowser.Model/Activity/IActivityManager.cs | 2 --
3 files changed, 5 insertions(+), 17 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs
index 4548e202a..796d2d8aa 100644
--- a/Jellyfin.Api/Controllers/LibraryController.cs
+++ b/Jellyfin.Api/Controllers/LibraryController.cs
@@ -619,7 +619,7 @@ namespace Jellyfin.Api.Controllers
[Authorize(Policy = Policies.Download)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult GetDownload([FromRoute] Guid itemId)
+ public async Task GetDownload([FromRoute] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
if (item == null)
@@ -648,7 +648,7 @@ namespace Jellyfin.Api.Controllers
if (user != null)
{
- LogDownload(item, user, auth);
+ await LogDownloadAsync(item, user, auth).ConfigureAwait(false);
}
var path = item.Path;
@@ -861,17 +861,17 @@ namespace Jellyfin.Api.Controllers
: item;
}
- private void LogDownload(BaseItem item, User user, AuthorizationInfo auth)
+ private async Task LogDownloadAsync(BaseItem item, User user, AuthorizationInfo auth)
{
try
{
- _activityManager.Create(new ActivityLog(
+ await _activityManager.CreateAsync(new ActivityLog(
string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name),
"UserDownloadingContent",
auth.UserId)
{
ShortOverview = string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),
- });
+ }).ConfigureAwait(false);
}
catch
{
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 2deefbe81..bd285f6f1 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -27,16 +27,6 @@ namespace Jellyfin.Server.Implementations.Activity
///
public event EventHandler> EntryCreated;
- ///
- public void Create(ActivityLog entry)
- {
- using var dbContext = _provider.CreateContext();
- dbContext.ActivityLogs.Add(entry);
- dbContext.SaveChanges();
-
- EntryCreated?.Invoke(this, new GenericEventArgs(ConvertToOldModel(entry)));
- }
-
///
public async Task CreateAsync(ActivityLog entry)
{
diff --git a/MediaBrowser.Model/Activity/IActivityManager.cs b/MediaBrowser.Model/Activity/IActivityManager.cs
index 9dab5e77b..e5e7b0763 100644
--- a/MediaBrowser.Model/Activity/IActivityManager.cs
+++ b/MediaBrowser.Model/Activity/IActivityManager.cs
@@ -13,8 +13,6 @@ namespace MediaBrowser.Model.Activity
{
event EventHandler> EntryCreated;
- void Create(ActivityLog entry);
-
Task CreateAsync(ActivityLog entry);
QueryResult GetPagedResult(int? startIndex, int? limit);
--
cgit v1.2.3
From 5f64ab02a01f35f2bc2429cdee56973e77048fa5 Mon Sep 17 00:00:00 2001
From: crobibero
Date: Tue, 25 Aug 2020 07:33:58 -0600
Subject: bump System.Text.Json
---
Emby.Server.Implementations/Data/SqliteItemRepository.cs | 3 ---
Jellyfin.Api/Controllers/PluginsController.cs | 8 ++++++--
Jellyfin.Api/Helpers/MediaInfoHelper.cs | 6 +++++-
Jellyfin.Api/Jellyfin.Api.csproj | 1 +
Jellyfin.Data/Jellyfin.Data.csproj | 1 +
Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs | 2 +-
Jellyfin.Server/Jellyfin.Server.csproj | 1 +
.../Migrations/Routines/MigrateDisplayPreferencesDb.cs | 5 +++++
Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs | 7 ++++++-
MediaBrowser.Common/Json/Converters/JsonNullableInt32Converter.cs | 5 +++++
MediaBrowser.Common/Json/Converters/JsonNullableInt64Converter.cs | 5 +++++
MediaBrowser.Common/Json/JsonDefaults.cs | 2 +-
MediaBrowser.Model/MediaBrowser.Model.csproj | 2 +-
tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj | 1 +
14 files changed, 39 insertions(+), 10 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 48e2f5d4a..5bf740cfc 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -90,9 +90,6 @@ namespace Emby.Server.Implementations.Data
_typeMapper = new TypeMapper();
_jsonOptions = JsonDefaults.GetOptions();
- // GetItem throws NotSupportedException with this enabled, so hardcode false.
- _jsonOptions.IgnoreNullValues = false;
-
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
}
diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs
index b2f34680b..a82f2621a 100644
--- a/Jellyfin.Api/Controllers/PluginsController.cs
+++ b/Jellyfin.Api/Controllers/PluginsController.cs
@@ -120,10 +120,14 @@ namespace Jellyfin.Api.Controllers
return NotFound();
}
- var configuration = (BasePluginConfiguration)await JsonSerializer.DeserializeAsync(Request.Body, plugin.ConfigurationType, _serializerOptions)
+ var configuration = (BasePluginConfiguration?)await JsonSerializer.DeserializeAsync(Request.Body, plugin.ConfigurationType, _serializerOptions)
.ConfigureAwait(false);
- plugin.UpdateConfiguration(configuration);
+ if (configuration != null)
+ {
+ plugin.UpdateConfiguration(configuration);
+ }
+
return NoContent();
}
diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
index d2d1855a4..3a736d1e8 100644
--- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs
+++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
@@ -127,7 +127,11 @@ namespace Jellyfin.Api.Helpers
{
// Since we're going to be setting properties on MediaSourceInfos that come out of _mediaSourceManager, we should clone it
// Should we move this directly into MediaSourceManager?
- result.MediaSources = JsonSerializer.Deserialize(JsonSerializer.SerializeToUtf8Bytes(mediaSources));
+ var mediaSourcesClone = JsonSerializer.Deserialize(JsonSerializer.SerializeToUtf8Bytes(mediaSources));
+ if (mediaSourcesClone != null)
+ {
+ result.MediaSources = mediaSourcesClone;
+ }
result.PlaySessionId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
}
diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj
index 24bc07b66..7eb0ba007 100644
--- a/Jellyfin.Api/Jellyfin.Api.csproj
+++ b/Jellyfin.Api/Jellyfin.Api.csproj
@@ -19,6 +19,7 @@
+
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 43b838cc1..bf5833ae4 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -22,6 +22,7 @@
+
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
index 1f9fc7078..ddbe0edb7 100644
--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
@@ -168,7 +168,7 @@ namespace Jellyfin.Server.Extensions
// From JsonDefaults
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
options.JsonSerializerOptions.WriteIndented = jsonOptions.WriteIndented;
- options.JsonSerializerOptions.IgnoreNullValues = jsonOptions.IgnoreNullValues;
+ options.JsonSerializerOptions.DefaultIgnoreCondition = jsonOptions.DefaultIgnoreCondition;
options.JsonSerializerOptions.Converters.Clear();
foreach (var converter in jsonOptions.Converters)
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 7541707d9..4cc51a098 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -54,6 +54,7 @@
+
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
index b15ccf01e..2e5f0cc05 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
@@ -81,6 +81,11 @@ namespace Jellyfin.Server.Migrations.Routines
foreach (var result in results)
{
var dto = JsonSerializer.Deserialize(result[3].ToString(), _jsonOptions);
+ if (dto is null)
+ {
+ continue;
+ }
+
var chromecastVersion = dto.CustomPrefs.TryGetValue("chromecastVersion", out var version)
? chromecastDict[version]
: ChromecastVersion.Stable;
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
index 274e6ab73..6cd6d1f82 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
@@ -74,7 +74,12 @@ namespace Jellyfin.Server.Migrations.Routines
foreach (var entry in queryResult)
{
- UserMockup mockup = JsonSerializer.Deserialize(entry[2].ToBlob(), JsonDefaults.GetOptions());
+ UserMockup? mockup = JsonSerializer.Deserialize(entry[2].ToBlob(), JsonDefaults.GetOptions());
+ if (mockup is null)
+ {
+ continue;
+ }
+
var userDataDir = Path.Combine(_paths.UserConfigurationDirectoryPath, mockup.Name);
var config = File.Exists(Path.Combine(userDataDir, "config.xml"))
diff --git a/MediaBrowser.Common/Json/Converters/JsonNullableInt32Converter.cs b/MediaBrowser.Common/Json/Converters/JsonNullableInt32Converter.cs
index c1660fe76..9db44d626 100644
--- a/MediaBrowser.Common/Json/Converters/JsonNullableInt32Converter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonNullableInt32Converter.cs
@@ -14,6 +14,11 @@ namespace MediaBrowser.Common.Json.Converters
///
public override int? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
+ if (reader.TokenType == JsonTokenType.Null)
+ {
+ return null;
+ }
+
if (reader.TokenType == JsonTokenType.String)
{
ReadOnlySpan span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
diff --git a/MediaBrowser.Common/Json/Converters/JsonNullableInt64Converter.cs b/MediaBrowser.Common/Json/Converters/JsonNullableInt64Converter.cs
index 53e5f6e9d..a9cdc23d7 100644
--- a/MediaBrowser.Common/Json/Converters/JsonNullableInt64Converter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonNullableInt64Converter.cs
@@ -21,6 +21,11 @@ namespace MediaBrowser.Common.Json.Converters
/// Parsed value.
public override long? Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options)
{
+ if (reader.TokenType == JsonTokenType.Null)
+ {
+ return null;
+ }
+
if (reader.TokenType == JsonTokenType.String)
{
// try to parse number directly from bytes
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs
index 891715b3d..b46ecffc7 100644
--- a/MediaBrowser.Common/Json/JsonDefaults.cs
+++ b/MediaBrowser.Common/Json/JsonDefaults.cs
@@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Json
{
ReadCommentHandling = JsonCommentHandling.Disallow,
WriteIndented = false,
- IgnoreNullValues = true
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
options.Converters.Add(new JsonGuidConverter());
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 902e29b20..a2aef948b 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj b/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
index a4ef10648..9d797e8ee 100644
--- a/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
+++ b/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
@@ -10,6 +10,7 @@
+
--
cgit v1.2.3
From 582c016d3bb967dad6100e4ff9c5d84317e2edc5 Mon Sep 17 00:00:00 2001
From: crobibero
Date: Tue, 25 Aug 2020 21:19:55 -0600
Subject: bump to preview8 and remove extra references
---
Jellyfin.Api/Jellyfin.Api.csproj | 1 -
Jellyfin.Data/Jellyfin.Data.csproj | 1 -
Jellyfin.Server/Jellyfin.Server.csproj | 1 -
MediaBrowser.Model/MediaBrowser.Model.csproj | 2 +-
tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj | 1 -
5 files changed, 1 insertion(+), 5 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj
index 7eb0ba007..24bc07b66 100644
--- a/Jellyfin.Api/Jellyfin.Api.csproj
+++ b/Jellyfin.Api/Jellyfin.Api.csproj
@@ -19,7 +19,6 @@
-
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index bf5833ae4..43b838cc1 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -22,7 +22,6 @@
-
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 4cc51a098..7541707d9 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -54,7 +54,6 @@
-
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index a2aef948b..8854caa2e 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj b/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
index 9d797e8ee..a4ef10648 100644
--- a/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
+++ b/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
@@ -10,7 +10,6 @@
-
--
cgit v1.2.3
From 670c41ee8900da32f0936a9a1f45d73e0508432b Mon Sep 17 00:00:00 2001
From: crobibero
Date: Tue, 25 Aug 2020 21:33:19 -0600
Subject: Properly pack project license
---
Emby.Naming/Emby.Naming.csproj | 12 +-
Jellyfin.Data/Jellyfin.Data.csproj | 12 +-
LICENSE | 339 ---------------------
LICENSE.txt | 339 +++++++++++++++++++++
MediaBrowser.Common/MediaBrowser.Common.csproj | 12 +-
.../MediaBrowser.Controller.csproj | 12 +-
MediaBrowser.Model/MediaBrowser.Model.csproj | 12 +-
7 files changed, 394 insertions(+), 344 deletions(-)
delete mode 100644 LICENSE
create mode 100644 LICENSE.txt
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 14aac1a4a..810895757 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -24,10 +24,20 @@
Jellyfin ContributorsJellyfin.Naming10.7.0
- https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
+
+ LICENSE.txt
+
+
+
+
+ LICENSE.txt
+ true
+
+
+
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 64a1dc57a..0b4bbb562 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -11,10 +11,20 @@
Jellyfin ContributorsJellyfin.Data10.7.0
- https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
+
+ LICENSE.txt
+
+
+
+
+ LICENSE.txt
+ true
+
+
+
../jellyfin.ruleset
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 4522ba065..000000000
--- a/LICENSE
+++ /dev/null
@@ -1,339 +0,0 @@
-GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {{description}}
- Copyright (C) {{year}} {{fullname}}
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- {signature of Ty Coon}, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 000000000..4522ba065
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,339 @@
+GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {{description}}
+ Copyright (C) {{year}} {{fullname}}
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ {signature of Ty Coon}, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 04100eba4..3716b66a0 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -9,10 +9,20 @@
Jellyfin ContributorsJellyfin.Common10.7.0
- https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
+
+ LICENSE.txt
+
+
+
+
+ LICENSE.txt
+ true
+
+
+
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index c155c6668..1763d240b 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -9,10 +9,20 @@
Jellyfin ContributorsJellyfin.Controller10.7.0
- https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
+
+ LICENSE.txt
+
+
+
+
+ LICENSE.txt
+ true
+
+
+
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 2cb89f77f..f40b90d89 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -9,10 +9,20 @@
Jellyfin ContributorsJellyfin.Model10.7.0
- https://www.gnu.org/licenses/old-licenses/gpl-2.0.txthttps://github.com/jellyfin/jellyfin
+
+ LICENSE.txt
+
+
+
+
+ LICENSE.txt
+ true
+
+
+
netstandard2.0;netstandard2.1false
--
cgit v1.2.3
From 5f60da29c737cae4ee298f9fbeae971740f8a5ba Mon Sep 17 00:00:00 2001
From: crobibero
Date: Wed, 26 Aug 2020 07:36:57 -0600
Subject: switch to spdx
---
Emby.Naming/Emby.Naming.csproj | 12 +-----------
Jellyfin.Data/Jellyfin.Data.csproj | 12 +-----------
MediaBrowser.Common/MediaBrowser.Common.csproj | 12 +-----------
MediaBrowser.Controller/MediaBrowser.Controller.csproj | 12 +-----------
MediaBrowser.Model/MediaBrowser.Model.csproj | 12 +-----------
5 files changed, 5 insertions(+), 55 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 810895757..cad5001e1 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -25,19 +25,9 @@
Jellyfin.Naming10.7.0https://github.com/jellyfin/jellyfin
+ GPL-3.0-or-later
-
- LICENSE.txt
-
-
-
-
- LICENSE.txt
- true
-
-
-
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 0b4bbb562..18b5bb522 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -12,19 +12,9 @@
Jellyfin.Data10.7.0https://github.com/jellyfin/jellyfin
+ GPL-3.0-or-later
-
- LICENSE.txt
-
-
-
-
- LICENSE.txt
- true
-
-
-
../jellyfin.ruleset
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 3716b66a0..e8ec75349 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -10,19 +10,9 @@
Jellyfin.Common10.7.0https://github.com/jellyfin/jellyfin
+ GPL-3.0-or-later
-
- LICENSE.txt
-
-
-
-
- LICENSE.txt
- true
-
-
-
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 1763d240b..9c86dba24 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -10,19 +10,9 @@
Jellyfin.Controller10.7.0https://github.com/jellyfin/jellyfin
+ GPL-3.0-or-later
-
- LICENSE.txt
-
-
-
-
- LICENSE.txt
- true
-
-
-
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index f40b90d89..81cecf2c7 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -10,19 +10,9 @@
Jellyfin.Model10.7.0https://github.com/jellyfin/jellyfin
+ GPL-3.0-or-later
-
- LICENSE.txt
-
-
-
-
- LICENSE.txt
- true
-
-
-
netstandard2.0;netstandard2.1false
--
cgit v1.2.3
From b02650ec2f812500e99c03a80425d548fc5cfc0c Mon Sep 17 00:00:00 2001
From: crobibero
Date: Wed, 26 Aug 2020 07:39:01 -0600
Subject: use proper spdx
---
Emby.Naming/Emby.Naming.csproj | 2 +-
Jellyfin.Data/Jellyfin.Data.csproj | 2 +-
MediaBrowser.Common/MediaBrowser.Common.csproj | 2 +-
MediaBrowser.Controller/MediaBrowser.Controller.csproj | 2 +-
MediaBrowser.Model/MediaBrowser.Model.csproj | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index cad5001e1..5e2c6e3e3 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -25,7 +25,7 @@
Jellyfin.Naming10.7.0https://github.com/jellyfin/jellyfin
- GPL-3.0-or-later
+ GPL-3.0-only
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index 18b5bb522..e8065419d 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -12,7 +12,7 @@
Jellyfin.Data10.7.0https://github.com/jellyfin/jellyfin
- GPL-3.0-or-later
+ GPL-3.0-only
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index e8ec75349..deb674e45 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -10,7 +10,7 @@
Jellyfin.Common10.7.0https://github.com/jellyfin/jellyfin
- GPL-3.0-or-later
+ GPL-3.0-only
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 9c86dba24..df92eda38 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -10,7 +10,7 @@
Jellyfin.Controller10.7.0https://github.com/jellyfin/jellyfin
- GPL-3.0-or-later
+ GPL-3.0-only
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 81cecf2c7..b0f99cef2 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -10,7 +10,7 @@
Jellyfin.Model10.7.0https://github.com/jellyfin/jellyfin
- GPL-3.0-or-later
+ GPL-3.0-only
--
cgit v1.2.3
From ec8967b8e6f201db84139c6ea96cc1769c2416ff Mon Sep 17 00:00:00 2001
From: crobibero
Date: Thu, 27 Aug 2020 10:00:06 -0600
Subject: Fix partial library and channel access
---
Jellyfin.Server.Implementations/Users/UserManager.cs | 12 ++++++------
Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs | 6 ++++--
MediaBrowser.Model/Users/UserPolicy.cs | 12 ++++++------
3 files changed, 16 insertions(+), 14 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index 3e8edeb44..8f04baa08 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -402,13 +402,13 @@ namespace Jellyfin.Server.Implementations.Users
EnablePublicSharing = user.HasPermission(PermissionKind.EnablePublicSharing),
AccessSchedules = user.AccessSchedules.ToArray(),
BlockedTags = user.GetPreference(PreferenceKind.BlockedTags),
- EnabledChannels = user.GetPreference(PreferenceKind.EnabledChannels),
+ EnabledChannels = user.GetPreference(PreferenceKind.EnabledChannels)?.Select(Guid.Parse).ToArray(),
EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices),
- EnabledFolders = user.GetPreference(PreferenceKind.EnabledFolders),
+ EnabledFolders = user.GetPreference(PreferenceKind.EnabledFolders)?.Select(Guid.Parse).ToArray(),
EnableContentDeletionFromFolders = user.GetPreference(PreferenceKind.EnableContentDeletionFromFolders),
SyncPlayAccess = user.SyncPlayAccess,
- BlockedChannels = user.GetPreference(PreferenceKind.BlockedChannels),
- BlockedMediaFolders = user.GetPreference(PreferenceKind.BlockedMediaFolders),
+ BlockedChannels = user.GetPreference(PreferenceKind.BlockedChannels)?.Select(Guid.Parse).ToArray(),
+ BlockedMediaFolders = user.GetPreference(PreferenceKind.BlockedMediaFolders)?.Select(Guid.Parse).ToArray(),
BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems).Select(Enum.Parse).ToArray()
}
};
@@ -735,9 +735,9 @@ namespace Jellyfin.Server.Implementations.Users
PreferenceKind.BlockUnratedItems,
policy.BlockUnratedItems?.Select(i => i.ToString()).ToArray() ?? Array.Empty());
user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags);
- user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels);
+ user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels?.Select(i => i.ToString("N", CultureInfo.InvariantCulture)).ToArray());
user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices);
- user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders);
+ user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders?.Select(i => i.ToString("N", CultureInfo.InvariantCulture)).ToArray());
user.SetPreference(PreferenceKind.EnableContentDeletionFromFolders, policy.EnableContentDeletionFromFolders);
dbContext.Update(user);
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
index ac6890f38..74c550331 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs
@@ -1,5 +1,7 @@
using System;
+using System.Globalization;
using System.IO;
+using System.Linq;
using Emby.Server.Implementations.Data;
using Emby.Server.Implementations.Serialization;
using Jellyfin.Data.Entities;
@@ -166,9 +168,9 @@ namespace Jellyfin.Server.Migrations.Routines
}
user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags);
- user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels);
+ user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels?.Select(i => i.ToString("N", CultureInfo.InvariantCulture)).ToArray());
user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices);
- user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders);
+ user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders?.Select(i => i.ToString("N", CultureInfo.InvariantCulture)).ToArray());
user.SetPreference(PreferenceKind.EnableContentDeletionFromFolders, policy.EnableContentDeletionFromFolders);
user.SetPreference(PreferenceKind.OrderedViews, config.OrderedViews);
user.SetPreference(PreferenceKind.GroupedFolders, config.GroupedFolders);
diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs
index caf2e0f54..a1f01f7e8 100644
--- a/MediaBrowser.Model/Users/UserPolicy.cs
+++ b/MediaBrowser.Model/Users/UserPolicy.cs
@@ -80,11 +80,11 @@ namespace MediaBrowser.Model.Users
public bool EnableAllDevices { get; set; }
- public string[] EnabledChannels { get; set; }
+ public Guid[] EnabledChannels { get; set; }
public bool EnableAllChannels { get; set; }
- public string[] EnabledFolders { get; set; }
+ public Guid[] EnabledFolders { get; set; }
public bool EnableAllFolders { get; set; }
@@ -94,9 +94,9 @@ namespace MediaBrowser.Model.Users
public bool EnablePublicSharing { get; set; }
- public string[] BlockedMediaFolders { get; set; }
+ public Guid[] BlockedMediaFolders { get; set; }
- public string[] BlockedChannels { get; set; }
+ public Guid[] BlockedChannels { get; set; }
public int RemoteClientBitrateLimit { get; set; }
@@ -145,10 +145,10 @@ namespace MediaBrowser.Model.Users
LoginAttemptsBeforeLockout = -1;
EnableAllChannels = true;
- EnabledChannels = Array.Empty();
+ EnabledChannels = Array.Empty();
EnableAllFolders = true;
- EnabledFolders = Array.Empty();
+ EnabledFolders = Array.Empty();
EnabledDevices = Array.Empty();
EnableAllDevices = true;
--
cgit v1.2.3
From e3377564288598742dbf64f396ed38e42b6b2915 Mon Sep 17 00:00:00 2001
From: Claus Vium
Date: Wed, 2 Sep 2020 12:22:14 +0200
Subject: Remove ServiceStack and related stuff
---
Emby.Server.Implementations/ApplicationHost.cs | 8 +-
.../HttpServer/FileWriter.cs | 250 -------
.../HttpServer/HttpListenerHost.cs | 233 +------
.../HttpServer/HttpResultFactory.cs | 721 ---------------------
.../HttpServer/RangeRequestWriter.cs | 212 ------
.../HttpServer/ResponseFilter.cs | 113 ----
.../HttpServer/Security/AuthService.cs | 213 +-----
.../HttpServer/Security/AuthorizationContext.cs | 21 +-
.../HttpServer/Security/SessionContext.cs | 20 +-
.../HttpServer/StreamWriter.cs | 120 ----
Emby.Server.Implementations/Services/HttpResult.cs | 64 --
.../Services/RequestHelper.cs | 51 --
.../Services/ResponseHelper.cs | 141 ----
.../Services/ServiceController.cs | 202 ------
.../Services/ServiceExec.cs | 230 -------
.../Services/ServiceHandler.cs | 212 ------
.../Services/ServiceMethod.cs | 20 -
.../Services/ServicePath.cs | 550 ----------------
.../Services/StringMapTypeDeserializer.cs | 118 ----
.../Services/UrlExtensions.cs | 27 -
.../SocketSharp/WebSocketSharpRequest.cs | 248 -------
.../Extensions/HttpContextExtensions.cs | 55 +-
.../MediaEncoding/EncodingJobOptions.cs | 30 -
.../Net/AuthenticatedAttribute.cs | 76 ---
MediaBrowser.Controller/Net/IAuthService.cs | 17 -
.../Net/IAuthorizationContext.cs | 3 +-
MediaBrowser.Controller/Net/IHasResultFactory.cs | 17 -
MediaBrowser.Controller/Net/IHttpResultFactory.cs | 82 ---
MediaBrowser.Controller/Net/IHttpServer.cs | 9 +-
MediaBrowser.Controller/Net/ISessionContext.cs | 6 +-
MediaBrowser.Controller/Net/StaticResultOptions.cs | 44 --
MediaBrowser.Model/Services/ApiMemberAttribute.cs | 65 --
MediaBrowser.Model/Services/IAsyncStreamWriter.cs | 13 -
MediaBrowser.Model/Services/IHasHeaders.cs | 11 -
MediaBrowser.Model/Services/IHasRequestFilter.cs | 24 -
MediaBrowser.Model/Services/IHttpRequest.cs | 17 -
MediaBrowser.Model/Services/IHttpResult.cs | 35 -
MediaBrowser.Model/Services/IRequest.cs | 93 ---
.../Services/IRequiresRequestStream.cs | 14 -
MediaBrowser.Model/Services/IService.cs | 15 -
MediaBrowser.Model/Services/IStreamWriter.cs | 11 -
.../Services/QueryParamCollection.cs | 147 -----
MediaBrowser.Model/Services/RouteAttribute.cs | 163 -----
MediaBrowser.Model/Session/PlayRequest.cs | 1 -
.../HttpServer/ResponseFilterTests.cs | 18 -
45 files changed, 91 insertions(+), 4649 deletions(-)
delete mode 100644 Emby.Server.Implementations/HttpServer/FileWriter.cs
delete mode 100644 Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
delete mode 100644 Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs
delete mode 100644 Emby.Server.Implementations/HttpServer/ResponseFilter.cs
delete mode 100644 Emby.Server.Implementations/HttpServer/StreamWriter.cs
delete mode 100644 Emby.Server.Implementations/Services/HttpResult.cs
delete mode 100644 Emby.Server.Implementations/Services/RequestHelper.cs
delete mode 100644 Emby.Server.Implementations/Services/ResponseHelper.cs
delete mode 100644 Emby.Server.Implementations/Services/ServiceController.cs
delete mode 100644 Emby.Server.Implementations/Services/ServiceExec.cs
delete mode 100644 Emby.Server.Implementations/Services/ServiceHandler.cs
delete mode 100644 Emby.Server.Implementations/Services/ServiceMethod.cs
delete mode 100644 Emby.Server.Implementations/Services/ServicePath.cs
delete mode 100644 Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
delete mode 100644 Emby.Server.Implementations/Services/UrlExtensions.cs
delete mode 100644 Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
delete mode 100644 MediaBrowser.Controller/Net/AuthenticatedAttribute.cs
delete mode 100644 MediaBrowser.Controller/Net/IHasResultFactory.cs
delete mode 100644 MediaBrowser.Controller/Net/IHttpResultFactory.cs
delete mode 100644 MediaBrowser.Controller/Net/StaticResultOptions.cs
delete mode 100644 MediaBrowser.Model/Services/ApiMemberAttribute.cs
delete mode 100644 MediaBrowser.Model/Services/IAsyncStreamWriter.cs
delete mode 100644 MediaBrowser.Model/Services/IHasHeaders.cs
delete mode 100644 MediaBrowser.Model/Services/IHasRequestFilter.cs
delete mode 100644 MediaBrowser.Model/Services/IHttpRequest.cs
delete mode 100644 MediaBrowser.Model/Services/IHttpResult.cs
delete mode 100644 MediaBrowser.Model/Services/IRequest.cs
delete mode 100644 MediaBrowser.Model/Services/IRequiresRequestStream.cs
delete mode 100644 MediaBrowser.Model/Services/IService.cs
delete mode 100644 MediaBrowser.Model/Services/IStreamWriter.cs
delete mode 100644 MediaBrowser.Model/Services/QueryParamCollection.cs
delete mode 100644 MediaBrowser.Model/Services/RouteAttribute.cs
delete mode 100644 tests/Jellyfin.Server.Implementations.Tests/HttpServer/ResponseFilterTests.cs
(limited to 'MediaBrowser.Model')
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index e9b063277..4f47d1999 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -41,7 +41,6 @@ using Emby.Server.Implementations.QuickConnect;
using Emby.Server.Implementations.ScheduledTasks;
using Emby.Server.Implementations.Security;
using Emby.Server.Implementations.Serialization;
-using Emby.Server.Implementations.Services;
using Emby.Server.Implementations.Session;
using Emby.Server.Implementations.SyncPlay;
using Emby.Server.Implementations.TV;
@@ -90,7 +89,6 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Providers.Chapters;
@@ -544,8 +542,6 @@ namespace Emby.Server.Implementations
ServiceCollection.AddSingleton();
- ServiceCollection.AddSingleton();
-
ServiceCollection.AddSingleton(this);
ServiceCollection.AddSingleton(ApplicationPaths);
@@ -581,7 +577,6 @@ namespace Emby.Server.Implementations
ServiceCollection.AddSingleton();
- ServiceCollection.AddSingleton();
ServiceCollection.AddSingleton();
ServiceCollection.AddSingleton();
@@ -757,7 +752,6 @@ namespace Emby.Server.Implementations
CollectionFolder.XmlSerializer = _xmlSerializer;
CollectionFolder.JsonSerializer = Resolve();
CollectionFolder.ApplicationHost = this;
- AuthenticatedAttribute.AuthService = Resolve();
}
///
@@ -777,7 +771,7 @@ namespace Emby.Server.Implementations
.Where(i => i != null)
.ToArray();
- _httpServer.Init(GetExportTypes(), GetExports(), GetUrlPrefixes());
+ _httpServer.Init(GetExports(), GetUrlPrefixes());
Resolve().AddParts(
GetExports(),
diff --git a/Emby.Server.Implementations/HttpServer/FileWriter.cs b/Emby.Server.Implementations/HttpServer/FileWriter.cs
deleted file mode 100644
index 6fce8de44..000000000
--- a/Emby.Server.Implementations/HttpServer/FileWriter.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Runtime.InteropServices;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Services;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Logging;
-using Microsoft.Net.Http.Headers;
-
-namespace Emby.Server.Implementations.HttpServer
-{
- public class FileWriter : IHttpResult
- {
- private static readonly CultureInfo UsCulture = CultureInfo.ReadOnly(new CultureInfo("en-US"));
-
- private static readonly string[] _skipLogExtensions = {
- ".js",
- ".html",
- ".css"
- };
-
- private readonly IStreamHelper _streamHelper;
- private readonly ILogger _logger;
-
- ///
- /// The _options.
- ///
- private readonly IDictionary _options = new Dictionary();
-
- ///
- /// The _requested ranges.
- ///
- private List> _requestedRanges;
-
- public FileWriter(string path, string contentType, string rangeHeader, ILogger logger, IFileSystem fileSystem, IStreamHelper streamHelper)
- {
- if (string.IsNullOrEmpty(contentType))
- {
- throw new ArgumentNullException(nameof(contentType));
- }
-
- _streamHelper = streamHelper;
-
- Path = path;
- _logger = logger;
- RangeHeader = rangeHeader;
-
- Headers[HeaderNames.ContentType] = contentType;
-
- TotalContentLength = fileSystem.GetFileInfo(path).Length;
- Headers[HeaderNames.AcceptRanges] = "bytes";
-
- if (string.IsNullOrWhiteSpace(rangeHeader))
- {
- Headers[HeaderNames.ContentLength] = TotalContentLength.ToString(CultureInfo.InvariantCulture);
- StatusCode = HttpStatusCode.OK;
- }
- else
- {
- StatusCode = HttpStatusCode.PartialContent;
- SetRangeValues();
- }
-
- FileShare = FileShare.Read;
- Cookies = new List();
- }
-
- private string RangeHeader { get; set; }
-
- private bool IsHeadRequest { get; set; }
-
- private long RangeStart { get; set; }
-
- private long RangeEnd { get; set; }
-
- private long RangeLength { get; set; }
-
- public long TotalContentLength { get; set; }
-
- public Action OnComplete { get; set; }
-
- public Action OnError { get; set; }
-
- public List Cookies { get; private set; }
-
- public FileShare FileShare { get; set; }
-
- ///
- /// Gets the options.
- ///
- /// The options.
- public IDictionary Headers => _options;
-
- public string Path { get; set; }
-
- ///
- /// Gets the requested ranges.
- ///
- /// The requested ranges.
- protected List> RequestedRanges
- {
- get
- {
- if (_requestedRanges == null)
- {
- _requestedRanges = new List>();
-
- // Example: bytes=0-,32-63
- var ranges = RangeHeader.Split('=')[1].Split(',');
-
- foreach (var range in ranges)
- {
- var vals = range.Split('-');
-
- long start = 0;
- long? end = null;
-
- if (!string.IsNullOrEmpty(vals[0]))
- {
- start = long.Parse(vals[0], UsCulture);
- }
-
- if (!string.IsNullOrEmpty(vals[1]))
- {
- end = long.Parse(vals[1], UsCulture);
- }
-
- _requestedRanges.Add(new KeyValuePair(start, end));
- }
- }
-
- return _requestedRanges;
- }
- }
-
- public string ContentType { get; set; }
-
- public IRequest RequestContext { get; set; }
-
- public object Response { get; set; }
-
- public int Status { get; set; }
-
- public HttpStatusCode StatusCode
- {
- get => (HttpStatusCode)Status;
- set => Status = (int)value;
- }
-
- ///
- /// Sets the range values.
- ///
- private void SetRangeValues()
- {
- var requestedRange = RequestedRanges[0];
-
- // If the requested range is "0-", we can optimize by just doing a stream copy
- if (!requestedRange.Value.HasValue)
- {
- RangeEnd = TotalContentLength - 1;
- }
- else
- {
- RangeEnd = requestedRange.Value.Value;
- }
-
- RangeStart = requestedRange.Key;
- RangeLength = 1 + RangeEnd - RangeStart;
-
- // Content-Length is the length of what we're serving, not the original content
- var lengthString = RangeLength.ToString(CultureInfo.InvariantCulture);
- Headers[HeaderNames.ContentLength] = lengthString;
- var rangeString = $"bytes {RangeStart}-{RangeEnd}/{TotalContentLength}";
- Headers[HeaderNames.ContentRange] = rangeString;
-
- _logger.LogDebug("Setting range response values for {0}. RangeRequest: {1} Content-Length: {2}, Content-Range: {3}", Path, RangeHeader, lengthString, rangeString);
- }
-
- public async Task WriteToAsync(HttpResponse response, CancellationToken cancellationToken)
- {
- try
- {
- // Headers only
- if (IsHeadRequest)
- {
- return;
- }
-
- var path = Path;
- var offset = RangeStart;
- var count = RangeLength;
-
- if (string.IsNullOrWhiteSpace(RangeHeader) || RangeStart <= 0 && RangeEnd >= TotalContentLength - 1)
- {
- var extension = System.IO.Path.GetExtension(path);
-
- if (extension == null || !_skipLogExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
- {
- _logger.LogDebug("Transmit file {0}", path);
- }
-
- offset = 0;
- count = 0;
- }
-
- await TransmitFile(response.Body, path, offset, count, FileShare, cancellationToken).ConfigureAwait(false);
- }
- finally
- {
- OnComplete?.Invoke();
- }
- }
-
- public async Task TransmitFile(Stream stream, string path, long offset, long count, FileShare fileShare, CancellationToken cancellationToken)
- {
- var fileOptions = FileOptions.SequentialScan;
-
- // use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- fileOptions |= FileOptions.Asynchronous;
- }
-
- using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, fileShare, IODefaults.FileStreamBufferSize, fileOptions))
- {
- if (offset > 0)
- {
- fs.Position = offset;
- }
-
- if (count > 0)
- {
- await _streamHelper.CopyToAsync(fs, stream, count, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- await fs.CopyToAsync(stream, IODefaults.CopyToBufferSize, cancellationToken).ConfigureAwait(false);
- }
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index fe39bb4b2..30cb7dd3a 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -7,11 +7,8 @@ using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Net.WebSockets;
-using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
-using Emby.Server.Implementations.Services;
-using Emby.Server.Implementations.SocketSharp;
using Jellyfin.Data.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
@@ -20,8 +17,6 @@ using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Globalization;
-using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.WebUtilities;
@@ -29,7 +24,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
-using ServiceStack.Text.Jsv;
namespace Emby.Server.Implementations.HttpServer
{
@@ -46,13 +40,9 @@ namespace Emby.Server.Implementations.HttpServer
private readonly IServerConfigurationManager _config;
private readonly INetworkManager _networkManager;
private readonly IServerApplicationHost _appHost;
- private readonly IJsonSerializer _jsonSerializer;
- private readonly IXmlSerializer _xmlSerializer;
- private readonly Func> _funcParseFn;
private readonly string _defaultRedirectPath;
private readonly string _baseUrlPrefix;
- private readonly Dictionary _serviceOperationsMap = new Dictionary();
private readonly IHostEnvironment _hostEnvironment;
private IWebSocketListener[] _webSocketListeners = Array.Empty();
@@ -64,10 +54,7 @@ namespace Emby.Server.Implementations.HttpServer
IServerConfigurationManager config,
IConfiguration configuration,
INetworkManager networkManager,
- IJsonSerializer jsonSerializer,
- IXmlSerializer xmlSerializer,
ILocalizationManager localizationManager,
- ServiceController serviceController,
IHostEnvironment hostEnvironment,
ILoggerFactory loggerFactory)
{
@@ -77,36 +64,21 @@ namespace Emby.Server.Implementations.HttpServer
_defaultRedirectPath = configuration[DefaultRedirectKey];
_baseUrlPrefix = _config.Configuration.BaseUrl;
_networkManager = networkManager;
- _jsonSerializer = jsonSerializer;
- _xmlSerializer = xmlSerializer;
- ServiceController = serviceController;
_hostEnvironment = hostEnvironment;
_loggerFactory = loggerFactory;
- _funcParseFn = t => s => JsvReader.GetParseFn(t)(s);
-
Instance = this;
- ResponseFilters = Array.Empty>();
GlobalResponse = localizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
}
public event EventHandler> WebSocketConnected;
- public Action[] ResponseFilters { get; set; }
-
public static HttpListenerHost Instance { get; protected set; }
public string[] UrlPrefixes { get; private set; }
public string GlobalResponse { get; set; }
- public ServiceController ServiceController { get; }
-
- public object CreateInstance(Type type)
- {
- return _appHost.CreateInstance(type);
- }
-
private static string NormalizeUrlPath(string path)
{
if (path.Length > 0 && path[0] == '/')
@@ -121,58 +93,6 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- ///
- /// Applies the request filters. Returns whether or not the request has been handled
- /// and no more processing should be done.
- ///
- ///
- public void ApplyRequestFilters(IRequest req, HttpResponse res, object requestDto)
- {
- // Exec all RequestFilter attributes with Priority < 0
- var attributes = GetRequestFilterAttributes(requestDto.GetType());
-
- int count = attributes.Count;
- int i = 0;
- for (; i < count && attributes[i].Priority < 0; i++)
- {
- var attribute = attributes[i];
- attribute.RequestFilter(req, res, requestDto);
- }
-
- // Exec remaining RequestFilter attributes with Priority >= 0
- for (; i < count && attributes[i].Priority >= 0; i++)
- {
- var attribute = attributes[i];
- attribute.RequestFilter(req, res, requestDto);
- }
- }
-
- public Type GetServiceTypeByRequest(Type requestType)
- {
- _serviceOperationsMap.TryGetValue(requestType, out var serviceType);
- return serviceType;
- }
-
- public void AddServiceInfo(Type serviceType, Type requestType)
- {
- _serviceOperationsMap[requestType] = serviceType;
- }
-
- private List GetRequestFilterAttributes(Type requestDtoType)
- {
- var attributes = requestDtoType.GetCustomAttributes(true).OfType().ToList();
-
- var serviceType = GetServiceTypeByRequest(requestDtoType);
- if (serviceType != null)
- {
- attributes.AddRange(serviceType.GetCustomAttributes(true).OfType());
- }
-
- attributes.Sort((x, y) => x.Priority - y.Priority);
-
- return attributes;
- }
-
private static Exception GetActualException(Exception ex)
{
if (ex is AggregateException agg)
@@ -210,7 +130,7 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- private async Task ErrorHandler(Exception ex, IRequest httpReq, int statusCode, string urlToLog, bool ignoreStackTrace)
+ private async Task ErrorHandler(Exception ex, HttpContext httpContext, int statusCode, string urlToLog, bool ignoreStackTrace)
{
if (ignoreStackTrace)
{
@@ -221,7 +141,7 @@ namespace Emby.Server.Implementations.HttpServer
_logger.LogError(ex, "Error processing request. URL: {Url}", urlToLog);
}
- var httpRes = httpReq.Response;
+ var httpRes = httpContext.Response;
if (httpRes.HasStarted)
{
@@ -395,24 +315,22 @@ namespace Emby.Server.Implementations.HttpServer
return WebSocketRequestHandler(context);
}
- var request = context.Request;
- var response = context.Response;
- var localPath = context.Request.Path.ToString();
-
- var req = new WebSocketSharpRequest(request, response, request.Path);
- return RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted);
+ return RequestHandler(context, context.RequestAborted);
}
///
/// Overridable method that can be used to implement a custom handler.
///
- private async Task RequestHandler(IHttpRequest httpReq, string urlString, string host, string localPath, CancellationToken cancellationToken)
+ private async Task RequestHandler(HttpContext httpContext, CancellationToken cancellationToken)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
- var httpRes = httpReq.Response;
+ var httpRes = httpContext.Response;
+ var host = httpContext.Request.Host.ToString();
+ var localPath = httpContext.Request.Path.ToString();
+ var urlString = httpContext.Request.GetDisplayUrl();
string urlToLog = GetUrlToLog(urlString);
- string remoteIp = httpReq.RemoteIp;
+ string remoteIp = httpContext.Request.RemoteIp();
try
{
@@ -432,7 +350,7 @@ namespace Emby.Server.Implementations.HttpServer
return;
}
- if (!ValidateRequest(remoteIp, httpReq.IsLocal))
+ if (!ValidateRequest(remoteIp, httpContext.Request.IsLocal()))
{
httpRes.StatusCode = 403;
httpRes.ContentType = "text/plain";
@@ -440,16 +358,16 @@ namespace Emby.Server.Implementations.HttpServer
return;
}
- if (!ValidateSsl(httpReq.RemoteIp, urlString))
+ if (!ValidateSsl(httpContext.Request.RemoteIp(), urlString))
{
- RedirectToSecureUrl(httpReq, httpRes, urlString);
+ RedirectToSecureUrl(httpRes, urlString);
return;
}
- if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(httpContext.Request.Method, "OPTIONS", StringComparison.OrdinalIgnoreCase))
{
httpRes.StatusCode = 200;
- foreach (var (key, value) in GetDefaultCorsHeaders(httpReq))
+ foreach (var (key, value) in GetDefaultCorsHeaders(httpContext))
{
httpRes.Headers.Add(key, value);
}
@@ -483,15 +401,7 @@ namespace Emby.Server.Implementations.HttpServer
}
}
- var handler = GetServiceHandler(httpReq);
- if (handler != null)
- {
- await handler.ProcessRequestAsync(this, httpReq, httpRes, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- throw new FileNotFoundException();
- }
+ throw new FileNotFoundException();
}
catch (Exception requestEx)
{
@@ -500,7 +410,7 @@ namespace Emby.Server.Implementations.HttpServer
var requestInnerEx = GetActualException(requestEx);
var statusCode = GetStatusCode(requestInnerEx);
- foreach (var (key, value) in GetDefaultCorsHeaders(httpReq))
+ foreach (var (key, value) in GetDefaultCorsHeaders(httpContext))
{
if (!httpRes.Headers.ContainsKey(key))
{
@@ -525,7 +435,7 @@ namespace Emby.Server.Implementations.HttpServer
throw;
}
- await ErrorHandler(requestInnerEx, httpReq, statusCode, urlToLog, ignoreStackTrace).ConfigureAwait(false);
+ await ErrorHandler(requestInnerEx, httpContext, statusCode, urlToLog, ignoreStackTrace).ConfigureAwait(false);
}
catch (Exception handlerException)
{
@@ -596,12 +506,12 @@ namespace Emby.Server.Implementations.HttpServer
///
///
///
- public IDictionary GetDefaultCorsHeaders(IRequest req)
+ public IDictionary GetDefaultCorsHeaders(HttpContext httpContext)
{
- var origin = req.Headers["Origin"];
+ var origin = httpContext.Request.Headers["Origin"];
if (origin == StringValues.Empty)
{
- origin = req.Headers["Host"];
+ origin = httpContext.Request.Headers["Host"];
if (origin == StringValues.Empty)
{
origin = "*";
@@ -616,23 +526,7 @@ namespace Emby.Server.Implementations.HttpServer
return headers;
}
- // Entry point for HttpListener
- public ServiceHandler GetServiceHandler(IHttpRequest httpReq)
- {
- var pathInfo = httpReq.PathInfo;
-
- pathInfo = ServiceHandler.GetSanitizedPathInfo(pathInfo, out string contentType);
- var restPath = ServiceController.GetRestPathForRequest(httpReq.HttpMethod, pathInfo);
- if (restPath != null)
- {
- return new ServiceHandler(restPath, contentType);
- }
-
- _logger.LogError("Could not find handler for {PathInfo}", pathInfo);
- return null;
- }
-
- private void RedirectToSecureUrl(IHttpRequest httpReq, HttpResponse httpRes, string url)
+ private void RedirectToSecureUrl(HttpResponse httpRes, string url)
{
if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri))
{
@@ -650,95 +544,12 @@ namespace Emby.Server.Implementations.HttpServer
///
/// Adds the rest handlers.
///
- /// The service types to register with the .
/// The web socket listeners.
/// The URL prefixes. See .
- public void Init(IEnumerable serviceTypes, IEnumerable listeners, IEnumerable urlPrefixes)
+ public void Init(IEnumerable listeners, IEnumerable urlPrefixes)
{
_webSocketListeners = listeners.ToArray();
UrlPrefixes = urlPrefixes.ToArray();
-
- ServiceController.Init(this, serviceTypes);
-
- ResponseFilters = new Action[]
- {
- new ResponseFilter(this, _logger).FilterResponse
- };
- }
-
- public RouteAttribute[] GetRouteAttributes(Type requestType)
- {
- var routes = requestType.GetTypeInfo().GetCustomAttributes(true).ToList();
- var clone = routes.ToList();
-
- foreach (var route in clone)
- {
- routes.Add(new RouteAttribute(NormalizeCustomRoutePath(route.Path), route.Verbs)
- {
- Notes = route.Notes,
- Priority = route.Priority,
- Summary = route.Summary
- });
-
- routes.Add(new RouteAttribute(NormalizeEmbyRoutePath(route.Path), route.Verbs)
- {
- Notes = route.Notes,
- Priority = route.Priority,
- Summary = route.Summary
- });
-
- routes.Add(new RouteAttribute(NormalizeMediaBrowserRoutePath(route.Path), route.Verbs)
- {
- Notes = route.Notes,
- Priority = route.Priority,
- Summary = route.Summary
- });
- }
-
- return routes.ToArray();
- }
-
- public Func GetParseFn(Type propertyType)
- {
- return _funcParseFn(propertyType);
- }
-
- public void SerializeToJson(object o, Stream stream)
- {
- _jsonSerializer.SerializeToStream(o, stream);
- }
-
- public void SerializeToXml(object o, Stream stream)
- {
- _xmlSerializer.SerializeToStream(o, stream);
- }
-
- public Task
/// The HTTP req.
/// Dictionary{System.StringSystem.String}.
- private Dictionary GetAuthorizationDictionary(IRequest httpReq)
+ private Dictionary GetAuthorizationDictionary(HttpContext httpReq)
{
- var auth = httpReq.Headers["X-Emby-Authorization"];
+ var auth = httpReq.Request.Headers["X-Emby-Authorization"];
if (string.IsNullOrEmpty(auth))
{
- auth = httpReq.Headers[HeaderNames.Authorization];
+ auth = httpReq.Request.Headers[HeaderNames.Authorization];
}
return GetAuthorization(auth);
diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
index 03fcfa53d..8777c59b7 100644
--- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
@@ -2,11 +2,11 @@
using System;
using Jellyfin.Data.Entities;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
-using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Services;
+using Microsoft.AspNetCore.Http;
namespace Emby.Server.Implementations.HttpServer.Security
{
@@ -23,26 +23,20 @@ namespace Emby.Server.Implementations.HttpServer.Security
_sessionManager = sessionManager;
}
- public SessionInfo GetSession(IRequest requestContext)
+ public SessionInfo GetSession(HttpContext requestContext)
{
var authorization = _authContext.GetAuthorizationInfo(requestContext);
var user = authorization.User;
- return _sessionManager.LogSessionActivity(authorization.Client, authorization.Version, authorization.DeviceId, authorization.Device, requestContext.RemoteIp, user);
- }
-
- private AuthenticationInfo GetTokenInfo(IRequest request)
- {
- request.Items.TryGetValue("OriginalAuthenticationInfo", out var info);
- return info as AuthenticationInfo;
+ return _sessionManager.LogSessionActivity(authorization.Client, authorization.Version, authorization.DeviceId, authorization.Device, requestContext.Request.RemoteIp(), user);
}
public SessionInfo GetSession(object requestContext)
{
- return GetSession((IRequest)requestContext);
+ return GetSession((HttpContext)requestContext);
}
- public User GetUser(IRequest requestContext)
+ public User GetUser(HttpContext requestContext)
{
var session = GetSession(requestContext);
@@ -51,7 +45,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
public User GetUser(object requestContext)
{
- return GetUser((IRequest)requestContext);
+ return GetUser((HttpContext)requestContext);
}
}
}
diff --git a/Emby.Server.Implementations/HttpServer/StreamWriter.cs b/Emby.Server.Implementations/HttpServer/StreamWriter.cs
deleted file mode 100644
index 00e3ab8fe..000000000
--- a/Emby.Server.Implementations/HttpServer/StreamWriter.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Services;
-using Microsoft.Net.Http.Headers;
-
-namespace Emby.Server.Implementations.HttpServer
-{
- ///
- /// Class StreamWriter.
- ///
- public class StreamWriter : IAsyncStreamWriter, IHasHeaders
- {
- ///
- /// The options.
- ///
- private readonly IDictionary _options = new Dictionary();
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The source.
- /// Type of the content.
- public StreamWriter(Stream source, string contentType)
- {
- if (string.IsNullOrEmpty(contentType))
- {
- throw new ArgumentNullException(nameof(contentType));
- }
-
- SourceStream = source;
-
- Headers["Content-Type"] = contentType;
-
- if (source.CanSeek)
- {
- Headers[HeaderNames.ContentLength] = source.Length.ToString(CultureInfo.InvariantCulture);
- }
-
- Headers[HeaderNames.ContentType] = contentType;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The source.
- /// Type of the content.
- /// The content length.
- public StreamWriter(byte[] source, string contentType, int contentLength)
- {
- if (string.IsNullOrEmpty(contentType))
- {
- throw new ArgumentNullException(nameof(contentType));
- }
-
- SourceBytes = source;
-
- Headers[HeaderNames.ContentLength] = contentLength.ToString(CultureInfo.InvariantCulture);
- Headers[HeaderNames.ContentType] = contentType;
- }
-
- ///
- /// Gets or sets the source stream.
- ///
- /// The source stream.
- private Stream SourceStream { get; set; }
-
- private byte[] SourceBytes { get; set; }
-
- ///
- /// Gets the options.
- ///
- /// The options.
- public IDictionary Headers => _options;
-
- ///
- /// Fires when complete.
- ///
- public Action OnComplete { get; set; }
-
- ///
- /// Fires when an error occours.
- ///
- public Action OnError { get; set; }
-
- ///
- public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
- {
- try
- {
- var bytes = SourceBytes;
-
- if (bytes != null)
- {
- await responseStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- using (var src = SourceStream)
- {
- await src.CopyToAsync(responseStream, cancellationToken).ConfigureAwait(false);
- }
- }
- }
- catch
- {
- OnError?.Invoke();
-
- throw;
- }
- finally
- {
- OnComplete?.Invoke();
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/HttpResult.cs b/Emby.Server.Implementations/Services/HttpResult.cs
deleted file mode 100644
index 8ba86f756..000000000
--- a/Emby.Server.Implementations/Services/HttpResult.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-#pragma warning disable CS1591
-
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Services;
-
-namespace Emby.Server.Implementations.Services
-{
- public class HttpResult
- : IHttpResult, IAsyncStreamWriter
- {
- public HttpResult(object response, string contentType, HttpStatusCode statusCode)
- {
- this.Headers = new Dictionary();
-
- this.Response = response;
- this.ContentType = contentType;
- this.StatusCode = statusCode;
- }
-
- public object Response { get; set; }
-
- public string ContentType { get; set; }
-
- public IDictionary Headers { get; private set; }
-
- public int Status { get; set; }
-
- public HttpStatusCode StatusCode
- {
- get => (HttpStatusCode)Status;
- set => Status = (int)value;
- }
-
- public IRequest RequestContext { get; set; }
-
- public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
- {
- var response = RequestContext?.Response;
-
- if (this.Response is byte[] bytesResponse)
- {
- var contentLength = bytesResponse.Length;
-
- if (response != null)
- {
- response.ContentLength = contentLength;
- }
-
- if (contentLength > 0)
- {
- await responseStream.WriteAsync(bytesResponse, 0, contentLength, cancellationToken).ConfigureAwait(false);
- }
-
- return;
- }
-
- await ResponseHelper.WriteObject(this.RequestContext, this.Response, response).ConfigureAwait(false);
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/RequestHelper.cs b/Emby.Server.Implementations/Services/RequestHelper.cs
deleted file mode 100644
index 1f9c7fc22..000000000
--- a/Emby.Server.Implementations/Services/RequestHelper.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using Emby.Server.Implementations.HttpServer;
-
-namespace Emby.Server.Implementations.Services
-{
- public class RequestHelper
- {
- public static Func> GetRequestReader(HttpListenerHost host, string contentType)
- {
- switch (GetContentTypeWithoutEncoding(contentType))
- {
- case "application/xml":
- case "text/xml":
- case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
- return host.DeserializeXml;
-
- case "application/json":
- case "text/json":
- return host.DeserializeJson;
- }
-
- return null;
- }
-
- public static Action GetResponseWriter(HttpListenerHost host, string contentType)
- {
- switch (GetContentTypeWithoutEncoding(contentType))
- {
- case "application/xml":
- case "text/xml":
- case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
- return host.SerializeToXml;
-
- case "application/json":
- case "text/json":
- return host.SerializeToJson;
- }
-
- return null;
- }
-
- private static string GetContentTypeWithoutEncoding(string contentType)
- {
- return contentType?.Split(';')[0].ToLowerInvariant().Trim();
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.cs
deleted file mode 100644
index a329b531d..000000000
--- a/Emby.Server.Implementations/Services/ResponseHelper.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Globalization;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Emby.Server.Implementations.HttpServer;
-using MediaBrowser.Model.Services;
-using Microsoft.AspNetCore.Http;
-
-namespace Emby.Server.Implementations.Services
-{
- public static class ResponseHelper
- {
- public static Task WriteToResponse(HttpResponse response, IRequest request, object result, CancellationToken cancellationToken)
- {
- if (result == null)
- {
- if (response.StatusCode == (int)HttpStatusCode.OK)
- {
- response.StatusCode = (int)HttpStatusCode.NoContent;
- }
-
- response.ContentLength = 0;
- return Task.CompletedTask;
- }
-
- var httpResult = result as IHttpResult;
- if (httpResult != null)
- {
- httpResult.RequestContext = request;
- request.ResponseContentType = httpResult.ContentType ?? request.ResponseContentType;
- }
-
- var defaultContentType = request.ResponseContentType;
-
- if (httpResult != null)
- {
- if (httpResult.RequestContext == null)
- {
- httpResult.RequestContext = request;
- }
-
- response.StatusCode = httpResult.Status;
- }
-
- if (result is IHasHeaders responseOptions)
- {
- foreach (var responseHeaders in responseOptions.Headers)
- {
- if (string.Equals(responseHeaders.Key, "Content-Length", StringComparison.OrdinalIgnoreCase))
- {
- response.ContentLength = long.Parse(responseHeaders.Value, CultureInfo.InvariantCulture);
- continue;
- }
-
- response.Headers.Add(responseHeaders.Key, responseHeaders.Value);
- }
- }
-
- // ContentType='text/html' is the default for a HttpResponse
- // Do not override if another has been set
- if (response.ContentType == null || response.ContentType == "text/html")
- {
- response.ContentType = defaultContentType;
- }
-
- if (response.ContentType == "application/json")
- {
- response.ContentType += "; charset=utf-8";
- }
-
- switch (result)
- {
- case IAsyncStreamWriter asyncStreamWriter:
- return asyncStreamWriter.WriteToAsync(response.Body, cancellationToken);
- case IStreamWriter streamWriter:
- streamWriter.WriteTo(response.Body);
- return Task.CompletedTask;
- case FileWriter fileWriter:
- return fileWriter.WriteToAsync(response, cancellationToken);
- case Stream stream:
- return CopyStream(stream, response.Body);
- case byte[] bytes:
- response.ContentType = "application/octet-stream";
- response.ContentLength = bytes.Length;
-
- if (bytes.Length > 0)
- {
- return response.Body.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
- }
-
- return Task.CompletedTask;
- case string responseText:
- var responseTextAsBytes = Encoding.UTF8.GetBytes(responseText);
- response.ContentLength = responseTextAsBytes.Length;
-
- if (responseTextAsBytes.Length > 0)
- {
- return response.Body.WriteAsync(responseTextAsBytes, 0, responseTextAsBytes.Length, cancellationToken);
- }
-
- return Task.CompletedTask;
- }
-
- return WriteObject(request, result, response);
- }
-
- private static async Task CopyStream(Stream src, Stream dest)
- {
- using (src)
- {
- await src.CopyToAsync(dest).ConfigureAwait(false);
- }
- }
-
- public static async Task WriteObject(IRequest request, object result, HttpResponse response)
- {
- var contentType = request.ResponseContentType;
- var serializer = RequestHelper.GetResponseWriter(HttpListenerHost.Instance, contentType);
-
- using (var ms = new MemoryStream())
- {
- serializer(result, ms);
-
- ms.Position = 0;
-
- var contentLength = ms.Length;
- response.ContentLength = contentLength;
-
- if (contentLength > 0)
- {
- await ms.CopyToAsync(response.Body).ConfigureAwait(false);
- }
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
deleted file mode 100644
index 47e7261e8..000000000
--- a/Emby.Server.Implementations/Services/ServiceController.cs
+++ /dev/null
@@ -1,202 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Threading.Tasks;
-using Emby.Server.Implementations.HttpServer;
-using MediaBrowser.Model.Services;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.Services
-{
- public delegate object ActionInvokerFn(object intance, object request);
-
- public delegate void VoidActionInvokerFn(object intance, object request);
-
- public class ServiceController
- {
- private readonly ILogger _logger;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The logger.
- public ServiceController(ILogger logger)
- {
- _logger = logger;
- }
-
- public void Init(HttpListenerHost appHost, IEnumerable serviceTypes)
- {
- foreach (var serviceType in serviceTypes)
- {
- RegisterService(appHost, serviceType);
- }
- }
-
- public void RegisterService(HttpListenerHost appHost, Type serviceType)
- {
- // Make sure the provided type implements IService
- if (!typeof(IService).IsAssignableFrom(serviceType))
- {
- _logger.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType);
- return;
- }
-
- var processedReqs = new HashSet();
-
- var actions = ServiceExecGeneral.Reset(serviceType);
-
- foreach (var mi in serviceType.GetActions())
- {
- var requestType = mi.GetParameters()[0].ParameterType;
- if (processedReqs.Contains(requestType))
- {
- continue;
- }
-
- processedReqs.Add(requestType);
-
- ServiceExecGeneral.CreateServiceRunnersFor(requestType, actions);
-
- // var returnMarker = GetTypeWithGenericTypeDefinitionOf(requestType, typeof(IReturn<>));
- // var responseType = returnMarker != null ?
- // GetGenericArguments(returnMarker)[0]
- // : mi.ReturnType != typeof(object) && mi.ReturnType != typeof(void) ?
- // mi.ReturnType
- // : Type.GetType(requestType.FullName + "Response");
-
- RegisterRestPaths(appHost, requestType, serviceType);
-
- appHost.AddServiceInfo(serviceType, requestType);
- }
- }
-
- public readonly RestPath.RestPathMap RestPathMap = new RestPath.RestPathMap();
-
- public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType)
- {
- var attrs = appHost.GetRouteAttributes(requestType);
- foreach (var attr in attrs)
- {
- var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, serviceType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description);
-
- RegisterRestPath(restPath);
- }
- }
-
- private static readonly char[] InvalidRouteChars = new[] { '?', '&' };
-
- public void RegisterRestPath(RestPath restPath)
- {
- if (restPath.Path[0] != '/')
- {
- throw new ArgumentException(
- string.Format(
- CultureInfo.InvariantCulture,
- "Route '{0}' on '{1}' must start with a '/'",
- restPath.Path,
- restPath.RequestType.GetMethodName()));
- }
-
- if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1)
- {
- throw new ArgumentException(
- string.Format(
- CultureInfo.InvariantCulture,
- "Route '{0}' on '{1}' contains invalid chars. ",
- restPath.Path,
- restPath.RequestType.GetMethodName()));
- }
-
- if (RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out List pathsAtFirstMatch))
- {
- pathsAtFirstMatch.Add(restPath);
- }
- else
- {
- RestPathMap[restPath.FirstMatchHashKey] = new List() { restPath };
- }
- }
-
- public RestPath GetRestPathForRequest(string httpMethod, string pathInfo)
- {
- var matchUsingPathParts = RestPath.GetPathPartsForMatching(pathInfo);
-
- List firstMatches;
-
- var yieldedHashMatches = RestPath.GetFirstMatchHashKeys(matchUsingPathParts);
- foreach (var potentialHashMatch in yieldedHashMatches)
- {
- if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
- {
- continue;
- }
-
- var bestScore = -1;
- RestPath bestMatch = null;
- foreach (var restPath in firstMatches)
- {
- var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
- if (score > bestScore)
- {
- bestScore = score;
- bestMatch = restPath;
- }
- }
-
- if (bestScore > 0 && bestMatch != null)
- {
- return bestMatch;
- }
- }
-
- var yieldedWildcardMatches = RestPath.GetFirstMatchWildCardHashKeys(matchUsingPathParts);
- foreach (var potentialHashMatch in yieldedWildcardMatches)
- {
- if (!this.RestPathMap.TryGetValue(potentialHashMatch, out firstMatches))
- {
- continue;
- }
-
- var bestScore = -1;
- RestPath bestMatch = null;
- foreach (var restPath in firstMatches)
- {
- var score = restPath.MatchScore(httpMethod, matchUsingPathParts);
- if (score > bestScore)
- {
- bestScore = score;
- bestMatch = restPath;
- }
- }
-
- if (bestScore > 0 && bestMatch != null)
- {
- return bestMatch;
- }
- }
-
- return null;
- }
-
- public Task Execute(HttpListenerHost httpHost, object requestDto, IRequest req)
- {
- var requestType = requestDto.GetType();
- req.OperationName = requestType.Name;
-
- var serviceType = httpHost.GetServiceTypeByRequest(requestType);
-
- var service = httpHost.CreateInstance(serviceType);
-
- if (service is IRequiresRequest serviceRequiresContext)
- {
- serviceRequiresContext.Request = req;
- }
-
- // Executes the service and returns the result
- return ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName());
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs
deleted file mode 100644
index 7b970627e..000000000
--- a/Emby.Server.Implementations/Services/ServiceExec.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Services;
-
-namespace Emby.Server.Implementations.Services
-{
- public static class ServiceExecExtensions
- {
- public static string[] AllVerbs = new[] {
- "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "CONNECT", // RFC 2616
- "PROPFIND", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK", // RFC 2518
- "VERSION-CONTROL", "REPORT", "CHECKOUT", "CHECKIN", "UNCHECKOUT",
- "MKWORKSPACE", "UPDATE", "LABEL", "MERGE", "BASELINE-CONTROL", "MKACTIVITY", // RFC 3253
- "ORDERPATCH", // RFC 3648
- "ACL", // RFC 3744
- "PATCH", // https://datatracker.ietf.org/doc/draft-dusseault-http-patch/
- "SEARCH", // https://datatracker.ietf.org/doc/draft-reschke-webdav-search/
- "BCOPY", "BDELETE", "BMOVE", "BPROPFIND", "BPROPPATCH", "NOTIFY",
- "POLL", "SUBSCRIBE", "UNSUBSCRIBE"
- };
-
- public static List GetActions(this Type serviceType)
- {
- var list = new List();
-
- foreach (var mi in serviceType.GetRuntimeMethods())
- {
- if (!mi.IsPublic)
- {
- continue;
- }
-
- if (mi.IsStatic)
- {
- continue;
- }
-
- if (mi.GetParameters().Length != 1)
- {
- continue;
- }
-
- var actionName = mi.Name;
- if (!AllVerbs.Contains(actionName, StringComparer.OrdinalIgnoreCase))
- {
- continue;
- }
-
- list.Add(mi);
- }
-
- return list;
- }
- }
-
- internal static class ServiceExecGeneral
- {
- private static Dictionary execMap = new Dictionary();
-
- public static void CreateServiceRunnersFor(Type requestType, List actions)
- {
- foreach (var actionCtx in actions)
- {
- if (execMap.ContainsKey(actionCtx.Id))
- {
- continue;
- }
-
- execMap[actionCtx.Id] = actionCtx;
- }
- }
-
- public static Task Execute(Type serviceType, IRequest request, object instance, object requestDto, string requestName)
- {
- var actionName = request.Verb ?? "POST";
-
- if (execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out ServiceMethod actionContext))
- {
- if (actionContext.RequestFilters != null)
- {
- foreach (var requestFilter in actionContext.RequestFilters)
- {
- requestFilter.RequestFilter(request, request.Response, requestDto);
- if (request.Response.HasStarted)
- {
- Task.FromResult(null);
- }
- }
- }
-
- var response = actionContext.ServiceAction(instance, requestDto);
-
- if (response is Task taskResponse)
- {
- return GetTaskResult(taskResponse);
- }
-
- return Task.FromResult(response);
- }
-
- var expectedMethodName = actionName.Substring(0, 1) + actionName.Substring(1).ToLowerInvariant();
- throw new NotImplementedException(
- string.Format(
- CultureInfo.InvariantCulture,
- "Could not find method named {1}({0}) or Any({0}) on Service {2}",
- requestDto.GetType().GetMethodName(),
- expectedMethodName,
- serviceType.GetMethodName()));
- }
-
- private static async Task GetTaskResult(Task task)
- {
- try
- {
- if (task is Task taskObject)
- {
- return await taskObject.ConfigureAwait(false);
- }
-
- await task.ConfigureAwait(false);
-
- var type = task.GetType().GetTypeInfo();
- if (!type.IsGenericType)
- {
- return null;
- }
-
- var resultProperty = type.GetDeclaredProperty("Result");
- if (resultProperty == null)
- {
- return null;
- }
-
- var result = resultProperty.GetValue(task);
-
- // hack alert
- if (result.GetType().Name.IndexOf("voidtaskresult", StringComparison.OrdinalIgnoreCase) != -1)
- {
- return null;
- }
-
- return result;
- }
- catch (TypeAccessException)
- {
- return null; // return null for void Task's
- }
- }
-
- public static List Reset(Type serviceType)
- {
- var actions = new List();
-
- foreach (var mi in serviceType.GetActions())
- {
- var actionName = mi.Name;
- var args = mi.GetParameters();
-
- var requestType = args[0].ParameterType;
- var actionCtx = new ServiceMethod
- {
- Id = ServiceMethod.Key(serviceType, actionName, requestType.GetMethodName())
- };
-
- actionCtx.ServiceAction = CreateExecFn(serviceType, requestType, mi);
-
- var reqFilters = new List();
-
- foreach (var attr in mi.GetCustomAttributes(true))
- {
- if (attr is IHasRequestFilter hasReqFilter)
- {
- reqFilters.Add(hasReqFilter);
- }
- }
-
- if (reqFilters.Count > 0)
- {
- actionCtx.RequestFilters = reqFilters.OrderBy(i => i.Priority).ToArray();
- }
-
- actions.Add(actionCtx);
- }
-
- return actions;
- }
-
- private static ActionInvokerFn CreateExecFn(Type serviceType, Type requestType, MethodInfo mi)
- {
- var serviceParam = Expression.Parameter(typeof(object), "serviceObj");
- var serviceStrong = Expression.Convert(serviceParam, serviceType);
-
- var requestDtoParam = Expression.Parameter(typeof(object), "requestDto");
- var requestDtoStrong = Expression.Convert(requestDtoParam, requestType);
-
- Expression callExecute = Expression.Call(
- serviceStrong, mi, requestDtoStrong);
-
- if (mi.ReturnType != typeof(void))
- {
- var executeFunc = Expression.Lambda(
- callExecute,
- serviceParam,
- requestDtoParam).Compile();
-
- return executeFunc;
- }
- else
- {
- var executeFunc = Expression.Lambda(
- callExecute,
- serviceParam,
- requestDtoParam).Compile();
-
- return (service, request) =>
- {
- executeFunc(service, request);
- return null;
- };
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs
deleted file mode 100644
index b4166f771..000000000
--- a/Emby.Server.Implementations/Services/ServiceHandler.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Net.Mime;
-using System.Reflection;
-using System.Threading;
-using System.Threading.Tasks;
-using Emby.Server.Implementations.HttpServer;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Model.Services;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.Services
-{
- public class ServiceHandler
- {
- private RestPath _restPath;
-
- private string _responseContentType;
-
- internal ServiceHandler(RestPath restPath, string responseContentType)
- {
- _restPath = restPath;
- _responseContentType = responseContentType;
- }
-
- protected static Task CreateContentTypeRequest(HttpListenerHost host, IRequest httpReq, Type requestType, string contentType)
- {
- if (!string.IsNullOrEmpty(contentType) && httpReq.ContentLength > 0)
- {
- var deserializer = RequestHelper.GetRequestReader(host, contentType);
- if (deserializer != null)
- {
- return deserializer.Invoke(requestType, httpReq.InputStream);
- }
- }
-
- return Task.FromResult(host.CreateInstance(requestType));
- }
-
- public static string GetSanitizedPathInfo(string pathInfo, out string contentType)
- {
- contentType = null;
- var pos = pathInfo.LastIndexOf('.');
- if (pos != -1)
- {
- var format = pathInfo.AsSpan().Slice(pos + 1);
- contentType = GetFormatContentType(format);
- if (contentType != null)
- {
- pathInfo = pathInfo.Substring(0, pos);
- }
- }
-
- return pathInfo;
- }
-
- private static string GetFormatContentType(ReadOnlySpan format)
- {
- if (format.Equals("json", StringComparison.Ordinal))
- {
- return MediaTypeNames.Application.Json;
- }
- else if (format.Equals("xml", StringComparison.Ordinal))
- {
- return MediaTypeNames.Application.Xml;
- }
-
- return null;
- }
-
- public async Task ProcessRequestAsync(HttpListenerHost httpHost, IRequest httpReq, HttpResponse httpRes, CancellationToken cancellationToken)
- {
- httpReq.Items["__route"] = _restPath;
-
- if (_responseContentType != null)
- {
- httpReq.ResponseContentType = _responseContentType;
- }
-
- var request = await CreateRequest(httpHost, httpReq, _restPath).ConfigureAwait(false);
-
- httpHost.ApplyRequestFilters(httpReq, httpRes, request);
-
- httpRes.HttpContext.SetServiceStackRequest(httpReq);
- var response = await httpHost.ServiceController.Execute(httpHost, request, httpReq).ConfigureAwait(false);
-
- // Apply response filters
- foreach (var responseFilter in httpHost.ResponseFilters)
- {
- responseFilter(httpReq, httpRes, response);
- }
-
- await ResponseHelper.WriteToResponse(httpRes, httpReq, response, cancellationToken).ConfigureAwait(false);
- }
-
- public static async Task CreateRequest(HttpListenerHost host, IRequest httpReq, RestPath restPath)
- {
- var requestType = restPath.RequestType;
-
- if (RequireqRequestStream(requestType))
- {
- // Used by IRequiresRequestStream
- var requestParams = GetRequestParams(httpReq.Response.HttpContext.Request);
- var request = ServiceHandler.CreateRequest(httpReq, restPath, requestParams, host.CreateInstance(requestType));
-
- var rawReq = (IRequiresRequestStream)request;
- rawReq.RequestStream = httpReq.InputStream;
- return rawReq;
- }
- else
- {
- var requestParams = GetFlattenedRequestParams(httpReq.Response.HttpContext.Request);
-
- var requestDto = await CreateContentTypeRequest(host, httpReq, restPath.RequestType, httpReq.ContentType).ConfigureAwait(false);
-
- return CreateRequest(httpReq, restPath, requestParams, requestDto);
- }
- }
-
- public static bool RequireqRequestStream(Type requestType)
- {
- var requiresRequestStreamTypeInfo = typeof(IRequiresRequestStream).GetTypeInfo();
-
- return requiresRequestStreamTypeInfo.IsAssignableFrom(requestType.GetTypeInfo());
- }
-
- public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary requestParams, object requestDto)
- {
- var pathInfo = !restPath.IsWildCardPath
- ? GetSanitizedPathInfo(httpReq.PathInfo, out _)
- : httpReq.PathInfo;
-
- return restPath.CreateRequest(pathInfo, requestParams, requestDto);
- }
-
- ///
- /// Duplicate Params are given a unique key by appending a #1 suffix
- ///
- private static Dictionary GetRequestParams(HttpRequest request)
- {
- var map = new Dictionary();
-
- foreach (var pair in request.Query)
- {
- var values = pair.Value;
- if (values.Count == 1)
- {
- map[pair.Key] = values[0];
- }
- else
- {
- for (var i = 0; i < values.Count; i++)
- {
- map[pair.Key + (i == 0 ? string.Empty : "#" + i)] = values[i];
- }
- }
- }
-
- if ((IsMethod(request.Method, "POST") || IsMethod(request.Method, "PUT"))
- && request.HasFormContentType)
- {
- foreach (var pair in request.Form)
- {
- var values = pair.Value;
- if (values.Count == 1)
- {
- map[pair.Key] = values[0];
- }
- else
- {
- for (var i = 0; i < values.Count; i++)
- {
- map[pair.Key + (i == 0 ? string.Empty : "#" + i)] = values[i];
- }
- }
- }
- }
-
- return map;
- }
-
- private static bool IsMethod(string method, string expected)
- => string.Equals(method, expected, StringComparison.OrdinalIgnoreCase);
-
- ///
- /// Duplicate params have their values joined together in a comma-delimited string.
- ///
- private static Dictionary GetFlattenedRequestParams(HttpRequest request)
- {
- var map = new Dictionary();
-
- foreach (var pair in request.Query)
- {
- map[pair.Key] = pair.Value;
- }
-
- if ((IsMethod(request.Method, "POST") || IsMethod(request.Method, "PUT"))
- && request.HasFormContentType)
- {
- foreach (var pair in request.Form)
- {
- map[pair.Key] = pair.Value;
- }
- }
-
- return map;
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ServiceMethod.cs b/Emby.Server.Implementations/Services/ServiceMethod.cs
deleted file mode 100644
index 5116cc04f..000000000
--- a/Emby.Server.Implementations/Services/ServiceMethod.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-
-namespace Emby.Server.Implementations.Services
-{
- public class ServiceMethod
- {
- public string Id { get; set; }
-
- public ActionInvokerFn ServiceAction { get; set; }
-
- public MediaBrowser.Model.Services.IHasRequestFilter[] RequestFilters { get; set; }
-
- public static string Key(Type serviceType, string method, string requestDtoName)
- {
- return serviceType.FullName + " " + method.ToUpperInvariant() + " " + requestDtoName;
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs
deleted file mode 100644
index 0d4728b43..000000000
--- a/Emby.Server.Implementations/Services/ServicePath.cs
+++ /dev/null
@@ -1,550 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Text.Json.Serialization;
-
-namespace Emby.Server.Implementations.Services
-{
- public class RestPath
- {
- private const string WildCard = "*";
- private const char WildCardChar = '*';
- private const string PathSeperator = "/";
- private const char PathSeperatorChar = '/';
- private const char ComponentSeperator = '.';
- private const string VariablePrefix = "{";
-
- private readonly bool[] componentsWithSeparators;
-
- private readonly string restPath;
- public bool IsWildCardPath { get; private set; }
-
- private readonly string[] literalsToMatch;
-
- private readonly string[] variablesNames;
-
- private readonly bool[] isWildcard;
- private readonly int wildcardCount = 0;
-
- internal static string[] IgnoreAttributesNamed = new[]
- {
- nameof(JsonIgnoreAttribute)
- };
-
- private static Type _excludeType = typeof(Stream);
-
- public int VariableArgsCount { get; set; }
-
- ///
- /// The number of segments separated by '/' determinable by path.Split('/').Length
- /// e.g. /path/to/here.ext == 3
- ///
- public int PathComponentsCount { get; set; }
-
- ///
- /// Gets or sets the total number of segments after subparts have been exploded ('.')
- /// e.g. /path/to/here.ext == 4.
- ///
- public int TotalComponentsCount { get; set; }
-
- public string[] Verbs { get; private set; }
-
- public Type RequestType { get; private set; }
-
- public Type ServiceType { get; private set; }
-
- public string Path => this.restPath;
-
- public string Summary { get; private set; }
-
- public string Description { get; private set; }
-
- public bool IsHidden { get; private set; }
-
- public static string[] GetPathPartsForMatching(string pathInfo)
- {
- return pathInfo.ToLowerInvariant().Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries);
- }
-
- public static List GetFirstMatchHashKeys(string[] pathPartsForMatching)
- {
- var hashPrefix = pathPartsForMatching.Length + PathSeperator;
- return GetPotentialMatchesWithPrefix(hashPrefix, pathPartsForMatching);
- }
-
- public static List GetFirstMatchWildCardHashKeys(string[] pathPartsForMatching)
- {
- const string HashPrefix = WildCard + PathSeperator;
- return GetPotentialMatchesWithPrefix(HashPrefix, pathPartsForMatching);
- }
-
- private static List GetPotentialMatchesWithPrefix(string hashPrefix, string[] pathPartsForMatching)
- {
- var list = new List();
-
- foreach (var part in pathPartsForMatching)
- {
- list.Add(hashPrefix + part);
-
- if (part.IndexOf(ComponentSeperator, StringComparison.Ordinal) == -1)
- {
- continue;
- }
-
- var subParts = part.Split(ComponentSeperator);
- foreach (var subPart in subParts)
- {
- list.Add(hashPrefix + subPart);
- }
- }
-
- return list;
- }
-
- public RestPath(Func createInstanceFn, Func> getParseFn, Type requestType, Type serviceType, string path, string verbs, bool isHidden = false, string summary = null, string description = null)
- {
- this.RequestType = requestType;
- this.ServiceType = serviceType;
- this.Summary = summary;
- this.IsHidden = isHidden;
- this.Description = description;
- this.restPath = path;
-
- this.Verbs = string.IsNullOrWhiteSpace(verbs) ? ServiceExecExtensions.AllVerbs : verbs.ToUpperInvariant().Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
-
- var componentsList = new List();
-
- // We only split on '.' if the restPath has them. Allows for /{action}.{type}
- var hasSeparators = new List();
- foreach (var component in this.restPath.Split(PathSeperatorChar))
- {
- if (string.IsNullOrEmpty(component))
- {
- continue;
- }
-
- if (component.IndexOf(VariablePrefix, StringComparison.OrdinalIgnoreCase) != -1
- && component.IndexOf(ComponentSeperator, StringComparison.Ordinal) != -1)
- {
- hasSeparators.Add(true);
- componentsList.AddRange(component.Split(ComponentSeperator));
- }
- else
- {
- hasSeparators.Add(false);
- componentsList.Add(component);
- }
- }
-
- var components = componentsList.ToArray();
- this.TotalComponentsCount = components.Length;
-
- this.literalsToMatch = new string[this.TotalComponentsCount];
- this.variablesNames = new string[this.TotalComponentsCount];
- this.isWildcard = new bool[this.TotalComponentsCount];
- this.componentsWithSeparators = hasSeparators.ToArray();
- this.PathComponentsCount = this.componentsWithSeparators.Length;
- string firstLiteralMatch = null;
-
- for (var i = 0; i < components.Length; i++)
- {
- var component = components[i];
-
- if (component.StartsWith(VariablePrefix, StringComparison.Ordinal))
- {
- var variableName = component.Substring(1, component.Length - 2);
- if (variableName[variableName.Length - 1] == WildCardChar)
- {
- this.isWildcard[i] = true;
- variableName = variableName.Substring(0, variableName.Length - 1);
- }
-
- this.variablesNames[i] = variableName;
- this.VariableArgsCount++;
- }
- else
- {
- this.literalsToMatch[i] = component.ToLowerInvariant();
-
- if (firstLiteralMatch == null)
- {
- firstLiteralMatch = this.literalsToMatch[i];
- }
- }
- }
-
- for (var i = 0; i < components.Length - 1; i++)
- {
- if (!this.isWildcard[i])
- {
- continue;
- }
-
- if (this.literalsToMatch[i + 1] == null)
- {
- throw new ArgumentException(
- "A wildcard path component must be at the end of the path or followed by a literal path component.");
- }
- }
-
- this.wildcardCount = this.isWildcard.Length;
- this.IsWildCardPath = this.wildcardCount > 0;
-
- this.FirstMatchHashKey = !this.IsWildCardPath
- ? this.PathComponentsCount + PathSeperator + firstLiteralMatch
- : WildCardChar + PathSeperator + firstLiteralMatch;
-
- this.typeDeserializer = new StringMapTypeDeserializer(createInstanceFn, getParseFn, this.RequestType);
-
- _propertyNamesMap = new HashSet(
- GetSerializableProperties(RequestType).Select(x => x.Name),
- StringComparer.OrdinalIgnoreCase);
- }
-
- internal static IEnumerable GetSerializableProperties(Type type)
- {
- foreach (var prop in GetPublicProperties(type))
- {
- if (prop.GetMethod == null
- || _excludeType == prop.PropertyType)
- {
- continue;
- }
-
- var ignored = false;
- foreach (var attr in prop.GetCustomAttributes(true))
- {
- if (IgnoreAttributesNamed.Contains(attr.GetType().Name))
- {
- ignored = true;
- break;
- }
- }
-
- if (!ignored)
- {
- yield return prop;
- }
- }
- }
-
- private static IEnumerable GetPublicProperties(Type type)
- {
- if (type.IsInterface)
- {
- var propertyInfos = new List();
- var considered = new List()
- {
- type
- };
- var queue = new Queue();
- queue.Enqueue(type);
-
- while (queue.Count > 0)
- {
- var subType = queue.Dequeue();
- foreach (var subInterface in subType.GetTypeInfo().ImplementedInterfaces)
- {
- if (considered.Contains(subInterface))
- {
- continue;
- }
-
- considered.Add(subInterface);
- queue.Enqueue(subInterface);
- }
-
- var newPropertyInfos = GetTypesPublicProperties(subType)
- .Where(x => !propertyInfos.Contains(x));
-
- propertyInfos.InsertRange(0, newPropertyInfos);
- }
-
- return propertyInfos;
- }
-
- return GetTypesPublicProperties(type)
- .Where(x => x.GetIndexParameters().Length == 0);
- }
-
- private static IEnumerable GetTypesPublicProperties(Type subType)
- {
- foreach (var pi in subType.GetRuntimeProperties())
- {
- var mi = pi.GetMethod ?? pi.SetMethod;
- if (mi != null && mi.IsStatic)
- {
- continue;
- }
-
- yield return pi;
- }
- }
-
- ///
- /// Provide for quick lookups based on hashes that can be determined from a request url.
- ///
- public string FirstMatchHashKey { get; private set; }
-
- private readonly StringMapTypeDeserializer typeDeserializer;
-
- private readonly HashSet _propertyNamesMap;
-
- public int MatchScore(string httpMethod, string[] withPathInfoParts)
- {
- var isMatch = IsMatch(httpMethod, withPathInfoParts, out var wildcardMatchCount);
- if (!isMatch)
- {
- return -1;
- }
-
- // Routes with least wildcard matches get the highest score
- var score = Math.Max(100 - wildcardMatchCount, 1) * 1000
- // Routes with less variable (and more literal) matches
- + Math.Max(10 - VariableArgsCount, 1) * 100;
-
- // Exact verb match is better than ANY
- if (Verbs.Length == 1 && string.Equals(httpMethod, Verbs[0], StringComparison.OrdinalIgnoreCase))
- {
- score += 10;
- }
- else
- {
- score += 1;
- }
-
- return score;
- }
-
- ///
- /// For performance withPathInfoParts should already be a lower case string
- /// to minimize redundant matching operations.
- ///
- public bool IsMatch(string httpMethod, string[] withPathInfoParts, out int wildcardMatchCount)
- {
- wildcardMatchCount = 0;
-
- if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath)
- {
- return false;
- }
-
- if (!Verbs.Contains(httpMethod, StringComparer.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (!ExplodeComponents(ref withPathInfoParts))
- {
- return false;
- }
-
- if (this.TotalComponentsCount != withPathInfoParts.Length && !this.IsWildCardPath)
- {
- return false;
- }
-
- int pathIx = 0;
- for (var i = 0; i < this.TotalComponentsCount; i++)
- {
- if (this.isWildcard[i])
- {
- if (i < this.TotalComponentsCount - 1)
- {
- // Continue to consume up until a match with the next literal
- while (pathIx < withPathInfoParts.Length
- && !string.Equals(withPathInfoParts[pathIx], this.literalsToMatch[i + 1], StringComparison.InvariantCultureIgnoreCase))
- {
- pathIx++;
- wildcardMatchCount++;
- }
-
- // Ensure there are still enough parts left to match the remainder
- if ((withPathInfoParts.Length - pathIx) < (this.TotalComponentsCount - i - 1))
- {
- return false;
- }
- }
- else
- {
- // A wildcard at the end matches the remainder of path
- wildcardMatchCount += withPathInfoParts.Length - pathIx;
- pathIx = withPathInfoParts.Length;
- }
- }
- else
- {
- var literalToMatch = this.literalsToMatch[i];
- if (literalToMatch == null)
- {
- // Matching an ordinary (non-wildcard) variable consumes a single part
- pathIx++;
- continue;
- }
-
- if (withPathInfoParts.Length <= pathIx
- || !string.Equals(withPathInfoParts[pathIx], literalToMatch, StringComparison.InvariantCultureIgnoreCase))
- {
- return false;
- }
-
- pathIx++;
- }
- }
-
- return pathIx == withPathInfoParts.Length;
- }
-
- private bool ExplodeComponents(ref string[] withPathInfoParts)
- {
- var totalComponents = new List();
- for (var i = 0; i < withPathInfoParts.Length; i++)
- {
- var component = withPathInfoParts[i];
- if (string.IsNullOrEmpty(component))
- {
- continue;
- }
-
- if (this.PathComponentsCount != this.TotalComponentsCount
- && this.componentsWithSeparators[i])
- {
- var subComponents = component.Split(ComponentSeperator);
- if (subComponents.Length < 2)
- {
- return false;
- }
-
- totalComponents.AddRange(subComponents);
- }
- else
- {
- totalComponents.Add(component);
- }
- }
-
- withPathInfoParts = totalComponents.ToArray();
- return true;
- }
-
- public object CreateRequest(string pathInfo, Dictionary queryStringAndFormData, object fromInstance)
- {
- var requestComponents = pathInfo.Split(new[] { PathSeperatorChar }, StringSplitOptions.RemoveEmptyEntries);
-
- ExplodeComponents(ref requestComponents);
-
- if (requestComponents.Length != this.TotalComponentsCount)
- {
- var isValidWildCardPath = this.IsWildCardPath
- && requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
-
- if (!isValidWildCardPath)
- {
- throw new ArgumentException(
- string.Format(
- CultureInfo.InvariantCulture,
- "Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
- pathInfo,
- this.restPath));
- }
- }
-
- var requestKeyValuesMap = new Dictionary();
- var pathIx = 0;
- for (var i = 0; i < this.TotalComponentsCount; i++)
- {
- var variableName = this.variablesNames[i];
- if (variableName == null)
- {
- pathIx++;
- continue;
- }
-
- if (!this._propertyNamesMap.Contains(variableName))
- {
- if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
- {
- pathIx++;
- continue;
- }
-
- throw new ArgumentException("Could not find property "
- + variableName + " on " + RequestType.GetMethodName());
- }
-
- var value = requestComponents.Length > pathIx ? requestComponents[pathIx] : null; // wildcard has arg mismatch
- if (value != null && this.isWildcard[i])
- {
- if (i == this.TotalComponentsCount - 1)
- {
- // Wildcard at end of path definition consumes all the rest
- var sb = new StringBuilder();
- sb.Append(value);
- for (var j = pathIx + 1; j < requestComponents.Length; j++)
- {
- sb.Append(PathSeperatorChar)
- .Append(requestComponents[j]);
- }
-
- value = sb.ToString();
- }
- else
- {
- // Wildcard in middle of path definition consumes up until it
- // hits a match for the next element in the definition (which must be a literal)
- // It may consume 0 or more path parts
- var stopLiteral = i == this.TotalComponentsCount - 1 ? null : this.literalsToMatch[i + 1];
- if (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
- {
- var sb = new StringBuilder(value);
- pathIx++;
- while (!string.Equals(requestComponents[pathIx], stopLiteral, StringComparison.OrdinalIgnoreCase))
- {
- sb.Append(PathSeperatorChar)
- .Append(requestComponents[pathIx++]);
- }
-
- value = sb.ToString();
- }
- else
- {
- value = null;
- }
- }
- }
- else
- {
- // Variable consumes single path item
- pathIx++;
- }
-
- requestKeyValuesMap[variableName] = value;
- }
-
- if (queryStringAndFormData != null)
- {
- // Query String and form data can override variable path matches
- // path variables < query string < form data
- foreach (var name in queryStringAndFormData)
- {
- requestKeyValuesMap[name.Key] = name.Value;
- }
- }
-
- return this.typeDeserializer.PopulateFromMap(fromInstance, requestKeyValuesMap);
- }
-
- public class RestPathMap : SortedDictionary>
- {
- public RestPathMap() : base(StringComparer.OrdinalIgnoreCase)
- {
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
deleted file mode 100644
index 165bb0fc4..000000000
--- a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using MediaBrowser.Common.Extensions;
-
-namespace Emby.Server.Implementations.Services
-{
- ///
- /// Serializer cache of delegates required to create a type from a string map (e.g. for REST urls)
- ///
- public class StringMapTypeDeserializer
- {
- internal class PropertySerializerEntry
- {
- public PropertySerializerEntry(Action propertySetFn, Func propertyParseStringFn, Type propertyType)
- {
- PropertySetFn = propertySetFn;
- PropertyParseStringFn = propertyParseStringFn;
- PropertyType = propertyType;
- }
-
- public Action PropertySetFn { get; private set; }
-
- public Func PropertyParseStringFn { get; private set; }
-
- public Type PropertyType { get; private set; }
- }
-
- private readonly Type type;
- private readonly Dictionary propertySetterMap
- = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- public Func GetParseFn(Type propertyType)
- {
- if (propertyType == typeof(string))
- {
- return s => s;
- }
-
- return _GetParseFn(propertyType);
- }
-
- private readonly Func _CreateInstanceFn;
- private readonly Func> _GetParseFn;
-
- public StringMapTypeDeserializer(Func createInstanceFn, Func> getParseFn, Type type)
- {
- _CreateInstanceFn = createInstanceFn;
- _GetParseFn = getParseFn;
- this.type = type;
-
- foreach (var propertyInfo in RestPath.GetSerializableProperties(type))
- {
- var propertySetFn = TypeAccessor.GetSetPropertyMethod(propertyInfo);
- var propertyType = propertyInfo.PropertyType;
- var propertyParseStringFn = GetParseFn(propertyType);
- var propertySerializer = new PropertySerializerEntry(propertySetFn, propertyParseStringFn, propertyType);
-
- propertySetterMap[propertyInfo.Name] = propertySerializer;
- }
- }
-
- public object PopulateFromMap(object instance, IDictionary keyValuePairs)
- {
- PropertySerializerEntry propertySerializerEntry = null;
-
- if (instance == null)
- {
- instance = _CreateInstanceFn(type);
- }
-
- foreach (var pair in keyValuePairs)
- {
- string propertyName = pair.Key;
- string propertyTextValue = pair.Value;
-
- if (propertyTextValue == null
- || !propertySetterMap.TryGetValue(propertyName, out propertySerializerEntry)
- || propertySerializerEntry.PropertySetFn == null)
- {
- continue;
- }
-
- if (propertySerializerEntry.PropertyType == typeof(bool))
- {
- // InputExtensions.cs#530 MVC Checkbox helper emits extra hidden input field, generating 2 values, first is the real value
- propertyTextValue = StringExtensions.LeftPart(propertyTextValue, ',').ToString();
- }
-
- var value = propertySerializerEntry.PropertyParseStringFn(propertyTextValue);
- if (value == null)
- {
- continue;
- }
-
- propertySerializerEntry.PropertySetFn(instance, value);
- }
-
- return instance;
- }
- }
-
- internal static class TypeAccessor
- {
- public static Action GetSetPropertyMethod(PropertyInfo propertyInfo)
- {
- if (!propertyInfo.CanWrite || propertyInfo.GetIndexParameters().Length > 0)
- {
- return null;
- }
-
- var setMethodInfo = propertyInfo.SetMethod;
- return (instance, value) => setMethodInfo.Invoke(instance, new[] { value });
- }
- }
-}
diff --git a/Emby.Server.Implementations/Services/UrlExtensions.cs b/Emby.Server.Implementations/Services/UrlExtensions.cs
deleted file mode 100644
index 92e36b60e..000000000
--- a/Emby.Server.Implementations/Services/UrlExtensions.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using MediaBrowser.Common.Extensions;
-
-namespace Emby.Server.Implementations.Services
-{
- ///
- /// Donated by Ivan Korneliuk from his post:
- /// http://korneliuk.blogspot.com/2012/08/servicestack-reusing-dtos.html
- ///
- /// Modified to only allow using routes matching the supplied HTTP Verb.
- ///
- public static class UrlExtensions
- {
- public static string GetMethodName(this Type type)
- {
- var typeName = type.FullName != null // can be null, e.g. generic types
- ? StringExtensions.LeftPart(type.FullName, "[[", StringComparison.Ordinal).ToString() // Generic Fullname
- .Replace(type.Namespace + ".", string.Empty, StringComparison.Ordinal) // Trim Namespaces
- .Replace("+", ".", StringComparison.Ordinal) // Convert nested into normal type
- : type.Name;
-
- return type.IsGenericParameter ? "'" + typeName : typeName;
- }
- }
-}
diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
deleted file mode 100644
index ae1a8d0b7..000000000
--- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
+++ /dev/null
@@ -1,248 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Net.Mime;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Net;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Http.Extensions;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Primitives;
-using Microsoft.Net.Http.Headers;
-using IHttpRequest = MediaBrowser.Model.Services.IHttpRequest;
-
-namespace Emby.Server.Implementations.SocketSharp
-{
- public class WebSocketSharpRequest : IHttpRequest
- {
- private const string FormUrlEncoded = "application/x-www-form-urlencoded";
- private const string MultiPartFormData = "multipart/form-data";
- private const string Soap11 = "text/xml; charset=utf-8";
-
- private string _remoteIp;
- private Dictionary _items;
- private string _responseContentType;
-
- public WebSocketSharpRequest(HttpRequest httpRequest, HttpResponse httpResponse, string operationName)
- {
- this.OperationName = operationName;
- this.Request = httpRequest;
- this.Response = httpResponse;
- }
-
- public string Accept => StringValues.IsNullOrEmpty(Request.Headers[HeaderNames.Accept]) ? null : Request.Headers[HeaderNames.Accept].ToString();
-
- public string Authorization => StringValues.IsNullOrEmpty(Request.Headers[HeaderNames.Authorization]) ? null : Request.Headers[HeaderNames.Authorization].ToString();
-
- public HttpRequest Request { get; }
-
- public HttpResponse Response { get; }
-
- public string OperationName { get; set; }
-
- public string RawUrl => Request.GetEncodedPathAndQuery();
-
- public string AbsoluteUri => Request.GetDisplayUrl().TrimEnd('/');
-
- public string RemoteIp
- {
- get
- {
- if (_remoteIp != null)
- {
- return _remoteIp;
- }
-
- IPAddress ip;
-
- // "Real" remote ip might be in X-Forwarded-For of X-Real-Ip
- // (if the server is behind a reverse proxy for example)
- if (!IPAddress.TryParse(GetHeader(CustomHeaderNames.XForwardedFor), out ip))
- {
- if (!IPAddress.TryParse(GetHeader(CustomHeaderNames.XRealIP), out ip))
- {
- ip = Request.HttpContext.Connection.RemoteIpAddress;
-
- // Default to the loopback address if no RemoteIpAddress is specified (i.e. during integration tests)
- ip ??= IPAddress.Loopback;
- }
- }
-
- return _remoteIp = NormalizeIp(ip).ToString();
- }
- }
-
- public string[] AcceptTypes => Request.Headers.GetCommaSeparatedValues(HeaderNames.Accept);
-
- public Dictionary Items => _items ?? (_items = new Dictionary());
-
- public string ResponseContentType
- {
- get =>
- _responseContentType
- ?? (_responseContentType = GetResponseContentType(Request));
- set => _responseContentType = value;
- }
-
- public string PathInfo => Request.Path.Value;
-
- public string UserAgent => Request.Headers[HeaderNames.UserAgent];
-
- public IHeaderDictionary Headers => Request.Headers;
-
- public IQueryCollection QueryString => Request.Query;
-
- public bool IsLocal =>
- (Request.HttpContext.Connection.LocalIpAddress == null
- && Request.HttpContext.Connection.RemoteIpAddress == null)
- || Request.HttpContext.Connection.LocalIpAddress.Equals(Request.HttpContext.Connection.RemoteIpAddress);
-
- public string HttpMethod => Request.Method;
-
- public string Verb => HttpMethod;
-
- public string ContentType => Request.ContentType;
-
- public Uri UrlReferrer => Request.GetTypedHeaders().Referer;
-
- public Stream InputStream => Request.Body;
-
- public long ContentLength => Request.ContentLength ?? 0;
-
- private string GetHeader(string name) => Request.Headers[name].ToString();
-
- private static IPAddress NormalizeIp(IPAddress ip)
- {
- if (ip.IsIPv4MappedToIPv6)
- {
- return ip.MapToIPv4();
- }
-
- return ip;
- }
-
- public static string GetResponseContentType(HttpRequest httpReq)
- {
- var specifiedContentType = GetQueryStringContentType(httpReq);
- if (!string.IsNullOrEmpty(specifiedContentType))
- {
- return specifiedContentType;
- }
-
- const string ServerDefaultContentType = MediaTypeNames.Application.Json;
-
- var acceptContentTypes = httpReq.Headers.GetCommaSeparatedValues(HeaderNames.Accept);
- string defaultContentType = null;
- if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData))
- {
- defaultContentType = ServerDefaultContentType;
- }
-
- var acceptsAnything = false;
- var hasDefaultContentType = defaultContentType != null;
- if (acceptContentTypes != null)
- {
- foreach (ReadOnlySpan acceptsType in acceptContentTypes)
- {
- ReadOnlySpan contentType = acceptsType;
- var index = contentType.IndexOf(';');
- if (index != -1)
- {
- contentType = contentType.Slice(0, index);
- }
-
- contentType = contentType.Trim();
- acceptsAnything = contentType.Equals("*/*", StringComparison.OrdinalIgnoreCase);
-
- if (acceptsAnything)
- {
- break;
- }
- }
-
- if (acceptsAnything)
- {
- if (hasDefaultContentType)
- {
- return defaultContentType;
- }
- else
- {
- return ServerDefaultContentType;
- }
- }
- }
-
- if (acceptContentTypes == null && httpReq.ContentType == Soap11)
- {
- return Soap11;
- }
-
- // We could also send a '406 Not Acceptable', but this is allowed also
- return ServerDefaultContentType;
- }
-
- public static bool HasAnyOfContentTypes(HttpRequest request, params string[] contentTypes)
- {
- if (contentTypes == null || request.ContentType == null)
- {
- return false;
- }
-
- foreach (var contentType in contentTypes)
- {
- if (IsContentType(request, contentType))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsContentType(HttpRequest request, string contentType)
- {
- return request.ContentType.StartsWith(contentType, StringComparison.OrdinalIgnoreCase);
- }
-
- private static string GetQueryStringContentType(HttpRequest httpReq)
- {
- ReadOnlySpan format = httpReq.Query["format"].ToString();
- if (format == ReadOnlySpan.Empty)
- {
- const int FormatMaxLength = 4;
- ReadOnlySpan pi = httpReq.Path.ToString();
- if (pi == null || pi.Length <= FormatMaxLength)
- {
- return null;
- }
-
- if (pi[0] == '/')
- {
- pi = pi.Slice(1);
- }
-
- format = pi.LeftPart('/');
- if (format.Length > FormatMaxLength)
- {
- return null;
- }
- }
-
- format = format.LeftPart('.');
- if (format.Contains("json", StringComparison.OrdinalIgnoreCase))
- {
- return "application/json";
- }
- else if (format.Contains("xml", StringComparison.OrdinalIgnoreCase))
- {
- return "application/xml";
- }
-
- return null;
- }
- }
-}
diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
index d746207c7..76db68885 100644
--- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
+++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Model.Services;
+using System.Net;
+using MediaBrowser.Common.Net;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Common.Extensions
@@ -8,26 +9,54 @@ namespace MediaBrowser.Common.Extensions
///
public static class HttpContextExtensions
{
- private const string ServiceStackRequest = "ServiceStackRequest";
-
///
- /// Set the ServiceStack request.
+ /// Checks the origin of the HTTP request.
///
- /// The HttpContext instance.
- /// The service stack request instance.
- public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request)
+ /// The incoming HTTP request.
+ /// true if the request is coming from LAN, false otherwise.
+ public static bool IsLocal(this HttpRequest request)
{
- httpContext.Items[ServiceStackRequest] = request;
+ return (request.HttpContext.Connection.LocalIpAddress == null
+ && request.HttpContext.Connection.RemoteIpAddress == null)
+ || request.HttpContext.Connection.LocalIpAddress.Equals(request.HttpContext.Connection.RemoteIpAddress);
}
///
- /// Get the ServiceStack request.
+ /// Extracts the remote IP address of the caller of the HTTP request.
///
- /// The HttpContext instance.
- /// The service stack request instance.
- public static IRequest GetServiceStackRequest(this HttpContext httpContext)
+ /// The HTTP request.
+ /// The remote caller IP address.
+ public static string RemoteIp(this HttpRequest request)
{
- return (IRequest)httpContext.Items[ServiceStackRequest];
+ if (string.IsNullOrEmpty(request.HttpContext.Items["RemoteIp"].ToString()))
+ {
+ return request.HttpContext.Items["RemoteIp"].ToString();
+ }
+
+ IPAddress ip;
+
+ // "Real" remote ip might be in X-Forwarded-For of X-Real-Ip
+ // (if the server is behind a reverse proxy for example)
+ if (!IPAddress.TryParse(request.Headers[CustomHeaderNames.XForwardedFor].ToString(), out ip))
+ {
+ if (!IPAddress.TryParse(request.Headers[CustomHeaderNames.XRealIP].ToString(), out ip))
+ {
+ ip = request.HttpContext.Connection.RemoteIpAddress;
+
+ // Default to the loopback address if no RemoteIpAddress is specified (i.e. during integration tests)
+ ip ??= IPAddress.Loopback;
+ }
+ }
+
+ if (ip.IsIPv4MappedToIPv6)
+ {
+ ip = ip.MapToIPv4();
+ }
+
+ var normalizedIp = ip.ToString();
+
+ request.HttpContext.Items["RemoteIp"] = normalizedIp;
+ return normalizedIp;
}
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs
index 4cbb63e46..1f3abe8f4 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs
@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Services;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -63,26 +62,20 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets or sets the id.
///
/// The id.
- [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public Guid Id { get; set; }
- [ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string MediaSourceId { get; set; }
- [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string DeviceId { get; set; }
- [ApiMember(Name = "Container", Description = "Container", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public string Container { get; set; }
///
/// Gets or sets the audio codec.
///
/// The audio codec.
- [ApiMember(Name = "AudioCodec", Description = "Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string AudioCodec { get; set; }
- [ApiMember(Name = "EnableAutoStreamCopy", Description = "Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool EnableAutoStreamCopy { get; set; }
public bool AllowVideoStreamCopy { get; set; }
@@ -95,7 +88,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets or sets the audio sample rate.
///
/// The audio sample rate.
- [ApiMember(Name = "AudioSampleRate", Description = "Optional. Specify a specific audio sample rate, e.g. 44100", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? AudioSampleRate { get; set; }
public int? MaxAudioBitDepth { get; set; }
@@ -104,105 +96,86 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets or sets the audio bit rate.
///
/// The audio bit rate.
- [ApiMember(Name = "AudioBitRate", Description = "Optional. Specify an audio bitrate to encode to, e.g. 128000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? AudioBitRate { get; set; }
///
/// Gets or sets the audio channels.
///
/// The audio channels.
- [ApiMember(Name = "AudioChannels", Description = "Optional. Specify a specific number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? AudioChannels { get; set; }
- [ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxAudioChannels { get; set; }
- [ApiMember(Name = "Static", Description = "Optional. If true, the original file will be streamed statically without any encoding. Use either no url extension or the original file extension. true/false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool Static { get; set; }
///
/// Gets or sets the profile.
///
/// The profile.
- [ApiMember(Name = "Profile", Description = "Optional. Specify a specific an encoder profile (varies by encoder), e.g. main, baseline, high.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string Profile { get; set; }
///
/// Gets or sets the level.
///
/// The level.
- [ApiMember(Name = "Level", Description = "Optional. Specify a level for the encoder profile (varies by encoder), e.g. 3, 3.1.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string Level { get; set; }
///
/// Gets or sets the framerate.
///
/// The framerate.
- [ApiMember(Name = "Framerate", Description = "Optional. A specific video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")]
public float? Framerate { get; set; }
- [ApiMember(Name = "MaxFramerate", Description = "Optional. A specific maximum video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")]
public float? MaxFramerate { get; set; }
- [ApiMember(Name = "CopyTimestamps", Description = "Whether or not to copy timestamps when transcoding with an offset. Defaults to false.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool CopyTimestamps { get; set; }
///
/// Gets or sets the start time ticks.
///
/// The start time ticks.
- [ApiMember(Name = "StartTimeTicks", Description = "Optional. Specify a starting offset, in ticks. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public long? StartTimeTicks { get; set; }
///
/// Gets or sets the width.
///
/// The width.
- [ApiMember(Name = "Width", Description = "Optional. The fixed horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? Width { get; set; }
///
/// Gets or sets the height.
///
/// The height.
- [ApiMember(Name = "Height", Description = "Optional. The fixed vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? Height { get; set; }
///
/// Gets or sets the width of the max.
///
/// The width of the max.
- [ApiMember(Name = "MaxWidth", Description = "Optional. The maximum horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxWidth { get; set; }
///
/// Gets or sets the height of the max.
///
/// The height of the max.
- [ApiMember(Name = "MaxHeight", Description = "Optional. The maximum vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxHeight { get; set; }
///
/// Gets or sets the video bit rate.
///
/// The video bit rate.
- [ApiMember(Name = "VideoBitRate", Description = "Optional. Specify a video bitrate to encode to, e.g. 500000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? VideoBitRate { get; set; }
///
/// Gets or sets the index of the subtitle stream.
///
/// The index of the subtitle stream.
- [ApiMember(Name = "SubtitleStreamIndex", Description = "Optional. The index of the subtitle stream to use. If omitted no subtitles will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? SubtitleStreamIndex { get; set; }
- [ApiMember(Name = "SubtitleMethod", Description = "Optional. Specify the subtitle delivery method.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public SubtitleDeliveryMethod SubtitleMethod { get; set; }
- [ApiMember(Name = "MaxRefFrames", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxRefFrames { get; set; }
- [ApiMember(Name = "MaxVideoBitDepth", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? MaxVideoBitDepth { get; set; }
public bool RequireAvc { get; set; }
@@ -223,7 +196,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets or sets the video codec.
///
/// The video codec.
- [ApiMember(Name = "VideoCodec", Description = "Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vpx, wmv.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string VideoCodec { get; set; }
public string SubtitleCodec { get; set; }
@@ -234,14 +206,12 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets or sets the index of the audio stream.
///
/// The index of the audio stream.
- [ApiMember(Name = "AudioStreamIndex", Description = "Optional. The index of the audio stream to use. If omitted the first audio stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? AudioStreamIndex { get; set; }
///
/// Gets or sets the index of the video stream.
///
/// The index of the video stream.
- [ApiMember(Name = "VideoStreamIndex", Description = "Optional. The index of the video stream to use. If omitted the first video stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? VideoStreamIndex { get; set; }
public EncodingContext Context { get; set; }
diff --git a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs
deleted file mode 100644
index 1366fd42e..000000000
--- a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using MediaBrowser.Model.Services;
-using Microsoft.AspNetCore.Http;
-
-namespace MediaBrowser.Controller.Net
-{
- public class AuthenticatedAttribute : Attribute, IHasRequestFilter, IAuthenticationAttributes
- {
- public static IAuthService AuthService { get; set; }
-
- ///
- /// Gets or sets the roles.
- ///
- /// The roles.
- public string Roles { get; set; }
-
- ///
- /// Gets or sets a value indicating whether [escape parental control].
- ///
- /// true if [escape parental control]; otherwise, false.
- public bool EscapeParentalControl { get; set; }
-
- ///
- /// Gets or sets a value indicating whether [allow before startup wizard].
- ///
- /// true if [allow before startup wizard]; otherwise, false.
- public bool AllowBeforeStartupWizard { get; set; }
-
- public bool AllowLocal { get; set; }
-
- ///
- /// The request filter is executed before the service.
- ///
- /// The http request wrapper.
- /// The http response wrapper.
- /// The request DTO.
- public void RequestFilter(IRequest request, HttpResponse response, object requestDto)
- {
- AuthService.Authenticate(request, this);
- }
-
- ///
- /// Order in which Request Filters are executed.
- /// <0 Executed before global request filters
- /// >0 Executed after global request filters
- ///
- /// The priority.
- public int Priority => 0;
-
- public string[] GetRoles()
- {
- return (Roles ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- }
-
- public bool IgnoreLegacyAuth { get; set; }
-
- public bool AllowLocalOnly { get; set; }
- }
-
- public interface IAuthenticationAttributes
- {
- bool EscapeParentalControl { get; }
-
- bool AllowBeforeStartupWizard { get; }
-
- bool AllowLocal { get; }
-
- bool AllowLocalOnly { get; }
-
- string[] GetRoles();
-
- bool IgnoreLegacyAuth { get; }
- }
-}
diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs
index 2055a656a..04b2e13e8 100644
--- a/MediaBrowser.Controller/Net/IAuthService.cs
+++ b/MediaBrowser.Controller/Net/IAuthService.cs
@@ -1,7 +1,5 @@
#nullable enable
-using Jellyfin.Data.Entities;
-using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.Net
@@ -11,21 +9,6 @@ namespace MediaBrowser.Controller.Net
///
public interface IAuthService
{
- ///
- /// Authenticate and authorize request.
- ///
- /// Request.
- /// Authorization attributes.
- void Authenticate(IRequest request, IAuthenticationAttributes authAttribtutes);
-
- ///
- /// Authenticate and authorize request.
- ///
- /// Request.
- /// Authorization attributes.
- /// Authenticated user.
- User? Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtutes);
-
///
/// Authenticate request.
///
diff --git a/MediaBrowser.Controller/Net/IAuthorizationContext.cs b/MediaBrowser.Controller/Net/IAuthorizationContext.cs
index 37a7425b9..4d2f5f5e3 100644
--- a/MediaBrowser.Controller/Net/IAuthorizationContext.cs
+++ b/MediaBrowser.Controller/Net/IAuthorizationContext.cs
@@ -1,4 +1,3 @@
-using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.Net
@@ -20,7 +19,7 @@ namespace MediaBrowser.Controller.Net
///
/// The request context.
/// AuthorizationInfo.
- AuthorizationInfo GetAuthorizationInfo(IRequest requestContext);
+ AuthorizationInfo GetAuthorizationInfo(HttpContext requestContext);
///
/// Gets the authorization information.
diff --git a/MediaBrowser.Controller/Net/IHasResultFactory.cs b/MediaBrowser.Controller/Net/IHasResultFactory.cs
deleted file mode 100644
index b8cf8cd78..000000000
--- a/MediaBrowser.Controller/Net/IHasResultFactory.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using MediaBrowser.Model.Services;
-
-namespace MediaBrowser.Controller.Net
-{
- ///
- /// Interface IHasResultFactory
- /// Services that require a ResultFactory should implement this
- ///
- public interface IHasResultFactory : IRequiresRequest
- {
- ///
- /// Gets or sets the result factory.
- ///
- /// The result factory.
- IHttpResultFactory ResultFactory { get; set; }
- }
-}
diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs
deleted file mode 100644
index 8293a8714..000000000
--- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Services;
-
-namespace MediaBrowser.Controller.Net
-{
- ///
- /// Interface IHttpResultFactory.
- ///
- public interface IHttpResultFactory
- {
- ///
- /// Gets the result.
- ///
- /// The content.
- /// Type of the content.
- /// The response headers.
- /// System.Object.
- object GetResult(string content, string contentType, IDictionary responseHeaders = null);
-
- object GetResult(IRequest requestContext, byte[] content, string contentType, IDictionary responseHeaders = null);
-
- object GetResult(IRequest requestContext, Stream content, string contentType, IDictionary responseHeaders = null);
-
- object GetResult(IRequest requestContext, string content, string contentType, IDictionary responseHeaders = null);
-
- object GetRedirectResult(string url);
-
- object GetResult(IRequest requestContext, T result, IDictionary responseHeaders = null)
- where T : class;
-
- ///
- /// Gets the static result.
- ///
- /// The request context.
- /// The cache key.
- /// The last date modified.
- /// Duration of the cache.
- /// Type of the content.
- /// The factory fn.
- /// The response headers.
- /// if set to true [is head request].
- /// System.Object.
- Task GetStaticResult(IRequest requestContext,
- Guid cacheKey,
- DateTime? lastDateModified,
- TimeSpan? cacheDuration,
- string contentType, Func> factoryFn,
- IDictionary responseHeaders = null,
- bool isHeadRequest = false);
-
- ///
- /// Gets the static result.
- ///
- /// The request context.
- /// The options.
- /// System.Object.
- Task GetStaticResult(IRequest requestContext, StaticResultOptions options);
-
- ///
- /// Gets the static file result.
- ///
- /// The request context.
- /// The path.
- /// The file share.
- /// System.Object.
- Task GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read);
-
- ///
- /// Gets the static file result.
- ///
- /// The request context.
- /// The options.
- /// System.Object.
- Task GetStaticFileResult(IRequest requestContext,
- StaticFileResultOptions options);
- }
-}
diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs
index b04ebda8c..845f27045 100644
--- a/MediaBrowser.Controller/Net/IHttpServer.cs
+++ b/MediaBrowser.Controller/Net/IHttpServer.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Jellyfin.Data.Events;
-using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.Net
@@ -26,7 +25,7 @@ namespace MediaBrowser.Controller.Net
///
/// Inits this instance.
///
- void Init(IEnumerable serviceTypes, IEnumerable listener, IEnumerable urlPrefixes);
+ void Init(IEnumerable listener, IEnumerable urlPrefixes);
///
/// If set, all requests will respond with this message.
@@ -43,8 +42,8 @@ namespace MediaBrowser.Controller.Net
///
/// Get the default CORS headers.
///
- ///
- ///
- IDictionary GetDefaultCorsHeaders(IRequest req);
+ /// The HTTP context of the current request.
+ /// The default CORS headers for the context.
+ IDictionary GetDefaultCorsHeaders(HttpContext httpContext);
}
}
diff --git a/MediaBrowser.Controller/Net/ISessionContext.cs b/MediaBrowser.Controller/Net/ISessionContext.cs
index 5da748f41..a60dc2ea1 100644
--- a/MediaBrowser.Controller/Net/ISessionContext.cs
+++ b/MediaBrowser.Controller/Net/ISessionContext.cs
@@ -2,7 +2,7 @@
using Jellyfin.Data.Entities;
using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Services;
+using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.Net
{
@@ -12,8 +12,8 @@ namespace MediaBrowser.Controller.Net
User GetUser(object requestContext);
- SessionInfo GetSession(IRequest requestContext);
+ SessionInfo GetSession(HttpContext requestContext);
- User GetUser(IRequest requestContext);
+ User GetUser(HttpContext requestContext);
}
}
diff --git a/MediaBrowser.Controller/Net/StaticResultOptions.cs b/MediaBrowser.Controller/Net/StaticResultOptions.cs
deleted file mode 100644
index c1e9bc845..000000000
--- a/MediaBrowser.Controller/Net/StaticResultOptions.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Controller.Net
-{
- public class StaticResultOptions
- {
- public string ContentType { get; set; }
-
- public TimeSpan? CacheDuration { get; set; }
-
- public DateTime? DateLastModified { get; set; }
-
- public Func> ContentFactory { get; set; }
-
- public bool IsHeadRequest { get; set; }
-
- public IDictionary ResponseHeaders { get; set; }
-
- public Action OnComplete { get; set; }
-
- public Action OnError { get; set; }
-
- public string Path { get; set; }
-
- public long? ContentLength { get; set; }
-
- public FileShare FileShare { get; set; }
-
- public StaticResultOptions()
- {
- ResponseHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase);
- FileShare = FileShare.Read;
- }
- }
-
- public class StaticFileResultOptions : StaticResultOptions
- {
- }
-}
diff --git a/MediaBrowser.Model/Services/ApiMemberAttribute.cs b/MediaBrowser.Model/Services/ApiMemberAttribute.cs
deleted file mode 100644
index 63f3ecd55..000000000
--- a/MediaBrowser.Model/Services/ApiMemberAttribute.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-#nullable disable
-using System;
-
-namespace MediaBrowser.Model.Services
-{
- ///
- /// Identifies a single API endpoint.
- ///
- [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
- public class ApiMemberAttribute : Attribute
- {
- ///
- /// Gets or sets verb to which applies attribute. By default applies to all verbs.
- ///
- public string Verb { get; set; }
-
- ///
- /// Gets or sets parameter type: It can be only one of the following: path, query, body, form, or header.
- ///
- public string ParameterType { get; set; }
-
- ///
- /// Gets or sets unique name for the parameter. Each name must be unique, even if they are associated with different paramType values.
- ///
- ///
- ///
- /// Other notes on the name field:
- /// If paramType is body, the name is used only for UI and codegeneration.
- /// If paramType is path, the name field must correspond to the associated path segment from the path field in the api object.
- /// If paramType is query, the name field corresponds to the query param name.
- ///
- ///
- public string Name { get; set; }
-
- ///
- /// Gets or sets the human-readable description for the parameter.
- ///
- public string Description { get; set; }
-
- ///
- /// For path, query, and header paramTypes, this field must be a primitive. For body, this can be a complex or container datatype.
- ///
- public string DataType { get; set; }
-
- ///
- /// For path, this is always true. Otherwise, this field tells the client whether or not the field must be supplied.
- ///
- public bool IsRequired { get; set; }
-
- ///
- /// For query params, this specifies that a comma-separated list of values can be passed to the API. For path and body types, this field cannot be true.
- ///
- public bool AllowMultiple { get; set; }
-
- ///
- /// Gets or sets route to which applies attribute, matches using StartsWith. By default applies to all routes.
- ///
- public string Route { get; set; }
-
- ///
- /// Whether to exclude this property from being included in the ModelSchema.
- ///
- public bool ExcludeInSchema { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IAsyncStreamWriter.cs b/MediaBrowser.Model/Services/IAsyncStreamWriter.cs
deleted file mode 100644
index afbca78a2..000000000
--- a/MediaBrowser.Model/Services/IAsyncStreamWriter.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma warning disable CS1591
-
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IAsyncStreamWriter
- {
- Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken);
- }
-}
diff --git a/MediaBrowser.Model/Services/IHasHeaders.cs b/MediaBrowser.Model/Services/IHasHeaders.cs
deleted file mode 100644
index 313f34b41..000000000
--- a/MediaBrowser.Model/Services/IHasHeaders.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma warning disable CS1591
-
-using System.Collections.Generic;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IHasHeaders
- {
- IDictionary Headers { get; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IHasRequestFilter.cs b/MediaBrowser.Model/Services/IHasRequestFilter.cs
deleted file mode 100644
index b83d3b075..000000000
--- a/MediaBrowser.Model/Services/IHasRequestFilter.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma warning disable CS1591
-
-using Microsoft.AspNetCore.Http;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IHasRequestFilter
- {
- ///
- /// Gets the order in which Request Filters are executed.
- /// <0 Executed before global request filters.
- /// >0 Executed after global request filters.
- ///
- int Priority { get; }
-
- ///
- /// The request filter is executed before the service.
- ///
- /// The http request wrapper.
- /// The http response wrapper.
- /// The request DTO.
- void RequestFilter(IRequest req, HttpResponse res, object requestDto);
- }
-}
diff --git a/MediaBrowser.Model/Services/IHttpRequest.cs b/MediaBrowser.Model/Services/IHttpRequest.cs
deleted file mode 100644
index 3ea65195c..000000000
--- a/MediaBrowser.Model/Services/IHttpRequest.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma warning disable CS1591
-
-namespace MediaBrowser.Model.Services
-{
- public interface IHttpRequest : IRequest
- {
- ///
- /// Gets the HTTP Verb.
- ///
- string HttpMethod { get; }
-
- ///
- /// Gets the value of the Accept HTTP Request Header.
- ///
- string Accept { get; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IHttpResult.cs b/MediaBrowser.Model/Services/IHttpResult.cs
deleted file mode 100644
index abc581d8e..000000000
--- a/MediaBrowser.Model/Services/IHttpResult.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591
-
-using System.Net;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IHttpResult : IHasHeaders
- {
- ///
- /// The HTTP Response Status.
- ///
- int Status { get; set; }
-
- ///
- /// The HTTP Response Status Code.
- ///
- HttpStatusCode StatusCode { get; set; }
-
- ///
- /// The HTTP Response ContentType.
- ///
- string ContentType { get; set; }
-
- ///
- /// Response DTO.
- ///
- object Response { get; set; }
-
- ///
- /// Holds the request call context.
- ///
- IRequest RequestContext { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IRequest.cs b/MediaBrowser.Model/Services/IRequest.cs
deleted file mode 100644
index 8bc1d3668..000000000
--- a/MediaBrowser.Model/Services/IRequest.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using Microsoft.AspNetCore.Http;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IRequest
- {
- HttpResponse Response { get; }
-
- ///
- /// The name of the service being called (e.g. Request DTO Name)
- ///
- string OperationName { get; set; }
-
- ///
- /// The Verb / HttpMethod or Action for this request
- ///
- string Verb { get; }
-
- ///
- /// The request ContentType.
- ///
- string ContentType { get; }
-
- bool IsLocal { get; }
-
- string UserAgent { get; }
-
- ///
- /// The expected Response ContentType for this request.
- ///
- string ResponseContentType { get; set; }
-
- ///
- /// Attach any data to this request that all filters and services can access.
- ///
- Dictionary Items { get; }
-
- IHeaderDictionary Headers { get; }
-
- IQueryCollection QueryString { get; }
-
- string RawUrl { get; }
-
- string AbsoluteUri { get; }
-
- ///
- /// The Remote Ip as reported by X-Forwarded-For, X-Real-IP or Request.UserHostAddress
- ///
- string RemoteIp { get; }
-
- ///
- /// The value of the Authorization Header used to send the Api Key, null if not available.
- ///
- string Authorization { get; }
-
- string[] AcceptTypes { get; }
-
- string PathInfo { get; }
-
- Stream InputStream { get; }
-
- long ContentLength { get; }
-
- ///
- /// The value of the Referrer, null if not available.
- ///
- Uri UrlReferrer { get; }
- }
-
- public interface IHttpFile
- {
- string Name { get; }
-
- string FileName { get; }
-
- long ContentLength { get; }
-
- string ContentType { get; }
-
- Stream InputStream { get; }
- }
-
- public interface IRequiresRequest
- {
- IRequest Request { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IRequiresRequestStream.cs b/MediaBrowser.Model/Services/IRequiresRequestStream.cs
deleted file mode 100644
index 3e5f2da42..000000000
--- a/MediaBrowser.Model/Services/IRequiresRequestStream.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma warning disable CS1591
-
-using System.IO;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IRequiresRequestStream
- {
- ///
- /// The raw Http Request Input Stream.
- ///
- Stream RequestStream { get; set; }
- }
-}
diff --git a/MediaBrowser.Model/Services/IService.cs b/MediaBrowser.Model/Services/IService.cs
deleted file mode 100644
index 5233f57ab..000000000
--- a/MediaBrowser.Model/Services/IService.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma warning disable CS1591
-
-namespace MediaBrowser.Model.Services
-{
- // marker interface
- public interface IService
- {
- }
-
- public interface IReturn { }
-
- public interface IReturn : IReturn { }
-
- public interface IReturnVoid : IReturn { }
-}
diff --git a/MediaBrowser.Model/Services/IStreamWriter.cs b/MediaBrowser.Model/Services/IStreamWriter.cs
deleted file mode 100644
index 3ebfef66b..000000000
--- a/MediaBrowser.Model/Services/IStreamWriter.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma warning disable CS1591
-
-using System.IO;
-
-namespace MediaBrowser.Model.Services
-{
- public interface IStreamWriter
- {
- void WriteTo(Stream responseStream);
- }
-}
diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs
deleted file mode 100644
index bdb0cabdf..000000000
--- a/MediaBrowser.Model/Services/QueryParamCollection.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using MediaBrowser.Model.Dto;
-
-namespace MediaBrowser.Model.Services
-{
- // Remove this garbage class, it's just a bastard copy of NameValueCollection
- public class QueryParamCollection : List
- {
- public QueryParamCollection()
- {
- }
-
- private static StringComparison GetStringComparison()
- {
- return StringComparison.OrdinalIgnoreCase;
- }
-
- ///
- /// Adds a new query parameter.
- ///
- public void Add(string key, string value)
- {
- Add(new NameValuePair(key, value));
- }
-
- private void Set(string key, string value)
- {
- if (string.IsNullOrEmpty(value))
- {
- var parameters = GetItems(key);
-
- foreach (var p in parameters)
- {
- Remove(p);
- }
-
- return;
- }
-
- foreach (var pair in this)
- {
- var stringComparison = GetStringComparison();
-
- if (string.Equals(key, pair.Name, stringComparison))
- {
- pair.Value = value;
- return;
- }
- }
-
- Add(key, value);
- }
-
- private string Get(string name)
- {
- var stringComparison = GetStringComparison();
-
- foreach (var pair in this)
- {
- if (string.Equals(pair.Name, name, stringComparison))
- {
- return pair.Value;
- }
- }
-
- return null;
- }
-
- private List GetItems(string name)
- {
- var stringComparison = GetStringComparison();
-
- var list = new List();
-
- foreach (var pair in this)
- {
- if (string.Equals(pair.Name, name, stringComparison))
- {
- list.Add(pair);
- }
- }
-
- return list;
- }
-
- public virtual List GetValues(string name)
- {
- var stringComparison = GetStringComparison();
-
- var list = new List();
-
- foreach (var pair in this)
- {
- if (string.Equals(pair.Name, name, stringComparison))
- {
- list.Add(pair.Value);
- }
- }
-
- return list;
- }
-
- public IEnumerable Keys
- {
- get
- {
- var keys = new string[this.Count];
-
- for (var i = 0; i < keys.Length; i++)
- {
- keys[i] = this[i].Name;
- }
-
- return keys;
- }
- }
-
- ///
- /// Gets or sets a query parameter value by name. A query may contain multiple values of the same name
- /// (i.e. "x=1&x=2"), in which case the value is an array, which works for both getting and setting.
- ///
- /// The query parameter name.
- /// The query parameter value or array of values.
- public string this[string name]
- {
- get => Get(name);
- set => Set(name, value);
- }
-
- private string GetQueryStringValue(NameValuePair pair)
- {
- return pair.Name + "=" + pair.Value;
- }
-
- public override string ToString()
- {
- var vals = this.Select(GetQueryStringValue).ToArray();
-
- return string.Join("&", vals);
- }
- }
-}
diff --git a/MediaBrowser.Model/Services/RouteAttribute.cs b/MediaBrowser.Model/Services/RouteAttribute.cs
deleted file mode 100644
index f8bf51112..000000000
--- a/MediaBrowser.Model/Services/RouteAttribute.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-#nullable disable
-#pragma warning disable CS1591
-
-using System;
-
-namespace MediaBrowser.Model.Services
-{
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
- public class RouteAttribute : Attribute
- {
- ///
- /// Initializes an instance of the class.
- ///
- ///
- /// The path template to map to the request. See
- /// RouteAttribute.Path
- /// for details on the correct format.
- ///
- public RouteAttribute(string path)
- : this(path, null)
- {
- }
-
- ///
- /// Initializes an instance of the class.
- ///
- ///
- /// The path template to map to the request. See
- /// RouteAttribute.Path
- /// for details on the correct format.
- ///
- /// A comma-delimited list of HTTP verbs supported by the
- /// service. If unspecified, all verbs are assumed to be supported.
- public RouteAttribute(string path, string verbs)
- {
- Path = path;
- Verbs = verbs;
- }
-
- ///
- /// Gets or sets the path template to be mapped to the request.
- ///
- ///
- /// A value providing the path mapped to
- /// the request. Never .
- ///
- ///
- /// Some examples of valid paths are:
- ///
- ///
- /// "/Inventory"
- /// "/Inventory/{Category}/{ItemId}"
- /// "/Inventory/{ItemPath*}"
- ///
- ///
- /// Variables are specified within "{}"
- /// brackets. Each variable in the path is mapped to the same-named property
- /// on the request DTO. At runtime, ServiceStack will parse the
- /// request URL, extract the variable values, instantiate the request DTO,
- /// and assign the variable values into the corresponding request properties,
- /// prior to passing the request DTO to the service object for processing.
- ///
- /// It is not necessary to specify all request properties as
- /// variables in the path. For unspecified properties, callers may provide
- /// values in the query string. For example: the URL
- /// "http://services/Inventory?Category=Books&ItemId=12345" causes the same
- /// request DTO to be processed as "http://services/Inventory/Books/12345",
- /// provided that the paths "/Inventory" (which supports the first URL) and
- /// "/Inventory/{Category}/{ItemId}" (which supports the second URL)
- /// are both mapped to the request DTO.
- ///
- /// Please note that while it is possible to specify property values
- /// in the query string, it is generally considered to be less RESTful and
- /// less desirable than to specify them as variables in the path. Using the
- /// query string to specify property values may also interfere with HTTP
- /// caching.
- ///
- /// The final variable in the path may contain a "*" suffix
- /// to grab all remaining segments in the path portion of the request URL and assign
- /// them to a single property on the request DTO.
- /// For example, if the path "/Inventory/{ItemPath*}" is mapped to the request DTO,
- /// then the request URL "http://services/Inventory/Books/12345" will result
- /// in a request DTO whose ItemPath property contains "Books/12345".
- /// You may only specify one such variable in the path, and it must be positioned at
- /// the end of the path.
- ///
- public string Path { get; set; }
-
- ///
- /// Gets or sets short summary of what the route does.
- ///
- public string Summary { get; set; }
-
- public string Description { get; set; }
-
- public bool IsHidden { get; set; }
-
- ///
- /// Gets or sets longer text to explain the behaviour of the route.
- ///
- public string Notes { get; set; }
-
- ///
- /// Gets or sets a comma-delimited list of HTTP verbs supported by the service, such as
- /// "GET,PUT,POST,DELETE".
- ///
- ///
- /// A providing a comma-delimited list of HTTP verbs supported
- /// by the service, or empty if all verbs are supported.
- ///
- public string Verbs { get; set; }
-
- ///
- /// Used to rank the precedences of route definitions in reverse routing.
- /// i.e. Priorities below 0 are auto-generated have less precedence.
- ///
- public int Priority { get; set; }
-
- protected bool Equals(RouteAttribute other)
- {
- return base.Equals(other)
- && string.Equals(Path, other.Path)
- && string.Equals(Summary, other.Summary)
- && string.Equals(Notes, other.Notes)
- && string.Equals(Verbs, other.Verbs)
- && Priority == other.Priority;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- if (obj.GetType() != this.GetType())
- {
- return false;
- }
-
- return Equals((RouteAttribute)obj);
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- var hashCode = base.GetHashCode();
- hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (Summary != null ? Summary.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (Notes != null ? Notes.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (Verbs != null ? Verbs.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ Priority;
- return hashCode;
- }
- }
- }
-}
diff --git a/MediaBrowser.Model/Session/PlayRequest.cs b/MediaBrowser.Model/Session/PlayRequest.cs
index eeb25c2e8..6a66465a2 100644
--- a/MediaBrowser.Model/Session/PlayRequest.cs
+++ b/MediaBrowser.Model/Session/PlayRequest.cs
@@ -2,7 +2,6 @@
#pragma warning disable CS1591
using System;
-using MediaBrowser.Model.Services;
namespace MediaBrowser.Model.Session
{
diff --git a/tests/Jellyfin.Server.Implementations.Tests/HttpServer/ResponseFilterTests.cs b/tests/Jellyfin.Server.Implementations.Tests/HttpServer/ResponseFilterTests.cs
deleted file mode 100644
index 39bd94b59..000000000
--- a/tests/Jellyfin.Server.Implementations.Tests/HttpServer/ResponseFilterTests.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Emby.Server.Implementations.HttpServer;
-using Xunit;
-
-namespace Jellyfin.Server.Implementations.Tests.HttpServer
-{
- public class ResponseFilterTests
- {
- [Theory]
- [InlineData(null, null)]
- [InlineData("", "")]
- [InlineData("This is a clean string.", "This is a clean string.")]
- [InlineData("This isn't \n\ra clean string.", "This isn't a clean string.")]
- public void RemoveControlCharacters_ValidArgs_Correct(string? input, string? result)
- {
- Assert.Equal(result, ResponseFilter.RemoveControlCharacters(input));
- }
- }
-}
--
cgit v1.2.3
From 346581bb2ab8e5c93d83e0a486d3d705b54c7d08 Mon Sep 17 00:00:00 2001
From: Erwin de Haan
Date: Wed, 2 Sep 2020 22:42:00 +0200
Subject: Fixes for CI Nuget package pushing and CI triggers
Also adds SourceLink support and symbols that are pushed to Nuget.
Add symbols to main nuget packages for unstable builds (Azure Artifacts does not support symbols outside of the main package)
SourceLink will enable stepping during debugging.
---
.ci/azure-pipelines-package.yml | 36 +++++++++++++++++-----
.ci/azure-pipelines.yml | 14 ++++++---
Emby.Naming/Emby.Naming.csproj | 13 ++++++++
Jellyfin.Data/Jellyfin.Data.csproj | 9 ++++++
MediaBrowser.Common/MediaBrowser.Common.csproj | 10 ++++++
.../MediaBrowser.Controller.csproj | 10 ++++++
MediaBrowser.Model/MediaBrowser.Model.csproj | 10 ++++++
7 files changed, 91 insertions(+), 11 deletions(-)
(limited to 'MediaBrowser.Model')
diff --git a/.ci/azure-pipelines-package.yml b/.ci/azure-pipelines-package.yml
index cfe76d463..2d83320b5 100644
--- a/.ci/azure-pipelines-package.yml
+++ b/.ci/azure-pipelines-package.yml
@@ -138,14 +138,14 @@ jobs:
commands: sudo nohup -n /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber) unstable &
- task: SSH@0
- displayName: 'Update Stable Repository'
+ displayName: 'Update Stable Repository'
continueOnError: true
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
inputs:
sshEndpoint: repository
runOptions: 'commands'
commands: sudo nohup -n /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber) &
-
+
- job: PublishNuget
displayName: 'Publish NuGet packages'
dependsOn:
@@ -175,7 +175,7 @@ jobs:
MediaBrowser.Model/MediaBrowser.Model.csproj
Emby.Naming/Emby.Naming.csproj
custom: 'pack'
- arguments: '--version-suffix $(Build.BuildNumber) -o $(Build.ArtifactStagingDirectory)'
+ arguments: '--version-suffix $(Build.BuildNumber) -o $(Build.ArtifactStagingDirectory) -p:Stability=Unstable'
- task: PublishBuildArtifacts@1
displayName: 'Publish Nuget packages'
@@ -183,10 +183,32 @@ jobs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: Jellyfin Nuget Packages
+ - task: NuGetAuthenticate@0
+ displayName: 'Authenticate to stable Nuget feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ nuGetServiceConnections: 'NugetOrg'
+
- task: NuGetCommand@2
- displayName: 'Push Nuget packages to feed'
- condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
+ displayName: 'Push Nuget packages to stable feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
+ inputs:
+ command: 'push'
+ packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;$(Build.ArtifactStagingDirectory)/**/*.snupkg'
+ nuGetFeedType: 'external'
+ publishFeedCredentials: 'NugetOrg'
+ allowPackageConflicts: true # This ignores an error if the version already exists
+
+ - task: NuGetAuthenticate@0
+ displayName: 'Authenticate to unstable Nuget feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
+
+ - task: NuGetCommand@2
+ displayName: 'Push Nuget packages to unstable feed'
+ condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'push'
- packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
- includeNugetOrg: 'true'
+ packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' # No symbols since Azure Artifact does not support it
+ nuGetFeedType: 'internal'
+ publishVstsFeed: '7cce6c46-d610-45e3-9fb7-65a6bfd1b671/a5746b79-f369-42db-93ff-59cd066f9327'
+ allowPackageConflicts: true # This ignores an error if the version already exists
diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml
index 0c86c0171..6f5f3ff2b 100644
--- a/.ci/azure-pipelines.yml
+++ b/.ci/azure-pipelines.yml
@@ -13,15 +13,21 @@ pr:
trigger:
batch: true
+ branches:
+ include:
+ - '*'
+ tags:
+ include:
+ - 'v*'
jobs:
-- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
+- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-main.yml
parameters:
LinuxImage: 'ubuntu-latest'
RestoreBuildProjects: $(RestoreBuildProjects)
-- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
+- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-test.yml
parameters:
ImageNames:
@@ -29,7 +35,7 @@ jobs:
Windows: 'windows-latest'
macOS: 'macos-latest'
-- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
+- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-abi.yml
parameters:
Packages:
@@ -47,5 +53,5 @@ jobs:
AssemblyFileName: MediaBrowser.Common.dll
LinuxImage: 'ubuntu-latest'
-- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
+- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
- template: azure-pipelines-package.yml
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 5e2c6e3e3..6857f9952 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -10,6 +10,15 @@
falsetruetrue
+ true
+ true
+ true
+ snupkg
+
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
@@ -28,6 +37,10 @@
GPL-3.0-only
+
+
+
+
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index e8065419d..547771faa 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -5,6 +5,15 @@
falsetruetrue
+ true
+ true
+ true
+ snupkg
+
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index deb674e45..6e258371c 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -18,6 +18,7 @@
+
@@ -32,6 +33,15 @@
falsetruetrue
+ true
+ true
+ true
+ snupkg
+
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index df92eda38..3674181b1 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -14,6 +14,7 @@
+
@@ -32,6 +33,15 @@
falsetruetrue
+ true
+ true
+ true
+ snupkg
+
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 0491c9072..4ae38ade9 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -20,9 +20,19 @@
trueenablelatest
+ true
+ true
+ true
+ snupkg
+
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
+
--
cgit v1.2.3