From de98457332a1e25d38553dd11403704372213e15 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Wed, 17 Aug 2022 20:14:07 +0200 Subject: [PATCH] Fix operation name in SearchController and correct nullability for SearchHint --- Jellyfin.Api/Controllers/SearchController.cs | 8 ++- MediaBrowser.Model/Search/SearchHint.cs | 66 +++++++++++++++----- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs index 07e113ad3..138d8b8df 100644 --- a/Jellyfin.Api/Controllers/SearchController.cs +++ b/Jellyfin.Api/Controllers/SearchController.cs @@ -79,7 +79,7 @@ namespace Jellyfin.Api.Controllers [HttpGet] [Description("Gets search hints based on a search term")] [ProducesResponseType(StatusCodes.Status200OK)] - public ActionResult Get( + public ActionResult GetSearchHints( [FromQuery] int? startIndex, [FromQuery] int? limit, [FromQuery] Guid? userId, @@ -140,7 +140,7 @@ namespace Jellyfin.Api.Controllers IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, Id = item.Id, - Type = item.GetClientTypeName(), + Type = item.GetBaseItemKind(), MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, RunTimeTicks = item.RunTimeTicks, @@ -149,8 +149,10 @@ namespace Jellyfin.Api.Controllers EndDate = item.EndDate }; - // legacy +#pragma warning disable CS0618 + // Kept for compatibility with older clients result.ItemId = result.Id; +#pragma warning restore CS0618 if (item.IsFolder) { diff --git a/MediaBrowser.Model/Search/SearchHint.cs b/MediaBrowser.Model/Search/SearchHint.cs index 983dbd2bc..4696c3797 100644 --- a/MediaBrowser.Model/Search/SearchHint.cs +++ b/MediaBrowser.Model/Search/SearchHint.cs @@ -1,8 +1,6 @@ -#nullable disable -#pragma warning disable CS1591 - using System; using System.Collections.Generic; +using Jellyfin.Data.Enums; namespace MediaBrowser.Model.Search { @@ -11,12 +9,28 @@ namespace MediaBrowser.Model.Search /// public class SearchHint { + /// + /// Initializes a new instance of the class. + /// + public SearchHint() + { + Name = string.Empty; + MatchedTerm = string.Empty; + MediaType = string.Empty; + Artists = Array.Empty(); + } + /// /// Gets or sets the item id. /// /// The item id. + [Obsolete("Use Id instead")] public Guid ItemId { get; set; } + /// + /// Gets or sets the item id. + /// + /// The item id. public Guid Id { get; set; } /// @@ -53,38 +67,42 @@ namespace MediaBrowser.Model.Search /// Gets or sets the image tag. /// /// The image tag. - public string PrimaryImageTag { get; set; } + public string? PrimaryImageTag { get; set; } /// /// Gets or sets the thumb image tag. /// /// The thumb image tag. - public string ThumbImageTag { get; set; } + public string? ThumbImageTag { get; set; } /// /// Gets or sets the thumb image item identifier. /// /// The thumb image item identifier. - public string ThumbImageItemId { get; set; } + public string? ThumbImageItemId { get; set; } /// /// Gets or sets the backdrop image tag. /// /// The backdrop image tag. - public string BackdropImageTag { get; set; } + public string? BackdropImageTag { get; set; } /// /// Gets or sets the backdrop image item identifier. /// /// The backdrop image item identifier. - public string BackdropImageItemId { get; set; } + public string? BackdropImageItemId { get; set; } /// /// Gets or sets the type. /// /// The type. - public string Type { get; set; } + public BaseItemKind Type { get; set; } + /// + /// Gets a value indicating whether this instance is folder. + /// + /// true if this instance is folder; otherwise, false. public bool? IsFolder { get; set; } /// @@ -99,31 +117,47 @@ namespace MediaBrowser.Model.Search /// The type of the media. public string MediaType { get; set; } + /// + /// Gets or sets the start date. + /// + /// The start date. public DateTime? StartDate { get; set; } + /// + /// Gets or sets the end date. + /// + /// The end date. public DateTime? EndDate { get; set; } /// /// Gets or sets the series. /// /// The series. - public string Series { get; set; } + public string? Series { get; set; } - public string Status { get; set; } + /// + /// Gets or sets the status. + /// + /// The status. + public string? Status { get; set; } /// /// Gets or sets the album. /// /// The album. - public string Album { get; set; } + public string? Album { get; set; } - public Guid AlbumId { get; set; } + /// + /// Gets or sets the album id. + /// + /// The album id. + public Guid? AlbumId { get; set; } /// /// Gets or sets the album artist. /// /// The album artist. - public string AlbumArtist { get; set; } + public string? AlbumArtist { get; set; } /// /// Gets or sets the artists. @@ -147,13 +181,13 @@ namespace MediaBrowser.Model.Search /// Gets or sets the channel identifier. /// /// The channel identifier. - public Guid ChannelId { get; set; } + public Guid? ChannelId { get; set; } /// /// Gets or sets the name of the channel. /// /// The name of the channel. - public string ChannelName { get; set; } + public string? ChannelName { get; set; } /// /// Gets or sets the primary image aspect ratio.