aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Dlna/Main/DlnaEntryPoint.cs3
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs6
-rw-r--r--Jellyfin.Api/Controllers/ItemLookupController.cs4
-rw-r--r--Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs12
-rw-r--r--Jellyfin.Server/Startup.cs3
-rw-r--r--MediaBrowser.Common/Net/CustomHeaderNames.cs13
-rw-r--r--MediaBrowser.Common/System/OperatingSystem.cs74
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs4
-rw-r--r--MediaBrowser.Model/System/OperatingSystemId.cs12
-rw-r--r--MediaBrowser.Model/System/PublicSystemInfo.cs5
-rw-r--r--MediaBrowser.Model/System/SystemInfo.cs6
-rw-r--r--MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs22
-rw-r--r--src/Jellyfin.Extensions/AlphanumericComparator.cs43
-rw-r--r--tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs5
14 files changed, 44 insertions, 168 deletions
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs
index 2dc079254a..aab475153b 100644
--- a/Emby.Dlna/Main/DlnaEntryPoint.cs
+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs
@@ -7,6 +7,7 @@ using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Net.Sockets;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Emby.Dlna.PlayTo;
using Emby.Dlna.Ssdp;
@@ -262,7 +263,7 @@ namespace Emby.Dlna.Main
{
_publisher = new SsdpDevicePublisher(
_communicationsServer,
- MediaBrowser.Common.System.OperatingSystem.Name,
+ Environment.OSVersion.Platform.ToString(),
Environment.OSVersion.VersionString,
_config.GetDlnaConfiguration().SendOnlyMatchedHost)
{
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index fe1f4defe4..560ba7d10d 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -690,7 +690,7 @@ namespace Emby.Server.Implementations
logger.LogInformation("Environment Variables: {EnvVars}", relevantEnvVars);
logger.LogInformation("Arguments: {Args}", commandLineArgs);
- logger.LogInformation("Operating system: {OS}", MediaBrowser.Common.System.OperatingSystem.Name);
+ logger.LogInformation("Operating system: {OS}", RuntimeInformation.OSDescription);
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
@@ -1032,14 +1032,11 @@ namespace Emby.Server.Implementations
ItemsByNamePath = ApplicationPaths.InternalMetadataPath,
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
CachePath = ApplicationPaths.CachePath,
- OperatingSystem = MediaBrowser.Common.System.OperatingSystem.Id.ToString(),
- OperatingSystemDisplayName = MediaBrowser.Common.System.OperatingSystem.Name,
CanLaunchWebBrowser = CanLaunchWebBrowser,
TranscodingTempPath = ConfigurationManager.GetTranscodePath(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(request),
SupportsLibraryMonitor = true,
- SystemArchitecture = RuntimeInformation.OSArchitecture,
PackageName = _startupOptions.PackageName
};
}
@@ -1051,7 +1048,6 @@ namespace Emby.Server.Implementations
Version = ApplicationVersionString,
ProductName = ApplicationProductName,
Id = SystemId,
- OperatingSystem = MediaBrowser.Common.System.OperatingSystem.Id.ToString(),
ServerName = FriendlyName,
LocalAddress = GetSmartApiUrl(request),
StartupWizardCompleted = ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted
diff --git a/Jellyfin.Api/Controllers/ItemLookupController.cs b/Jellyfin.Api/Controllers/ItemLookupController.cs
index 34893d682d..b6c5504db5 100644
--- a/Jellyfin.Api/Controllers/ItemLookupController.cs
+++ b/Jellyfin.Api/Controllers/ItemLookupController.cs
@@ -248,10 +248,10 @@ namespace Jellyfin.Api.Controllers
{
var item = _libraryManager.GetItemById(itemId);
_logger.LogInformation(
- "Setting provider id's to item {0}-{1}: {2}",
+ "Setting provider id's to item {ItemId}-{ItemName}: {@ProviderIds}",
item.Id,
item.Name,
- JsonSerializer.Serialize(searchResult.ProviderIds));
+ searchResult.ProviderIds);
// Since the refresh process won't erase provider Ids, we need to set this explicitly now.
item.ProviderIds = searchResult.ProviderIds;
diff --git a/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
index 94df23e569..7c6ce3273e 100644
--- a/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
+++ b/Jellyfin.Api/WebSocketListeners/ScheduledTasksWebSocketListener.cs
@@ -64,21 +64,21 @@ namespace Jellyfin.Api.WebSocketListeners
base.Dispose(dispose);
}
- private void OnTaskCompleted(object? sender, TaskCompletionEventArgs e)
+ private async void OnTaskCompleted(object? sender, TaskCompletionEventArgs e)
{
- SendData(true);
e.Task.TaskProgress -= OnTaskProgress;
+ await SendData(true).ConfigureAwait(false);
}
- private void OnTaskExecuting(object? sender, GenericEventArgs<IScheduledTaskWorker> e)
+ private async void OnTaskExecuting(object? sender, GenericEventArgs<IScheduledTaskWorker> e)
{
- SendData(true);
+ await SendData(true).ConfigureAwait(false);
e.Argument.TaskProgress += OnTaskProgress;
}
- private void OnTaskProgress(object? sender, GenericEventArgs<double> e)
+ private async void OnTaskProgress(object? sender, GenericEventArgs<double> e)
{
- SendData(false);
+ await SendData(false).ConfigureAwait(false);
}
}
}
diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs
index 7abd2fbef9..155f9fc8c1 100644
--- a/Jellyfin.Server/Startup.cs
+++ b/Jellyfin.Server/Startup.cs
@@ -4,6 +4,7 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
+using System.Runtime.InteropServices;
using System.Text;
using Jellyfin.Api.Middleware;
using Jellyfin.MediaEncoding.Hls.Extensions;
@@ -108,7 +109,7 @@ namespace Jellyfin.Server
string.Format(
CultureInfo.InvariantCulture,
"{0}/{1} UPnP/1.0 {2}/{3}",
- MediaBrowser.Common.System.OperatingSystem.Name,
+ Environment.OSVersion.Platform,
Environment.OSVersion,
_serverApplicationHost.Name,
_serverApplicationHost.ApplicationVersionString));
diff --git a/MediaBrowser.Common/Net/CustomHeaderNames.cs b/MediaBrowser.Common/Net/CustomHeaderNames.cs
deleted file mode 100644
index 5ca9897eb4..0000000000
--- a/MediaBrowser.Common/Net/CustomHeaderNames.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma warning disable CS1591
-
-namespace MediaBrowser.Common.Net
-{
- public static class CustomHeaderNames
- {
- // Other Headers
- public const string XForwardedFor = "X-Forwarded-For";
- public const string XForwardedPort = "X-Forwarded-Port";
- public const string XForwardedProto = "X-Forwarded-Proto";
- public const string XRealIP = "X-Real-IP";
- }
-}
diff --git a/MediaBrowser.Common/System/OperatingSystem.cs b/MediaBrowser.Common/System/OperatingSystem.cs
deleted file mode 100644
index 5f673d3208..0000000000
--- a/MediaBrowser.Common/System/OperatingSystem.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Runtime.InteropServices;
-using System.Threading;
-using MediaBrowser.Model.System;
-
-namespace MediaBrowser.Common.System
-{
- public static class OperatingSystem
- {
- // We can't use Interlocked.CompareExchange for enums
- private static int _id = int.MaxValue;
-
- public static OperatingSystemId Id
- {
- get
- {
- if (_id == int.MaxValue)
- {
- Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
- }
-
- return (OperatingSystemId)_id;
- }
- }
-
- public static string Name
- {
- get
- {
- switch (Id)
- {
- case OperatingSystemId.BSD: return "BSD";
- case OperatingSystemId.Linux: return "Linux";
- case OperatingSystemId.Darwin: return "macOS";
- case OperatingSystemId.Windows: return "Windows";
- default: throw new PlatformNotSupportedException($"Unknown OS {Id}");
- }
- }
- }
-
- private static OperatingSystemId GetId()
- {
- switch (Environment.OSVersion.Platform)
- {
- // On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
- case PlatformID.MacOSX:
- return OperatingSystemId.Darwin;
- case PlatformID.Win32NT:
- return OperatingSystemId.Windows;
- case PlatformID.Unix:
- default:
- {
- string osDescription = RuntimeInformation.OSDescription;
- if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase))
- {
- return OperatingSystemId.Linux;
- }
- else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase))
- {
- return OperatingSystemId.Darwin;
- }
- else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase))
- {
- return OperatingSystemId.BSD;
- }
-
- throw new PlatformNotSupportedException($"Can't resolve OS with description: '{osDescription}'");
- }
- }
- }
- }
-}
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 4cab1f640e..9f7be977ff 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -4251,9 +4251,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (hasGraphicalSubs)
{
- var subSwScaleFilter = isSwDecoder
- ? GetSwScaleFilter(state, options, vidEncoder, inW, inH, threeDFormat, reqW, reqH, reqMaxW, reqMaxH)
- : GetCustomSwScaleFilter(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
+ var subSwScaleFilter = GetCustomSwScaleFilter(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
subFilters.Add(subSwScaleFilter);
overlayFilters.Add("overlay=eof_action=pass:shortest=1:repeatlast=0");
diff --git a/MediaBrowser.Model/System/OperatingSystemId.cs b/MediaBrowser.Model/System/OperatingSystemId.cs
deleted file mode 100644
index 2e417f6b56..0000000000
--- a/MediaBrowser.Model/System/OperatingSystemId.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma warning disable CS1591
-
-namespace MediaBrowser.Model.System
-{
- public enum OperatingSystemId
- {
- Windows,
- Linux,
- Darwin,
- BSD
- }
-}
diff --git a/MediaBrowser.Model/System/PublicSystemInfo.cs b/MediaBrowser.Model/System/PublicSystemInfo.cs
index 53030843ae..31a8956427 100644
--- a/MediaBrowser.Model/System/PublicSystemInfo.cs
+++ b/MediaBrowser.Model/System/PublicSystemInfo.cs
@@ -1,6 +1,8 @@
#nullable disable
#pragma warning disable CS1591
+using System;
+
namespace MediaBrowser.Model.System
{
public class PublicSystemInfo
@@ -32,7 +34,8 @@ namespace MediaBrowser.Model.System
/// Gets or sets the operating system.
/// </summary>
/// <value>The operating system.</value>
- public string OperatingSystem { get; set; }
+ [Obsolete("This is no longer set")]
+ public string OperatingSystem { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the id.
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index 9e56849c7c..bd0099af70 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -42,7 +42,8 @@ namespace MediaBrowser.Model.System
/// Gets or sets the display name of the operating system.
/// </summary>
/// <value>The display name of the operating system.</value>
- public string OperatingSystemDisplayName { get; set; }
+ [Obsolete("This is no longer set")]
+ public string OperatingSystemDisplayName { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the package name.
@@ -137,6 +138,7 @@ namespace MediaBrowser.Model.System
[Obsolete("This isn't set correctly anymore")]
public FFmpegLocation EncoderLocation { get; set; }
- public Architecture SystemArchitecture { get; set; }
+ [Obsolete("This is no longer set")]
+ public Architecture SystemArchitecture { get; set; } = Architecture.X64;
}
}
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index 96c512a466..c3a735c6de 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -266,11 +266,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
var nfoConfiguration = _config.GetNfoConfiguration();
UserItemData? userData = null;
- if (!string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
- {
- var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
- userData = _userDataManager.GetUserData(user, item);
- }
switch (reader.Name)
{
@@ -370,9 +365,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
var val = reader.ReadElementContentAsBoolean();
- if (userData is not null)
+ if (!string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
{
+ var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
+ userData = _userDataManager.GetUserData(user, item);
userData.Played = val;
+ _userDataManager.SaveUserData(user, item, userData, UserDataSaveReason.Import, CancellationToken.None);
}
break;
@@ -381,11 +379,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "playcount":
{
var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val) && userData is not null)
+ if (!string.IsNullOrWhiteSpace(val) && !string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
{
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out var count))
{
+ var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
+ userData = _userDataManager.GetUserData(user, item);
userData.PlayCount = count;
+ _userDataManager.SaveUserData(user, item, userData, UserDataSaveReason.Import, CancellationToken.None);
}
}
@@ -395,12 +396,15 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "lastplayed":
{
var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val) && userData is not null)
+ if (!string.IsNullOrWhiteSpace(val) && !string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
{
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var added))
{
+ var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
+ userData = _userDataManager.GetUserData(user, item);
userData.LastPlayedDate = added;
- }
+ _userDataManager.SaveUserData(user, item, userData, UserDataSaveReason.Import, CancellationToken.None);
+ }
else
{
Logger.LogWarning("Invalid lastplayed value found: {Value}", val);
diff --git a/src/Jellyfin.Extensions/AlphanumericComparator.cs b/src/Jellyfin.Extensions/AlphanumericComparator.cs
index 1b19752bb3..6e451d40e9 100644
--- a/src/Jellyfin.Extensions/AlphanumericComparator.cs
+++ b/src/Jellyfin.Extensions/AlphanumericComparator.cs
@@ -86,47 +86,12 @@ namespace Jellyfin.Extensions
{
return 1;
}
- else if (span1Len >= 20) // Number is probably too big for a ulong
- {
- // Trim all the first digits that are the same
- int i = 0;
- while (i < span1Len && span1[i] == span2[i])
- {
- i++;
- }
-
- // If there are no more digits it's the same number
- if (i == span1Len)
- {
- continue;
- }
-
- // Only need to compare the most significant digit
- span1 = span1.Slice(i, 1);
- span2 = span2.Slice(i, 1);
- }
-
- if (!ulong.TryParse(span1, out var num1)
- || !ulong.TryParse(span2, out var num2))
- {
- return 0;
- }
- else if (num1 < num2)
- {
- return -1;
- }
- else if (num1 > num2)
- {
- return 1;
- }
}
- else
+
+ int result = span1.CompareTo(span2, StringComparison.InvariantCulture);
+ if (result != 0)
{
- int result = span1.CompareTo(span2, StringComparison.InvariantCulture);
- if (result != 0)
- {
- return result;
- }
+ return result;
}
} while (pos1 < len1 && pos2 < len2);
diff --git a/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
index 2a7e8fafdf..105e2a52ae 100644
--- a/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
+++ b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
@@ -19,6 +19,11 @@ namespace Jellyfin.Extensions.Tests
[InlineData("12345678912345678912345678913234567891", "12345678912345678912345678913234567892")]
[InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891a")]
[InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891b")]
+ [InlineData("a5", "a11")]
+ [InlineData("a05a", "a5b")]
+ [InlineData("a5a", "a05b")]
+ [InlineData("6xxx", "007asdf")]
+ [InlineData("00042Q", "42s")]
public void AlphanumericComparatorTest(params string?[] strings)
{
var copy = strings.Reverse().ToArray();