mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-18 05:30:34 +01:00
Merge pull request #9356 from Bond-009/tryparse
This commit is contained in:
@@ -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<BaseItem> GetTaggedItems()
|
||||
{
|
||||
return new List<BaseItem>();
|
||||
}
|
||||
=> Enumerable.Empty<BaseItem>();
|
||||
|
||||
public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user