From 724d2986a313823f5ded5c5745ab193cbd89e921 Mon Sep 17 00:00:00 2001
From: holow29 <67209066+holow29@users.noreply.github.com>
Date: Mon, 6 Feb 2023 00:40:49 -0500
Subject: Change transcoderChannelLimit default to 8
Change transcoderChannelLimit default to 8 from 6
Switch to querying for encoder and added more cases to transcoderChannelLimit
Refactor GetNumAudioChannelsParam
---
.../MediaEncoding/EncodingHelper.cs | 98 ++++++++--------------
1 file changed, 35 insertions(+), 63 deletions(-)
(limited to 'MediaBrowser.Controller')
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 9b5edabc0..98a6f47ba 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -2211,85 +2211,57 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
- var inputChannels = audioStream.Channels;
+ var codec = outputAudioCodec ?? string.Empty;
- if (inputChannels <= 0)
- {
- inputChannels = null;
- }
+ int? resultChannels = state.GetRequestedAudioChannels(codec);
- var codec = outputAudioCodec ?? string.Empty;
+ var inputChannels = audioStream.Channels;
- int? transcoderChannelLimit;
- if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
- {
- // wmav2 currently only supports two channel output
- transcoderChannelLimit = 2;
- }
- else if (codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1)
+ if (inputChannels > 0)
{
- // libmp3lame currently only supports two channel output
- transcoderChannelLimit = 2;
- }
- else if (codec.IndexOf("aac", StringComparison.OrdinalIgnoreCase) != -1)
- {
- // aac is able to handle 8ch(7.1 layout)
- transcoderChannelLimit = 8;
- }
- else
- {
- // If we don't have any media info then limit it to 6 to prevent encoding errors due to asking for too many channels
- transcoderChannelLimit = 6;
+ resultChannels = inputChannels < resultChannels ? inputChannels : resultChannels ?? inputChannels;
}
var isTranscodingAudio = !IsCopyCodec(codec);
- int? resultChannels = state.GetRequestedAudioChannels(codec);
if (isTranscodingAudio)
{
- resultChannels = GetMinValue(request.TranscodingMaxAudioChannels, resultChannels);
- }
-
- if (inputChannels.HasValue)
- {
- resultChannels = resultChannels.HasValue
- ? Math.Min(resultChannels.Value, inputChannels.Value)
- : inputChannels.Value;
- }
+ // Set max transcoding channels for encoders that can't handle more than a set amount of channels
+ // AAC, FLAC, ALAC, libopus, libvorbis encoders all support at least 8 channels
+ int transcoderChannelLimit = GetAudioEncoder(state) switch
+ {
+ string audioEncoder when audioEncoder.Equals("wmav2", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("libmp3lame", StringComparison.OrdinalIgnoreCase) => 2,
+ string audioEncoder when audioEncoder.Equals("libfdk_aac", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("aac_at", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("ac3", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("eac3", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("dts", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("mlp", StringComparison.OrdinalIgnoreCase)
+ || audioEncoder.Equals("truehd", StringComparison.OrdinalIgnoreCase) => 6,
+ // Set default max transcoding channels to 8 to prevent encoding errors due to asking for too many channels
+ _ => 8,
+ };
- if (isTranscodingAudio && transcoderChannelLimit.HasValue)
- {
- resultChannels = resultChannels.HasValue
- ? Math.Min(resultChannels.Value, transcoderChannelLimit.Value)
- : transcoderChannelLimit.Value;
- }
+ // Set resultChannels to minimum between resultChannels, TranscodingMaxAudioChannels, transcoderChannelLimit
- // Avoid transcoding to audio channels other than 1ch, 2ch, 6ch (5.1 layout) and 8ch (7.1 layout).
- // https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices
- if (isTranscodingAudio
- && state.TranscodingType != TranscodingJobType.Progressive
- && resultChannels.HasValue
- && ((resultChannels.Value > 2 && resultChannels.Value < 6) || resultChannels.Value == 7))
- {
- resultChannels = 2;
- }
-
- return resultChannels;
- }
+ resultChannels = transcoderChannelLimit < resultChannels ? transcoderChannelLimit : resultChannels ?? transcoderChannelLimit;
- private int? GetMinValue(int? val1, int? val2)
- {
- if (!val1.HasValue)
- {
- return val2;
- }
+ if (request.TranscodingMaxAudioChannels < resultChannels)
+ {
+ resultChannels = request.TranscodingMaxAudioChannels;
+ }
- if (!val2.HasValue)
- {
- return val1;
+ // Avoid transcoding to audio channels other than 1ch, 2ch, 6ch (5.1 layout) and 8ch (7.1 layout).
+ // https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices
+ if (state.TranscodingType != TranscodingJobType.Progressive
+ && ((resultChannels > 2 && resultChannels < 6) || resultChannels == 7))
+ {
+ resultChannels = 2;
+ }
}
- return Math.Min(val1.Value, val2.Value);
+ return resultChannels;
}
///
--
cgit v1.2.3
From cb85fc688f84de928e046cb6bd02629f04d68df6 Mon Sep 17 00:00:00 2001
From: Bond_009
Date: Wed, 15 Feb 2023 23:41:28 +0100
Subject: Enable nullable for more files
---
Emby.Server.Implementations/ScheduledTasks/TaskManager.cs | 6 ++----
.../Session/SessionWebSocketListener.cs | 13 ++++++++-----
Emby.Server.Implementations/Sorting/RuntimeComparer.cs | 5 +----
.../Sorting/SeriesSortNameComparer.cs | 7 ++-----
Emby.Server.Implementations/Sorting/SortNameComparer.cs | 5 +----
Emby.Server.Implementations/Sorting/StartDateComparer.cs | 6 ++----
Emby.Server.Implementations/Sorting/StudioComparer.cs | 5 +----
Emby.Server.Implementations/TV/TVSeriesManager.cs | 12 +++++-------
MediaBrowser.Controller/Session/ISessionController.cs | 2 --
MediaBrowser.Model/Tasks/ITaskManager.cs | 4 ++--
10 files changed, 24 insertions(+), 41 deletions(-)
(limited to 'MediaBrowser.Controller')
diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
index 63f0beb10..6dc20e66b 100644
--- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -43,9 +41,9 @@ namespace Emby.Server.Implementations.ScheduledTasks
ScheduledTasks = Array.Empty();
}
- public event EventHandler> TaskExecuting;
+ public event EventHandler>? TaskExecuting;
- public event EventHandler TaskCompleted;
+ public event EventHandler? TaskCompleted;
///
/// Gets the list of Scheduled Tasks.
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index aebb55907..4e427b1a4 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -58,7 +56,7 @@ namespace Emby.Server.Implementations.Session
///
/// The KeepAlive cancellation token.
///
- private CancellationTokenSource _keepAliveCancellationToken;
+ private CancellationTokenSource? _keepAliveCancellationToken;
///
/// Initializes a new instance of the class.
@@ -105,7 +103,7 @@ namespace Emby.Server.Implementations.Session
}
}
- private async Task GetSession(HttpContext httpContext, string remoteEndpoint)
+ private async Task GetSession(HttpContext httpContext, string? remoteEndpoint)
{
if (!httpContext.User.Identity?.IsAuthenticated ?? false)
{
@@ -138,8 +136,13 @@ namespace Emby.Server.Implementations.Session
///
/// The WebSocket.
/// The event arguments.
- private void OnWebSocketClosed(object sender, EventArgs e)
+ private void OnWebSocketClosed(object? sender, EventArgs e)
{
+ if (sender is null)
+ {
+ return;
+ }
+
var webSocket = (IWebSocketConnection)sender;
_logger.LogDebug("WebSocket {0} is closed.", webSocket);
RemoveWebSocket(webSocket);
diff --git a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
index 646bafbb5..753e58324 100644
--- a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
@@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// The x.
/// The y.
/// System.Int32.
- public int Compare(BaseItem x, BaseItem y)
+ public int Compare(BaseItem? x, BaseItem? y)
{
ArgumentNullException.ThrowIfNull(x);
-
ArgumentNullException.ThrowIfNull(y);
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
index 0bd9600b9..5b6c64f63 100644
--- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -23,15 +21,14 @@ namespace Emby.Server.Implementations.Sorting
/// The x.
/// The y.
/// System.Int32.
- public int Compare(BaseItem x, BaseItem y)
+ public int Compare(BaseItem? x, BaseItem? y)
{
return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase);
}
- private static string GetValue(BaseItem item)
+ private static string? GetValue(BaseItem? item)
{
var hasSeries = item as IHasSeries;
-
return hasSeries?.FindSeriesSortName();
}
}
diff --git a/Emby.Server.Implementations/Sorting/SortNameComparer.cs b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
index 628b9b3dd..19abafe19 100644
--- a/Emby.Server.Implementations/Sorting/SortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
@@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// The x.
/// The y.
/// System.Int32.
- public int Compare(BaseItem x, BaseItem y)
+ public int Compare(BaseItem? x, BaseItem? y)
{
ArgumentNullException.ThrowIfNull(x);
-
ArgumentNullException.ThrowIfNull(y);
return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/Sorting/StartDateComparer.cs b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
index c3df7c47e..2759d20de 100644
--- a/Emby.Server.Implementations/Sorting/StartDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -24,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// The x.
/// The y.
/// System.Int32.
- public int Compare(BaseItem x, BaseItem y)
+ public int Compare(BaseItem? x, BaseItem? y)
{
return GetDate(x).CompareTo(GetDate(y));
}
@@ -34,7 +32,7 @@ namespace Emby.Server.Implementations.Sorting
///
/// The x.
/// DateTime.
- private static DateTime GetDate(BaseItem x)
+ private static DateTime GetDate(BaseItem? x)
{
if (x is LiveTvProgram hasStartDate)
{
diff --git a/Emby.Server.Implementations/Sorting/StudioComparer.cs b/Emby.Server.Implementations/Sorting/StudioComparer.cs
index 457c06271..89d10f3d2 100644
--- a/Emby.Server.Implementations/Sorting/StudioComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StudioComparer.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -24,10 +22,9 @@ namespace Emby.Server.Implementations.Sorting
/// The x.
/// The y.
/// System.Int32.
- public int Compare(BaseItem x, BaseItem y)
+ public int Compare(BaseItem? x, BaseItem? y)
{
ArgumentNullException.ThrowIfNull(x);
-
ArgumentNullException.ThrowIfNull(y);
return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());
diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs
index 967f90b55..f0e173f0b 100644
--- a/Emby.Server.Implementations/TV/TVSeriesManager.cs
+++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
@@ -42,7 +40,7 @@ namespace Emby.Server.Implementations.TV
throw new ArgumentException("User not found");
}
- string presentationUniqueKey = null;
+ string? presentationUniqueKey = null;
if (query.SeriesId.HasValue && !query.SeriesId.Value.Equals(default))
{
if (_libraryManager.GetItemById(query.SeriesId.Value) is Series series)
@@ -91,7 +89,7 @@ namespace Emby.Server.Implementations.TV
throw new ArgumentException("User not found");
}
- string presentationUniqueKey = null;
+ string? presentationUniqueKey = null;
int? limit = null;
if (request.SeriesId.HasValue && !request.SeriesId.Value.Equals(default))
{
@@ -168,7 +166,7 @@ namespace Emby.Server.Implementations.TV
return !anyFound && i.LastWatchedDate == DateTime.MinValue;
})
.Select(i => i.GetEpisodeFunction())
- .Where(i => i is not null);
+ .Where(i => i is not null)!;
}
private static string GetUniqueSeriesKey(Episode episode)
@@ -185,7 +183,7 @@ namespace Emby.Server.Implementations.TV
/// Gets the next up.
///
/// Task{Episode}.
- private (DateTime LastWatchedDate, Func GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool rewatching)
+ private (DateTime LastWatchedDate, Func GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool rewatching)
{
var lastQuery = new InternalItemsQuery(user)
{
@@ -209,7 +207,7 @@ namespace Emby.Server.Implementations.TV
var lastWatchedEpisode = _libraryManager.GetItemList(lastQuery).Cast().FirstOrDefault();
- Episode GetEpisode()
+ Episode? GetEpisode()
{
var nextQuery = new InternalItemsQuery(user)
{
diff --git a/MediaBrowser.Controller/Session/ISessionController.cs b/MediaBrowser.Controller/Session/ISessionController.cs
index b38ee1146..c8b29aa1f 100644
--- a/MediaBrowser.Controller/Session/ISessionController.cs
+++ b/MediaBrowser.Controller/Session/ISessionController.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
#pragma warning disable CS1591
using System;
diff --git a/MediaBrowser.Model/Tasks/ITaskManager.cs b/MediaBrowser.Model/Tasks/ITaskManager.cs
index 13bebc479..5b55667e8 100644
--- a/MediaBrowser.Model/Tasks/ITaskManager.cs
+++ b/MediaBrowser.Model/Tasks/ITaskManager.cs
@@ -9,9 +9,9 @@ namespace MediaBrowser.Model.Tasks
{
public interface ITaskManager : IDisposable
{
- event EventHandler> TaskExecuting;
+ event EventHandler>? TaskExecuting;
- event EventHandler TaskCompleted;
+ event EventHandler? TaskCompleted;
///
/// Gets the list of Scheduled Tasks.
--
cgit v1.2.3
From 24a7e210c377bf828f21b5812f25c6545f7de006 Mon Sep 17 00:00:00 2001
From: Bond_009
Date: Sun, 19 Feb 2023 16:52:29 +0100
Subject: Optimize tryparse
* Don't check for null before
* Don't try different formats when not needed (NumberFormat.Integer is the fast path)
---
Emby.Naming/Audio/AlbumParser.cs | 9 ++----
.../Data/SqliteItemRepository.cs | 2 +-
.../LiveTv/Listings/SchedulesDirect.cs | 12 ++++----
.../LiveTv/TunerHosts/M3uParser.cs | 35 ++++++++--------------
.../Extensions/ClaimsPrincipalExtensions.cs | 3 +-
Jellyfin.Api/Helpers/StreamingHelpers.cs | 4 +--
Jellyfin.Api/Helpers/TranscodingJobHelper.cs | 3 +-
Jellyfin.Networking/Manager/NetworkManager.cs | 2 +-
.../Routines/MigrateDisplayPreferencesDb.cs | 2 +-
MediaBrowser.Common/Net/IPHost.cs | 4 +--
MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 12 +++-----
.../MediaEncoding/EncodingHelper.cs | 7 ++---
.../MediaEncoding/EncodingJobInfo.cs | 15 ++++------
MediaBrowser.Controller/MediaEncoding/JobLogger.cs | 8 ++---
.../Parsers/BaseItemXmlParser.cs | 7 ++---
.../Probing/ProbeResultNormalizer.cs | 33 ++++++++------------
MediaBrowser.Model/Dlna/ConditionProcessor.cs | 4 +--
MediaBrowser.Model/Dlna/SortCriteria.cs | 2 +-
MediaBrowser.Model/Dlna/StreamBuilder.cs | 23 +++++++-------
MediaBrowser.Model/Dlna/StreamInfo.cs | 24 +++------------
MediaBrowser.Providers/Manager/MetadataService.cs | 1 -
.../Plugins/Omdb/OmdbProvider.cs | 8 ++---
MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 7 ++---
23 files changed, 83 insertions(+), 144 deletions(-)
(limited to 'MediaBrowser.Controller')
diff --git a/Emby.Naming/Audio/AlbumParser.cs b/Emby.Naming/Audio/AlbumParser.cs
index bbfdccc90..86a564153 100644
--- a/Emby.Naming/Audio/AlbumParser.cs
+++ b/Emby.Naming/Audio/AlbumParser.cs
@@ -3,6 +3,7 @@ using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using Emby.Naming.Common;
+using Jellyfin.Extensions;
namespace Emby.Naming.Audio
{
@@ -58,13 +59,7 @@ namespace Emby.Naming.Audio
var tmp = trimmedFilename.Slice(prefix.Length).Trim();
- int index = tmp.IndexOf(' ');
- if (index != -1)
- {
- tmp = tmp.Slice(0, index);
- }
-
- if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out _))
+ if (int.TryParse(tmp.LeftPart(' '), CultureInfo.InvariantCulture, out _))
{
return true;
}
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 602d2a853..90f03995e 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -1195,7 +1195,7 @@ namespace Emby.Server.Implementations.Data
Path = RestorePath(path.ToString())
};
- if (long.TryParse(dateModified, NumberStyles.Any, CultureInfo.InvariantCulture, out var ticks)
+ if (long.TryParse(dateModified, CultureInfo.InvariantCulture, out var ticks)
&& ticks >= DateTime.MinValue.Ticks
&& ticks <= DateTime.MaxValue.Ticks)
{
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index 3f7914d3b..b5e742f98 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -570,15 +570,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
_tokens.TryAdd(username, savedToken);
}
- if (!string.IsNullOrEmpty(savedToken.Name) && !string.IsNullOrEmpty(savedToken.Value))
+ if (!string.IsNullOrEmpty(savedToken.Name)
+ && long.TryParse(savedToken.Value, CultureInfo.InvariantCulture, out long ticks))
{
- if (long.TryParse(savedToken.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out long ticks))
+ // If it's under 24 hours old we can still use it
+ if (DateTime.UtcNow.Ticks - ticks < TimeSpan.FromHours(20).Ticks)
{
- // If it's under 24 hours old we can still use it
- if (DateTime.UtcNow.Ticks - ticks < TimeSpan.FromHours(20).Ticks)
- {
- return savedToken.Name;
- }
+ return savedToken.Name;
}
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index a423ec8f4..c18cb0074 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -168,28 +168,24 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
string numberString = null;
string attributeValue;
- if (attributes.TryGetValue("tvg-chno", out attributeValue))
+ if (attributes.TryGetValue("tvg-chno", out attributeValue)
+ && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
- {
- numberString = attributeValue;
- }
+ numberString = attributeValue;
}
if (!IsValidChannelNumber(numberString))
{
if (attributes.TryGetValue("tvg-id", out attributeValue))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
numberString = attributeValue;
}
- else if (attributes.TryGetValue("channel-id", out attributeValue))
+ else if (attributes.TryGetValue("channel-id", out attributeValue)
+ && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
- {
- numberString = attributeValue;
- }
+ numberString = attributeValue;
}
}
@@ -207,7 +203,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Slice(0, numberIndex).Trim(new[] { ' ', '.' });
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(numberPart, CultureInfo.InvariantCulture, out _))
{
numberString = numberPart.ToString();
}
@@ -255,19 +251,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private static bool IsValidChannelNumber(string numberString)
{
- if (string.IsNullOrWhiteSpace(numberString) ||
- string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(numberString, "0", StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (string.IsNullOrWhiteSpace(numberString)
+ || string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(numberString, "0", StringComparison.OrdinalIgnoreCase))
{
return false;
}
- return true;
+ return double.TryParse(numberString, CultureInfo.InvariantCulture, out _);
}
private static string GetChannelName(string extInf, Dictionary attributes)
@@ -285,7 +276,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(numberPart, CultureInfo.InvariantCulture, out _))
{
// channel.Number = number.ToString();
nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
diff --git a/Jellyfin.Api/Extensions/ClaimsPrincipalExtensions.cs b/Jellyfin.Api/Extensions/ClaimsPrincipalExtensions.cs
index 6b3e78d4d..d2e8eb378 100644
--- a/Jellyfin.Api/Extensions/ClaimsPrincipalExtensions.cs
+++ b/Jellyfin.Api/Extensions/ClaimsPrincipalExtensions.cs
@@ -71,8 +71,7 @@ public static class ClaimsPrincipalExtensions
public static bool GetIsApiKey(this ClaimsPrincipal user)
{
var claimValue = GetClaimValue(user, InternalClaimTypes.IsApiKey);
- return !string.IsNullOrEmpty(claimValue)
- && bool.TryParse(claimValue, out var parsedClaimValue)
+ return bool.TryParse(claimValue, out var parsedClaimValue)
&& parsedClaimValue;
}
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index d867df86e..9b5a14c4d 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -337,10 +337,10 @@ public static class StreamingHelpers
value = index == -1
? value.Slice(npt.Length)
: value.Slice(npt.Length, index - npt.Length);
- if (value.IndexOf(':') == -1)
+ if (!value.Contains(':'))
{
// Parses npt times in the format of '417.33'
- if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds))
+ if (double.TryParse(value, CultureInfo.InvariantCulture, out var seconds))
{
return TimeSpan.FromSeconds(seconds).Ticks;
}
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index 12960f87a..cd8ac4982 100644
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@ -457,8 +457,7 @@ public class TranscodingJobHelper : IDisposable
var videoCodec = state.ActualOutputVideoCodec;
var hardwareAccelerationTypeString = _serverConfigurationManager.GetEncodingOptions().HardwareAccelerationType;
HardwareEncodingType? hardwareAccelerationType = null;
- if (!string.IsNullOrEmpty(hardwareAccelerationTypeString)
- && Enum.TryParse(hardwareAccelerationTypeString, out var parsedHardwareAccelerationType))
+ if (Enum.TryParse(hardwareAccelerationTypeString, out var parsedHardwareAccelerationType))
{
hardwareAccelerationType = parsedHardwareAccelerationType;
}
diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.cs
index 86989bfde..88332ce39 100644
--- a/Jellyfin.Networking/Manager/NetworkManager.cs
+++ b/Jellyfin.Networking/Manager/NetworkManager.cs
@@ -316,7 +316,7 @@ namespace Jellyfin.Networking.Manager
///
public string GetBindInterface(string source, out int? port)
{
- if (!string.IsNullOrEmpty(source) && IPHost.TryParse(source, out IPHost host))
+ if (IPHost.TryParse(source, out IPHost host))
{
return GetBindInterface(host, out port);
}
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
index 4b692d14f..7c4ffdbc0 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
@@ -130,7 +130,7 @@ namespace Jellyfin.Server.Migrations.Routines
SkipForwardLength = dto.CustomPrefs.TryGetValue("skipForwardLength", out var length) && int.TryParse(length, out var skipForwardLength)
? skipForwardLength
: 30000,
- SkipBackwardLength = dto.CustomPrefs.TryGetValue("skipBackLength", out length) && !string.IsNullOrEmpty(length) && int.TryParse(length, out var skipBackwardLength)
+ SkipBackwardLength = dto.CustomPrefs.TryGetValue("skipBackLength", out length) && int.TryParse(length, out var skipBackwardLength)
? skipBackwardLength
: 10000,
EnableNextVideoInfoOverlay = dto.CustomPrefs.TryGetValue("enableNextVideoInfoOverlay", out var enabled) && !string.IsNullOrEmpty(enabled)
diff --git a/MediaBrowser.Common/Net/IPHost.cs b/MediaBrowser.Common/Net/IPHost.cs
index 7cf1b8aa0..ec76a43b6 100644
--- a/MediaBrowser.Common/Net/IPHost.cs
+++ b/MediaBrowser.Common/Net/IPHost.cs
@@ -190,7 +190,7 @@ namespace MediaBrowser.Common.Net
/// Object representing the string, if it has successfully been parsed.
public static IPHost Parse(string host)
{
- if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res))
+ if (IPHost.TryParse(host, out IPHost res))
{
return res;
}
@@ -206,7 +206,7 @@ namespace MediaBrowser.Common.Net
/// Object representing the string, if it has successfully been parsed.
public static IPHost Parse(string host, AddressFamily family)
{
- if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res))
+ if (IPHost.TryParse(host, out IPHost res))
{
if (family == AddressFamily.InterNetwork)
{
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index 978826042..f11e3c8f6 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.Linq;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
@@ -105,12 +106,9 @@ namespace MediaBrowser.Controller.LiveTv
protected override string CreateSortName()
{
- if (!string.IsNullOrEmpty(Number))
+ if (double.TryParse(Number, CultureInfo.InvariantCulture, out double number))
{
- if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out double number))
- {
- return string.Format(CultureInfo.InvariantCulture, "{0:00000.0}", number) + "-" + (Name ?? string.Empty);
- }
+ return string.Format(CultureInfo.InvariantCulture, "{0:00000.0}", number) + "-" + (Name ?? string.Empty);
}
return (Number ?? string.Empty) + "-" + (Name ?? string.Empty);
@@ -122,9 +120,7 @@ namespace MediaBrowser.Controller.LiveTv
}
public IEnumerable GetTaggedItems()
- {
- return new List();
- }
+ => Enumerable.Empty();
public override List GetMediaSources(bool enablePathSubstitution)
{
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 14547d440..11b17eec3 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -1143,7 +1143,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public static string NormalizeTranscodingLevel(EncodingJobInfo state, string level)
{
- if (double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out double requestLevel))
+ if (double.TryParse(level, CultureInfo.InvariantCulture, out double requestLevel))
{
if (string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
|| string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase))
@@ -1737,7 +1737,7 @@ namespace MediaBrowser.Controller.MediaEncoding
else if (string.Equals(videoEncoder, "hevc_qsv", StringComparison.OrdinalIgnoreCase))
{
// hevc_qsv use -level 51 instead of -level 153.
- if (double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out double hevcLevel))
+ if (double.TryParse(level, CultureInfo.InvariantCulture, out double hevcLevel))
{
param += " -level " + (hevcLevel / 3);
}
@@ -1916,8 +1916,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// If a specific level was requested, the source must match or be less than
var level = state.GetRequestedLevel(videoStream.Codec);
- if (!string.IsNullOrEmpty(level)
- && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var requestLevel))
+ if (double.TryParse(level, CultureInfo.InvariantCulture, out var requestLevel))
{
if (!videoStream.Level.HasValue)
{
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
index 179cabc84..a6b541660 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
@@ -250,8 +250,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var level = GetRequestedLevel(ActualOutputVideoCodec);
- if (!string.IsNullOrEmpty(level)
- && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (double.TryParse(level, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -645,8 +644,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(codec))
{
var value = BaseRequest.GetOption(codec, "maxrefframes");
- if (!string.IsNullOrEmpty(value)
- && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -665,8 +663,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(codec))
{
var value = BaseRequest.GetOption(codec, "videobitdepth");
- if (!string.IsNullOrEmpty(value)
- && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -685,8 +682,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(codec))
{
var value = BaseRequest.GetOption(codec, "audiobitdepth");
- if (!string.IsNullOrEmpty(value)
- && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -700,8 +696,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(codec))
{
var value = BaseRequest.GetOption(codec, "audiochannels");
- if (!string.IsNullOrEmpty(value)
- && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
index d8475f12a..3b34af4e9 100644
--- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
+++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs
@@ -86,7 +86,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var rate = parts[i + 1];
- if (float.TryParse(rate, NumberStyles.Any, CultureInfo.InvariantCulture, out var val))
+ if (float.TryParse(rate, CultureInfo.InvariantCulture, out var val))
{
framerate = val;
}
@@ -95,7 +95,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var rate = part.Split('=', 2)[^1];
- if (float.TryParse(rate, NumberStyles.Any, CultureInfo.InvariantCulture, out var val))
+ if (float.TryParse(rate, CultureInfo.InvariantCulture, out var val))
{
framerate = val;
}
@@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (scale.HasValue)
{
- if (long.TryParse(size, NumberStyles.Any, CultureInfo.InvariantCulture, out var val))
+ if (long.TryParse(size, CultureInfo.InvariantCulture, out var val))
{
bytesTranscoded = val * scale.Value;
}
@@ -146,7 +146,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (scale.HasValue)
{
- if (float.TryParse(rate, NumberStyles.Any, CultureInfo.InvariantCulture, out var val))
+ if (float.TryParse(rate, CultureInfo.InvariantCulture, out var val))
{
bitRate = (int)Math.Ceiling(val * scale.Value);
}
diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
index 1030cf055..c8912807e 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
@@ -169,12 +169,9 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
var text = reader.ReadElementContentAsString();
- if (!string.IsNullOrEmpty(text))
+ if (float.TryParse(text, CultureInfo.InvariantCulture, out var value))
{
- if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
- {
- item.CriticRating = value;
- }
+ item.CriticRating = value;
}
break;
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 99310a75d..8b8279588 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -97,12 +97,9 @@ namespace MediaBrowser.MediaEncoding.Probing
{
info.Container = NormalizeFormat(data.Format.FormatName);
- if (!string.IsNullOrEmpty(data.Format.BitRate))
+ if (int.TryParse(data.Format.BitRate, CultureInfo.InvariantCulture, out var value))
{
- if (int.TryParse(data.Format.BitRate, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
- {
- info.Bitrate = value;
- }
+ info.Bitrate = value;
}
}
@@ -561,8 +558,8 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- if (string.IsNullOrWhiteSpace(name) ||
- string.IsNullOrWhiteSpace(value))
+ if (string.IsNullOrWhiteSpace(name)
+ || string.IsNullOrWhiteSpace(value))
{
return null;
}
@@ -674,9 +671,9 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.Channels = streamInfo.Channels;
- if (int.TryParse(streamInfo.SampleRate, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
+ if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
{
- stream.SampleRate = value;
+ stream.SampleRate = sampleRate;
}
stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
@@ -853,22 +850,18 @@ namespace MediaBrowser.MediaEncoding.Probing
// Get stream bitrate
var bitrate = 0;
- if (!string.IsNullOrEmpty(streamInfo.BitRate))
+ if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
{
- if (int.TryParse(streamInfo.BitRate, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
- {
- bitrate = value;
- }
+ bitrate = value;
}
// The bitrate info of FLAC musics and some videos is included in formatInfo.
if (bitrate == 0
&& formatInfo is not null
- && !string.IsNullOrEmpty(formatInfo.BitRate)
&& (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
{
// If the stream info doesn't have a bitrate get the value from the media format info
- if (int.TryParse(formatInfo.BitRate, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
+ if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
{
bitrate = value;
}
@@ -972,8 +965,8 @@ namespace MediaBrowser.MediaEncoding.Probing
var parts = (original ?? string.Empty).Split(':');
if (!(parts.Length == 2
- && int.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out var width)
- && int.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var height)
+ && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
+ && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
&& width > 0
&& height > 0))
{
@@ -1117,7 +1110,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "DURATION");
- if (!string.IsNullOrEmpty(duration) && TimeSpan.TryParse(duration, out var parsedDuration))
+ if (TimeSpan.TryParse(duration, out var parsedDuration))
{
return parsedDuration.TotalSeconds;
}
@@ -1446,7 +1439,7 @@ namespace MediaBrowser.MediaEncoding.Probing
// Limit accuracy to milliseconds to match xml saving
var secondsString = chapter.StartTime;
- if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds))
+ if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
{
var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
index 573422416..00b406bbe 100644
--- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs
+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
@@ -136,7 +136,7 @@ namespace MediaBrowser.Model.Dlna
return !condition.IsRequired;
}
- if (int.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
+ if (int.TryParse(condition.Value, CultureInfo.InvariantCulture, out var expected))
{
switch (condition.Condition)
{
@@ -212,7 +212,7 @@ namespace MediaBrowser.Model.Dlna
return !condition.IsRequired;
}
- if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
+ if (double.TryParse(condition.Value, CultureInfo.InvariantCulture, out var expected))
{
switch (condition.Condition)
{
diff --git a/MediaBrowser.Model/Dlna/SortCriteria.cs b/MediaBrowser.Model/Dlna/SortCriteria.cs
index 7fef16e53..7df53c6d1 100644
--- a/MediaBrowser.Model/Dlna/SortCriteria.cs
+++ b/MediaBrowser.Model/Dlna/SortCriteria.cs
@@ -9,7 +9,7 @@ namespace MediaBrowser.Model.Dlna
{
public SortCriteria(string sortOrder)
{
- if (!string.IsNullOrEmpty(sortOrder) && Enum.TryParse(sortOrder, true, out var sortOrderValue))
+ if (Enum.TryParse(sortOrder, true, out var sortOrderValue))
{
SortOrder = sortOrderValue;
}
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index eb6d60295..ab81bfb34 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -551,8 +551,7 @@ namespace MediaBrowser.Model.Dlna
}
playlistItem.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;
- if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels)
- && int.TryParse(transcodingProfile.MaxAudioChannels, NumberStyles.Any, CultureInfo.InvariantCulture, out int transcodingMaxAudioChannels))
+ if (int.TryParse(transcodingProfile.MaxAudioChannels, CultureInfo.InvariantCulture, out int transcodingMaxAudioChannels))
{
playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels;
}
@@ -1607,7 +1606,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1633,7 +1632,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1669,7 +1668,7 @@ namespace MediaBrowser.Model.Dlna
}
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1793,7 +1792,7 @@ namespace MediaBrowser.Model.Dlna
}
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1829,7 +1828,7 @@ namespace MediaBrowser.Model.Dlna
}
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1919,7 +1918,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1945,7 +1944,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1971,7 +1970,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (float.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -1997,7 +1996,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
@@ -2023,7 +2022,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs
index 3b5509907..93ace43df 100644
--- a/MediaBrowser.Model/Dlna/StreamInfo.cs
+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs
@@ -922,12 +922,8 @@ namespace MediaBrowser.Model.Dlna
public int? GetTargetVideoBitDepth(string codec)
{
var value = GetOption(codec, "videobitdepth");
- if (string.IsNullOrEmpty(value))
- {
- return null;
- }
- if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -938,12 +934,8 @@ namespace MediaBrowser.Model.Dlna
public int? GetTargetAudioBitDepth(string codec)
{
var value = GetOption(codec, "audiobitdepth");
- if (string.IsNullOrEmpty(value))
- {
- return null;
- }
- if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -954,12 +946,8 @@ namespace MediaBrowser.Model.Dlna
public double? GetTargetVideoLevel(string codec)
{
var value = GetOption(codec, "level");
- if (string.IsNullOrEmpty(value))
- {
- return null;
- }
- if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (double.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
@@ -970,12 +958,8 @@ namespace MediaBrowser.Model.Dlna
public int? GetTargetRefFrames(string codec)
{
var value = GetOption(codec, "maxrefframes");
- if (string.IsNullOrEmpty(value))
- {
- return null;
- }
- if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
+ if (int.TryParse(value, CultureInfo.InvariantCulture, out var result))
{
return result;
}
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index 9f287766a..0605b0bd7 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -151,7 +151,6 @@ namespace MediaBrowser.Providers.Manager
ApplySearchResult(id, refreshOptions.SearchResult);
}
- // await FindIdentities(id, cancellationToken).ConfigureAwait(false);
id.IsAutomated = refreshOptions.IsAutomated;
var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, ImageProvider, cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
index 497437bd8..dfaba6423 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
@@ -98,8 +98,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
// item.VoteCount = voteCount;
}
- if (!string.IsNullOrEmpty(result.imdbRating)
- && float.TryParse(result.imdbRating, NumberStyles.Any, CultureInfo.InvariantCulture, out var imdbRating)
+ if (float.TryParse(result.imdbRating, CultureInfo.InvariantCulture, out var imdbRating)
&& imdbRating >= 0)
{
item.CommunityRating = imdbRating;
@@ -209,8 +208,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
// item.VoteCount = voteCount;
}
- if (!string.IsNullOrEmpty(result.imdbRating)
- && float.TryParse(result.imdbRating, NumberStyles.Any, CultureInfo.InvariantCulture, out var imdbRating)
+ if (float.TryParse(result.imdbRating, CultureInfo.InvariantCulture, out var imdbRating)
&& imdbRating >= 0)
{
item.CommunityRating = imdbRating;
@@ -552,7 +550,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
if (rating?.Value is not null)
{
var value = rating.Value.TrimEnd('%');
- if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var score))
+ if (float.TryParse(value, CultureInfo.InvariantCulture, out var score))
{
return score;
}
diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
index c3a735c6d..159b8d658 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
@@ -315,12 +315,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
var text = reader.ReadElementContentAsString();
- if (!string.IsNullOrEmpty(text))
+ if (float.TryParse(text, CultureInfo.InvariantCulture, out var value))
{
- if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
- {
- item.CriticRating = value;
- }
+ item.CriticRating = value;
}
break;
--
cgit v1.2.3