Merge pull request #4633 from crobibero/guid-params
Use Guid as API parameter type where possible
This commit is contained in:
commit
e042572588
|
@ -540,18 +540,18 @@ namespace Emby.Server.Implementations.Channels
|
|||
{
|
||||
IncludeItemTypes = new[] { nameof(Channel) },
|
||||
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) }
|
||||
}).Select(i => GetChannelFeatures(i.ToString("N", CultureInfo.InvariantCulture))).ToArray();
|
||||
}).Select(i => GetChannelFeatures(i)).ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ChannelFeatures GetChannelFeatures(string id)
|
||||
public ChannelFeatures GetChannelFeatures(Guid? id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
if (!id.HasValue)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
var channel = GetChannel(id);
|
||||
var channel = GetChannel(id.Value);
|
||||
var channelProvider = GetChannelProvider(channel);
|
||||
|
||||
return GetChannelFeaturesDto(channel, channelProvider, channelProvider.GetChannelFeatures());
|
||||
|
|
|
@ -2462,9 +2462,19 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
public BaseItem GetParentItem(string parentId, Guid? userId)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(parentId))
|
||||
if (string.IsNullOrEmpty(parentId))
|
||||
{
|
||||
return GetItemById(new Guid(parentId));
|
||||
return GetParentItem((Guid?)null, userId);
|
||||
}
|
||||
|
||||
return GetParentItem(new Guid(parentId), userId);
|
||||
}
|
||||
|
||||
public BaseItem GetParentItem(Guid? parentId, Guid? userId)
|
||||
{
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
return GetItemById(parentId.Value);
|
||||
}
|
||||
|
||||
if (userId.HasValue && userId != Guid.Empty)
|
||||
|
|
|
@ -156,8 +156,8 @@ namespace Emby.Server.Implementations.Library
|
|||
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
||||
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||
Limit = query.Limit,
|
||||
IncludeItemsByName = string.IsNullOrEmpty(query.ParentId),
|
||||
ParentId = string.IsNullOrEmpty(query.ParentId) ? Guid.Empty : new Guid(query.ParentId),
|
||||
IncludeItemsByName = !query.ParentId.HasValue,
|
||||
ParentId = query.ParentId ?? Guid.Empty,
|
||||
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) },
|
||||
Recursive = true,
|
||||
|
||||
|
|
|
@ -56,13 +56,11 @@ namespace Emby.Server.Implementations.TV
|
|||
return GetResult(GetNextUpEpisodes(request, user, new[] { presentationUniqueKey }, dtoOptions), request);
|
||||
}
|
||||
|
||||
var parentIdGuid = string.IsNullOrEmpty(request.ParentId) ? (Guid?)null : new Guid(request.ParentId);
|
||||
|
||||
BaseItem[] parents;
|
||||
|
||||
if (parentIdGuid.HasValue)
|
||||
if (request.ParentId.HasValue)
|
||||
{
|
||||
var parent = _libraryManager.GetItemById(parentIdGuid.Value);
|
||||
var parent = _libraryManager.GetItemById(request.ParentId.Value);
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations;
|
|||
using System.Linq;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Api.Extensions;
|
||||
using Jellyfin.Api.Helpers;
|
||||
using Jellyfin.Api.ModelBinders;
|
||||
using Jellyfin.Data.Entities;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
|
@ -87,7 +86,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -119,16 +118,11 @@ namespace Jellyfin.Api.Controllers
|
|||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||
|
||||
User? user = null;
|
||||
BaseItem parentItem;
|
||||
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
|
||||
|
||||
if (userId.HasValue && !userId.Equals(Guid.Empty))
|
||||
{
|
||||
user = _userManager.GetUserById(userId.Value);
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.RootFolder : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
|
@ -157,15 +151,15 @@ namespace Jellyfin.Api.Controllers
|
|||
EnableTotalRecordCount = enableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(parentId) };
|
||||
query.AncestorIds = new[] { parentId.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(parentId) };
|
||||
query.ItemIds = new[] { parentId.Value };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +285,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -323,16 +317,11 @@ namespace Jellyfin.Api.Controllers
|
|||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||
|
||||
User? user = null;
|
||||
BaseItem parentItem;
|
||||
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
|
||||
|
||||
if (userId.HasValue && !userId.Equals(Guid.Empty))
|
||||
{
|
||||
user = _userManager.GetUserById(userId.Value);
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.RootFolder : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
|
@ -361,15 +350,15 @@ namespace Jellyfin.Api.Controllers
|
|||
EnableTotalRecordCount = enableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(parentId) };
|
||||
query.AncestorIds = new[] { parentId.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(parentId) };
|
||||
query.ItemIds = new[] { parentId.Value };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <response code="200">Channel features returned.</response>
|
||||
/// <returns>An <see cref="OkResult"/> containing the channel features.</returns>
|
||||
[HttpGet("{channelId}/Features")]
|
||||
public ActionResult<ChannelFeatures> GetChannelFeatures([FromRoute, Required] string channelId)
|
||||
public ActionResult<ChannelFeatures> GetChannelFeatures([FromRoute, Required] Guid channelId)
|
||||
{
|
||||
return _channelManager.GetChannelFeatures(channelId);
|
||||
}
|
||||
|
|
|
@ -50,33 +50,24 @@ namespace Jellyfin.Api.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<QueryFiltersLegacy> GetQueryFiltersLegacy(
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes)
|
||||
{
|
||||
var parentItem = string.IsNullOrEmpty(parentId)
|
||||
? null
|
||||
: _libraryManager.GetItemById(parentId);
|
||||
|
||||
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
||||
? _userManager.GetUserById(userId.Value)
|
||||
: null;
|
||||
|
||||
if (includeItemTypes.Length == 1
|
||||
&& (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase)))
|
||||
BaseItem? item = null;
|
||||
if (includeItemTypes.Length != 1
|
||||
|| !(string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
parentItem = null;
|
||||
item = _libraryManager.GetParentItem(parentId, user?.Id);
|
||||
}
|
||||
|
||||
var item = string.IsNullOrEmpty(parentId)
|
||||
? user == null
|
||||
? _libraryManager.RootFolder
|
||||
: _libraryManager.GetUserRootFolder()
|
||||
: parentItem;
|
||||
|
||||
var query = new InternalItemsQuery
|
||||
{
|
||||
User = user,
|
||||
|
@ -140,7 +131,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ActionResult<QueryFilters> GetQueryFilters(
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
[FromQuery] bool? isAiring,
|
||||
[FromQuery] bool? isMovie,
|
||||
|
@ -150,14 +141,11 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] bool? isSeries,
|
||||
[FromQuery] bool? recursive)
|
||||
{
|
||||
var parentItem = string.IsNullOrEmpty(parentId)
|
||||
? null
|
||||
: _libraryManager.GetItemById(parentId);
|
||||
|
||||
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
||||
? _userManager.GetUserById(userId.Value)
|
||||
: null;
|
||||
|
||||
BaseItem? parentItem = null;
|
||||
if (includeItemTypes.Length == 1
|
||||
&& (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
|
||||
|
@ -166,6 +154,10 @@ namespace Jellyfin.Api.Controllers
|
|||
{
|
||||
parentItem = null;
|
||||
}
|
||||
else if (parentId.HasValue)
|
||||
{
|
||||
parentItem = _libraryManager.GetItemById(parentId.Value);
|
||||
}
|
||||
|
||||
var filters = new QueryFilters();
|
||||
var genreQuery = new InternalItemsQuery(user)
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -109,15 +109,15 @@ namespace Jellyfin.Api.Controllers
|
|||
EnableTotalRecordCount = enableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(parentId) };
|
||||
query.AncestorIds = new[] { parentId.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(parentId) };
|
||||
query.ItemIds = new[] { parentId.Value };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] bool? recursive,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? sortOrder,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -239,14 +239,8 @@ namespace Jellyfin.Api.Controllers
|
|||
parentId = null;
|
||||
}
|
||||
|
||||
BaseItem? item = null;
|
||||
var item = _libraryManager.GetParentItem(parentId, userId);
|
||||
QueryResult<BaseItem> result;
|
||||
if (!string.IsNullOrEmpty(parentId))
|
||||
{
|
||||
item = _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
|
||||
item ??= _libraryManager.GetUserRootFolder();
|
||||
|
||||
if (!(item is Folder folder))
|
||||
{
|
||||
|
@ -343,7 +337,7 @@ namespace Jellyfin.Api.Controllers
|
|||
ItemIds = ids,
|
||||
MinCommunityRating = minCommunityRating,
|
||||
MinCriticRating = minCriticRating,
|
||||
ParentId = string.IsNullOrWhiteSpace(parentId) ? Guid.Empty : new Guid(parentId),
|
||||
ParentId = parentId ?? Guid.Empty,
|
||||
ParentIndexNumber = parentIndexNumber,
|
||||
EnableTotalRecordCount = enableTotalRecordCount,
|
||||
ExcludeItemIds = excludeItemIds,
|
||||
|
@ -615,7 +609,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] bool? recursive,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? sortOrder,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -773,7 +767,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
|
||||
[FromQuery] bool? enableUserData,
|
||||
|
@ -785,7 +779,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] bool? enableImages = true)
|
||||
{
|
||||
var user = _userManager.GetUserById(userId);
|
||||
var parentIdGuid = string.IsNullOrWhiteSpace(parentId) ? Guid.Empty : new Guid(parentId);
|
||||
var parentIdGuid = parentId ?? Guid.Empty;
|
||||
var dtoOptions = new DtoOptions { Fields = fields }
|
||||
.AddClientFields(Request)
|
||||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||
|
|
|
@ -362,7 +362,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[Authorize(Policy = Policies.DefaultAuthorization)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public ActionResult DeleteItems([FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] ids)
|
||||
public ActionResult DeleteItems([FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids)
|
||||
{
|
||||
if (ids.Length == 0)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[HttpGet("Recommendations")]
|
||||
public ActionResult<IEnumerable<RecommendationDto>> GetMovieRecommendations(
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery] int categoryLimit = 5,
|
||||
[FromQuery] int itemLimit = 8)
|
||||
|
@ -78,7 +78,7 @@ namespace Jellyfin.Api.Controllers
|
|||
|
||||
var categories = new List<RecommendationDto>();
|
||||
|
||||
var parentIdGuid = string.IsNullOrWhiteSpace(parentId) ? Guid.Empty : new Guid(parentId);
|
||||
var parentIdGuid = parentId ?? Guid.Empty;
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -109,15 +109,15 @@ namespace Jellyfin.Api.Controllers
|
|||
EnableTotalRecordCount = enableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(parentId) };
|
||||
query.AncestorIds = new[] { parentId.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(parentId) };
|
||||
query.ItemIds = new[] { parentId.Value };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@ namespace Jellyfin.Api.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<PackageInfo>> GetPackageInfo(
|
||||
[FromRoute, Required] string name,
|
||||
[FromQuery] string? assemblyGuid)
|
||||
[FromQuery] Guid? assemblyGuid)
|
||||
{
|
||||
var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
|
||||
var result = _installationManager.FilterPackages(
|
||||
packages,
|
||||
name,
|
||||
string.IsNullOrEmpty(assemblyGuid) ? default : Guid.Parse(assemblyGuid))
|
||||
assemblyGuid ?? default)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (result == null)
|
||||
|
@ -92,7 +92,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[Authorize(Policy = Policies.RequiresElevation)]
|
||||
public async Task<ActionResult> InstallPackage(
|
||||
[FromRoute, Required] string name,
|
||||
[FromQuery] string? assemblyGuid,
|
||||
[FromQuery] Guid? assemblyGuid,
|
||||
[FromQuery] string? version,
|
||||
[FromQuery] string? repositoryUrl)
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ namespace Jellyfin.Api.Controllers
|
|||
var package = _installationManager.GetCompatibleVersions(
|
||||
packages,
|
||||
name,
|
||||
string.IsNullOrEmpty(assemblyGuid) ? Guid.Empty : Guid.Parse(assemblyGuid),
|
||||
assemblyGuid ?? Guid.Empty,
|
||||
specificVersion: string.IsNullOrEmpty(version) ? null : Version.Parse(version))
|
||||
.FirstOrDefault();
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludePersonTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
|
||||
[FromQuery] string? appearsInItemId,
|
||||
[FromQuery] Guid? appearsInItemId,
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery] bool? enableImages = true)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ namespace Jellyfin.Api.Controllers
|
|||
NameContains = searchTerm,
|
||||
User = user,
|
||||
IsFavorite = !isFavorite.HasValue && isFavoriteInFilters ? true : isFavorite,
|
||||
AppearsInItemId = string.IsNullOrEmpty(appearsInItemId) ? Guid.Empty : Guid.Parse(appearsInItemId),
|
||||
AppearsInItemId = appearsInItemId ?? Guid.Empty,
|
||||
Limit = limit ?? 0
|
||||
});
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery] bool? isMovie,
|
||||
[FromQuery] bool? isSeries,
|
||||
[FromQuery] bool? isNews,
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -109,15 +109,15 @@ namespace Jellyfin.Api.Controllers
|
|||
EnableTotalRecordCount = enableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
if (parentId.HasValue)
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(parentId) };
|
||||
query.AncestorIds = new[] { parentId.Value };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(parentId) };
|
||||
query.ItemIds = new[] { parentId.Value };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] bool? recursive,
|
||||
[FromQuery] string? searchTerm,
|
||||
[FromQuery] string? sortOrder,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? limit,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery] string? seriesId,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery] bool? enableImges,
|
||||
[FromQuery] int? imageTypeLimit,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
|
||||
|
@ -132,7 +132,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery] bool? enableImges,
|
||||
[FromQuery] int? imageTypeLimit,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
|
||||
|
@ -144,7 +144,7 @@ namespace Jellyfin.Api.Controllers
|
|||
|
||||
var minPremiereDate = DateTime.Now.Date.ToUniversalTime().AddDays(-1);
|
||||
|
||||
var parentIdGuid = string.IsNullOrWhiteSpace(parentId) ? Guid.Empty : new Guid(parentId);
|
||||
var parentIdGuid = parentId ?? Guid.Empty;
|
||||
|
||||
var options = new DtoOptions { Fields = fields }
|
||||
.AddClientFields(Request)
|
||||
|
@ -194,14 +194,14 @@ namespace Jellyfin.Api.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public ActionResult<QueryResult<BaseItemDto>> GetEpisodes(
|
||||
[FromRoute, Required] string seriesId,
|
||||
[FromRoute, Required] Guid seriesId,
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery] int? season,
|
||||
[FromQuery] string? seasonId,
|
||||
[FromQuery] Guid? seasonId,
|
||||
[FromQuery] bool? isMissing,
|
||||
[FromQuery] string? adjacentTo,
|
||||
[FromQuery] string? startItemId,
|
||||
[FromQuery] Guid? startItemId,
|
||||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] bool? enableImages,
|
||||
|
@ -220,9 +220,9 @@ namespace Jellyfin.Api.Controllers
|
|||
.AddClientFields(Request)
|
||||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes!);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(seasonId)) // Season id was supplied. Get episodes by season id.
|
||||
if (seasonId.HasValue) // Season id was supplied. Get episodes by season id.
|
||||
{
|
||||
var item = _libraryManager.GetItemById(new Guid(seasonId));
|
||||
var item = _libraryManager.GetItemById(seasonId.Value);
|
||||
if (!(item is Season seasonItem))
|
||||
{
|
||||
return NotFound("No season exists with Id " + seasonId);
|
||||
|
@ -264,10 +264,10 @@ namespace Jellyfin.Api.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(startItemId))
|
||||
if (startItemId.HasValue)
|
||||
{
|
||||
episodes = episodes
|
||||
.SkipWhile(i => !string.Equals(i.Id.ToString("N", CultureInfo.InvariantCulture), startItemId, StringComparison.OrdinalIgnoreCase))
|
||||
.SkipWhile(i => startItemId.Value.Equals(i.Id))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public ActionResult<QueryResult<BaseItemDto>> GetSeasons(
|
||||
[FromRoute, Required] string seriesId,
|
||||
[FromRoute, Required] Guid seriesId,
|
||||
[FromQuery] Guid? userId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery] bool? isSpecialSeason,
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
|
|||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] string? sortOrder,
|
||||
[FromQuery] string? parentId,
|
||||
[FromQuery] Guid? parentId,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludeItemTypes,
|
||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
|
||||
|
@ -89,16 +89,11 @@ namespace Jellyfin.Api.Controllers
|
|||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||
|
||||
User? user = null;
|
||||
BaseItem parentItem;
|
||||
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
|
||||
|
||||
if (userId.HasValue && !userId.Equals(Guid.Empty))
|
||||
{
|
||||
user = _userManager.GetUserById(userId.Value);
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(parentId) ? _libraryManager.RootFolder : _libraryManager.GetItemById(parentId);
|
||||
}
|
||||
|
||||
IList<BaseItem> items;
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Channels
|
|||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <returns>ChannelFeatures.</returns>
|
||||
ChannelFeatures GetChannelFeatures(string id);
|
||||
ChannelFeatures GetChannelFeatures(Guid? id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all channel features.
|
||||
|
|
|
@ -574,5 +574,7 @@ namespace MediaBrowser.Controller.Library
|
|||
void RunMetadataSavers(IReadOnlyList<BaseItem> items, ItemUpdateType updateReason);
|
||||
|
||||
BaseItem GetParentItem(string parentId, Guid? userId);
|
||||
|
||||
BaseItem GetParentItem(Guid? parentId, Guid? userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Querying
|
|||
/// Gets or sets the parent identifier.
|
||||
/// </summary>
|
||||
/// <value>The parent identifier.</value>
|
||||
public string ParentId { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the series id.
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace MediaBrowser.Model.Search
|
|||
|
||||
public string[] ExcludeItemTypes { get; set; }
|
||||
|
||||
public string ParentId { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
public bool? IsMovie { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user