diff options
8 files changed, 25 insertions, 24 deletions
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index f51657c63..e4221dd50 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -139,13 +139,13 @@ namespace Emby.Server.Implementations.Library return list .OrderBy(i => { - var index = orders.IndexOf(i.Id.ToString("N", CultureInfo.InvariantCulture)); + var index = orders.IndexOf(i.Id.ToString("D", CultureInfo.InvariantCulture)); if (index == -1 && i is UserView view && view.DisplayParentId != Guid.Empty) { - index = orders.IndexOf(view.DisplayParentId.ToString("N", CultureInfo.InvariantCulture)); + index = orders.IndexOf(view.DisplayParentId.ToString("D", CultureInfo.InvariantCulture)); } return index == -1 ? int.MaxValue : index; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 8c9bb6ba0..7842be716 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1928,7 +1928,7 @@ namespace Emby.Server.Implementations.LiveTv foreach (var programDto in currentProgramDtos) { - if (currentChannelsDict.TryGetValue(programDto.ChannelId, out BaseItemDto channelDto)) + if (programDto.ChannelId.HasValue && currentChannelsDict.TryGetValue(programDto.ChannelId.Value, out BaseItemDto channelDto)) { channelDto.CurrentProgram = programDto; } @@ -2018,7 +2018,7 @@ namespace Emby.Server.Implementations.LiveTv info.DayPattern = _tvDtoService.GetDayPattern(info.Days); info.Name = program.Name; - info.ChannelId = programDto.ChannelId; + info.ChannelId = programDto.ChannelId ?? Guid.Empty; info.ChannelName = programDto.ChannelName; info.StartDate = program.StartDate; info.Name = program.Name; diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 97ef18939..1329084b6 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -342,10 +342,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun public string URL { get; set; } - [JsonConverter(typeof(JsonBoolNumberConverter))] public bool Favorite { get; set; } - [JsonConverter(typeof(JsonBoolNumberConverter))] public bool DRM { get; set; } public int HD { get; set; } diff --git a/MediaBrowser.Common/Json/Converters/JsonBoolNumberConverter.cs b/MediaBrowser.Common/Json/Converters/JsonBoolNumberConverter.cs index cb2047049..b29e6a71a 100644 --- a/MediaBrowser.Common/Json/Converters/JsonBoolNumberConverter.cs +++ b/MediaBrowser.Common/Json/Converters/JsonBoolNumberConverter.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Common.Json.Converters /// <inheritdoc /> public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) { - JsonSerializer.Serialize(writer, value, options); + writer.WriteBooleanValue(value); } } }
\ No newline at end of file diff --git a/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs b/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs index 52e08d071..ccf214e3c 100644 --- a/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs +++ b/MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs @@ -13,21 +13,13 @@ namespace MediaBrowser.Common.Json.Converters public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var guidStr = reader.GetString(); - return guidStr == null ? Guid.Empty : new Guid(guidStr); } /// <inheritdoc /> public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) { - if (value == Guid.Empty) - { - writer.WriteNullValue(); - } - else - { - writer.WriteStringValue(value); - } + writer.WriteStringValue(value); } } } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index fac754177..3f7aac9cd 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -152,7 +152,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the channel identifier. /// </summary> /// <value>The channel identifier.</value> - public Guid ChannelId { get; set; } + public Guid? ChannelId { get; set; } public string ChannelName { get; set; } @@ -270,7 +270,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the parent id. /// </summary> /// <value>The parent id.</value> - public Guid ParentId { get; set; } + public Guid? ParentId { get; set; } /// <summary> /// Gets or sets the type. @@ -344,13 +344,13 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the series id. /// </summary> /// <value>The series id.</value> - public Guid SeriesId { get; set; } + public Guid? SeriesId { get; set; } /// <summary> /// Gets or sets the season identifier. /// </summary> /// <value>The season identifier.</value> - public Guid SeasonId { get; set; } + public Guid? SeasonId { get; set; } /// <summary> /// Gets or sets the special feature count. @@ -428,7 +428,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the album id. /// </summary> /// <value>The album id.</value> - public Guid AlbumId { get; set; } + public Guid? AlbumId { get; set; } /// <summary> /// Gets or sets the album image tag. diff --git a/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs b/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs index 3779e2d0a..9ded01f2b 100644 --- a/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs +++ b/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs @@ -19,5 +19,16 @@ namespace Jellyfin.Common.Tests.Json var value = JsonSerializer.Deserialize<bool>(input, options); Assert.Equal(value, output); } + + [Theory] + [InlineData(true, "true")] + [InlineData(false, "false")] + public static void Serialize_Bool_Success(bool input, string output) + { + var options = new JsonSerializerOptions(); + options.Converters.Add(new JsonBoolNumberConverter()); + var value = JsonSerializer.Serialize(input, options); + Assert.Equal(value, output); + } } }
\ No newline at end of file diff --git a/tests/Jellyfin.Common.Tests/Json/JsonGuidConverterTests.cs b/tests/Jellyfin.Common.Tests/Json/JsonGuidConverterTests.cs index 3c94db491..663cc3c78 100644 --- a/tests/Jellyfin.Common.Tests/Json/JsonGuidConverterTests.cs +++ b/tests/Jellyfin.Common.Tests/Json/JsonGuidConverterTests.cs @@ -3,7 +3,7 @@ using System.Text.Json; using MediaBrowser.Common.Json.Converters; using Xunit; -namespace Jellyfin.Common.Tests.Extensions +namespace Jellyfin.Common.Tests.Json { public class JsonGuidConverterTests { @@ -44,9 +44,9 @@ namespace Jellyfin.Common.Tests.Extensions } [Fact] - public void Serialize_EmptyGuid_Null() + public void Serialize_EmptyGuid_EmptyGuid() { - Assert.Equal("null", JsonSerializer.Serialize(Guid.Empty, _options)); + Assert.Equal($"\"{Guid.Empty}\"", JsonSerializer.Serialize(Guid.Empty, _options)); } } } |
