Ver Fonte

Use JsonConverter

crobibero há 4 anos atrás
pai
commit
36bae6f030

+ 1 - 2
Jellyfin.Api/Controllers/LiveTvController.cs

@@ -661,9 +661,8 @@ namespace Jellyfin.Api.Controllers
                 }
                 }
             }
             }
 
 
-            var fields = RequestHelpers.GetItemFields(body.Fields);
             var dtoOptions = new DtoOptions()
             var dtoOptions = new DtoOptions()
-                .AddItemFields(fields)
+                .AddItemFields(body.Fields)
                 .AddClientFields(Request)
                 .AddClientFields(Request)
                 .AddAdditionalDtoOptions(body.EnableImages, body.EnableUserData, body.ImageTypeLimit, body.EnableImageTypes);
                 .AddAdditionalDtoOptions(body.EnableImages, body.EnableUserData, body.ImageTypeLimit, body.EnableImageTypes);
             return await _liveTvManager.GetPrograms(query, dtoOptions, CancellationToken.None).ConfigureAwait(false);
             return await _liveTvManager.GetPrograms(query, dtoOptions, CancellationToken.None).ConfigureAwait(false);

+ 0 - 29
Jellyfin.Api/Helpers/RequestHelpers.cs

@@ -1,12 +1,9 @@
 using System;
 using System;
-using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
-using System.Net;
 using Jellyfin.Data.Enums;
 using Jellyfin.Data.Enums;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Controller.Net;
 using MediaBrowser.Controller.Net;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.Controller.Session;
-using MediaBrowser.Model.Querying;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 
 
 namespace Jellyfin.Api.Helpers
 namespace Jellyfin.Api.Helpers
@@ -135,31 +132,5 @@ namespace Jellyfin.Api.Helpers
                 .Select(i => new Guid(i))
                 .Select(i => new Guid(i))
                 .ToArray();
                 .ToArray();
         }
         }
-
-        /// <summary>
-        /// Gets the item fields.
-        /// </summary>
-        /// <param name="fields">The fields string.</param>
-        /// <returns>IEnumerable{ItemFields}.</returns>
-        internal static ItemFields[] GetItemFields(string? fields)
-        {
-            if (string.IsNullOrEmpty(fields))
-            {
-                return Array.Empty<ItemFields>();
-            }
-
-            return Split(fields, ',', true)
-                .Select(v =>
-                {
-                    if (Enum.TryParse(v, true, out ItemFields value))
-                    {
-                        return (ItemFields?)value;
-                    }
-
-                    return null;
-                }).Where(i => i.HasValue)
-                .Select(i => i!.Value)
-                .ToArray();
-        }
     }
     }
 }
 }

+ 7 - 1
Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs

@@ -1,4 +1,8 @@
 using System;
 using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
+using MediaBrowser.Common.Json.Converters;
+using MediaBrowser.Model.Querying;
 
 
 namespace Jellyfin.Api.Models.LiveTvDtos
 namespace Jellyfin.Api.Models.LiveTvDtos
 {
 {
@@ -161,6 +165,8 @@ namespace Jellyfin.Api.Models.LiveTvDtos
         /// Gets or sets specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.
         /// Gets or sets specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.
         /// Optional.
         /// Optional.
         /// </summary>
         /// </summary>
-        public string? Fields { get; set; }
+        [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+        [SuppressMessage("Microsoft.Performance", "CA1819:ReturnArrays", MessageId = "Fields", Justification = "Imported from ServiceStack")]
+        public ItemFields[] Fields { get; set; } = Array.Empty<ItemFields>();
     }
     }
 }
 }