From 515ee90fb96b32d89134852b95ebcd8dbb656b94 Mon Sep 17 00:00:00 2001
From: nicknsy <20588554+nicknsy@users.noreply.github.com>
Date: Wed, 22 Feb 2023 18:17:54 -0800
Subject: Hls playlist
---
Jellyfin.Api/Models/StreamingDtos/VideoRequestDto.cs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'Jellyfin.Api/Models')
diff --git a/Jellyfin.Api/Models/StreamingDtos/VideoRequestDto.cs b/Jellyfin.Api/Models/StreamingDtos/VideoRequestDto.cs
index 60c529d4a..8548fec1a 100644
--- a/Jellyfin.Api/Models/StreamingDtos/VideoRequestDto.cs
+++ b/Jellyfin.Api/Models/StreamingDtos/VideoRequestDto.cs
@@ -1,4 +1,4 @@
-namespace Jellyfin.Api.Models.StreamingDtos;
+namespace Jellyfin.Api.Models.StreamingDtos;
///
/// The video request dto.
@@ -15,4 +15,9 @@ public class VideoRequestDto : StreamingRequestDto
/// Gets or sets a value indicating whether to enable subtitles in the manifest.
///
public bool EnableSubtitlesInManifest { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to enable trickplay images.
+ ///
+ public bool EnableTrickplay { get; set; }
}
--
cgit v1.2.3
From 2920611ffc206d845563637c4a865bf3f02d1374 Mon Sep 17 00:00:00 2001
From: Cody Robibero
Date: Sat, 13 May 2023 12:44:31 -0600
Subject: Convert string MediaType to enum MediaType
---
Emby.Dlna/ContentDirectory/ControlHandler.cs | 2 +-
Emby.Dlna/Didl/DidlBuilder.cs | 24 ++++++++--------
Emby.Dlna/PlayTo/PlayToController.cs | 7 +++--
Emby.Dlna/PlayTo/uBaseObject.cs | 13 +++++----
.../Data/SqliteItemRepository.cs | 16 ++++-------
.../Library/MediaSourceManager.cs | 15 +++++-----
.../Library/Resolvers/PlaylistResolver.cs | 1 +
.../Library/UserViewManager.cs | 2 +-
.../Library/Validators/CollectionPostScanTask.cs | 2 +-
.../Playlists/PlaylistManager.cs | 15 +++++-----
.../ScheduledTasks/Tasks/ChapterImagesTask.cs | 1 +
Jellyfin.Api/Controllers/ArtistsController.cs | 4 +--
Jellyfin.Api/Controllers/FilterController.cs | 2 +-
Jellyfin.Api/Controllers/ItemsController.cs | 6 ++--
Jellyfin.Api/Controllers/PlaylistsController.cs | 3 +-
Jellyfin.Api/Controllers/SearchController.cs | 2 +-
Jellyfin.Api/Controllers/SessionController.cs | 2 +-
Jellyfin.Api/Controllers/SuggestionsController.cs | 2 +-
Jellyfin.Api/Controllers/TrailersController.cs | 2 +-
Jellyfin.Api/Controllers/YearsController.cs | 6 ++--
Jellyfin.Api/Helpers/MediaInfoHelper.cs | 2 +-
Jellyfin.Api/Helpers/StreamingHelpers.cs | 3 +-
.../Models/PlaylistDtos/CreatePlaylistDto.cs | 3 +-
.../Models/SessionDtos/ClientCapabilitiesDto.cs | 3 +-
Jellyfin.Data/Enums/MediaType.cs | 32 ++++++++++++++++++++++
.../Consumers/Session/PlaybackStartLogger.cs | 7 +++--
.../Events/Consumers/Session/PlaybackStopLogger.cs | 7 +++--
MediaBrowser.Controller/Entities/Audio/Audio.cs | 2 +-
MediaBrowser.Controller/Entities/BaseItem.cs | 2 +-
MediaBrowser.Controller/Entities/Book.cs | 2 +-
.../Entities/InternalItemsQuery.cs | 4 +--
MediaBrowser.Controller/Entities/Photo.cs | 3 +-
.../Entities/UserViewBuilder.cs | 2 +-
MediaBrowser.Controller/Entities/Video.cs | 3 +-
MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 2 +-
MediaBrowser.Controller/Playlists/Playlist.cs | 14 +++++-----
MediaBrowser.Controller/Session/SessionInfo.cs | 5 ++--
.../Parsers/PlaylistXmlParser.cs | 8 +++++-
.../Savers/PlaylistXmlSaver.cs | 5 ++--
MediaBrowser.Model/Dlna/DeviceProfile.cs | 8 ++++--
MediaBrowser.Model/Dto/BaseItemDto.cs | 2 +-
MediaBrowser.Model/Entities/MediaType.cs | 28 -------------------
.../Playlists/PlaylistCreationRequest.cs | 3 +-
MediaBrowser.Model/Search/SearchHint.cs | 4 +--
MediaBrowser.Model/Search/SearchQuery.cs | 4 +--
MediaBrowser.Model/Session/ClientCapabilities.cs | 5 ++--
.../MediaInfo/SubtitleScheduledTask.cs | 2 +-
47 files changed, 159 insertions(+), 133 deletions(-)
create mode 100644 Jellyfin.Data/Enums/MediaType.cs
delete mode 100644 MediaBrowser.Model/Entities/MediaType.cs
(limited to 'Jellyfin.Api/Models')
diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs
index abd594a3a..12cd7e2ef 100644
--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs
+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs
@@ -494,7 +494,7 @@ namespace Emby.Dlna.ContentDirectory
{
var folder = (Folder)item;
- string[] mediaTypes = Array.Empty();
+ MediaType[] mediaTypes = Array.Empty();
bool? isFolder = null;
switch (search.SearchType)
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index 5ed982876..9f152df13 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -174,13 +174,14 @@ namespace Emby.Dlna.Didl
if (item is IHasMediaSources)
{
- if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ switch (item.MediaType)
{
- AddAudioResource(writer, item, deviceId, filter, streamInfo);
- }
- else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
- {
- AddVideoResource(writer, item, deviceId, filter, streamInfo);
+ case MediaType.Audio:
+ AddAudioResource(writer, item, deviceId, filter, streamInfo);
+ break;
+ case MediaType.Video:
+ AddVideoResource(writer, item, deviceId, filter, streamInfo);
+ break;
}
}
@@ -821,15 +822,15 @@ namespace Emby.Dlna.Didl
writer.WriteString(classType ?? "object.container.storageFolder");
}
- else if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ else if (item.MediaType == MediaType.Audio)
{
writer.WriteString("object.item.audioItem.musicTrack");
}
- else if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase))
+ else if (item.MediaType == MediaType.Photo)
{
writer.WriteString("object.item.imageItem.photo");
}
- else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ else if (item.MediaType == MediaType.Video)
{
if (!_profile.RequiresPlainVideoItems && item is Movie)
{
@@ -1006,8 +1007,7 @@ namespace Emby.Dlna.Didl
if (!_profile.EnableAlbumArtInDidl)
{
- if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)
- || string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Audio || item.MediaType == MediaType.Video)
{
if (!stubType.HasValue)
{
@@ -1016,7 +1016,7 @@ namespace Emby.Dlna.Didl
}
}
- if (!_profile.EnableSingleAlbumArtLimit || string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase))
+ if (!_profile.EnableSingleAlbumArtLimit || item.MediaType == MediaType.Photo)
{
AddImageResElement(item, writer, 4096, 4096, "jpg", "JPEG_LRG");
AddImageResElement(item, writer, 1024, 768, "jpg", "JPEG_MED");
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index b1ad15cdc..9e3d1d4d6 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Emby.Dlna.Didl;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using Jellyfin.Data.Events;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
@@ -577,7 +578,7 @@ namespace Emby.Dlna.PlayTo
private PlaylistItem GetPlaylistItem(BaseItem item, MediaSourceInfo[] mediaSources, DeviceProfile profile, string deviceId, string? mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex)
{
- if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Video)
{
return new PlaylistItem
{
@@ -597,7 +598,7 @@ namespace Emby.Dlna.PlayTo
};
}
- if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Audio)
{
return new PlaylistItem
{
@@ -615,7 +616,7 @@ namespace Emby.Dlna.PlayTo
};
}
- if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Photo)
{
return PlaylistItemFactory.Create((Photo)item, profile);
}
diff --git a/Emby.Dlna/PlayTo/uBaseObject.cs b/Emby.Dlna/PlayTo/uBaseObject.cs
index 2e0f2063b..a8f451405 100644
--- a/Emby.Dlna/PlayTo/uBaseObject.cs
+++ b/Emby.Dlna/PlayTo/uBaseObject.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
+using Jellyfin.Data.Enums;
namespace Emby.Dlna.PlayTo
{
@@ -33,19 +34,19 @@ namespace Emby.Dlna.PlayTo
{
var classType = UpnpClass ?? string.Empty;
- if (classType.IndexOf(MediaBrowser.Model.Entities.MediaType.Audio, StringComparison.Ordinal) != -1)
+ if (classType.Contains("Audio", StringComparison.Ordinal))
{
- return MediaBrowser.Model.Entities.MediaType.Audio;
+ return "Audio";
}
- if (classType.IndexOf(MediaBrowser.Model.Entities.MediaType.Video, StringComparison.Ordinal) != -1)
+ if (classType.Contains("Video", StringComparison.Ordinal))
{
- return MediaBrowser.Model.Entities.MediaType.Video;
+ return "Video";
}
- if (classType.IndexOf("image", StringComparison.Ordinal) != -1)
+ if (classType.Contains("image", StringComparison.Ordinal))
{
- return MediaBrowser.Model.Entities.MediaType.Photo;
+ return "Photo";
}
return null;
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 77cf4089b..798521d22 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -722,7 +722,7 @@ namespace Emby.Server.Implementations.Data
saveItemStatement.TryBind("@IsLocked", item.IsLocked);
saveItemStatement.TryBind("@Name", item.Name);
saveItemStatement.TryBind("@OfficialRating", item.OfficialRating);
- saveItemStatement.TryBind("@MediaType", item.MediaType);
+ saveItemStatement.TryBind("@MediaType", item.MediaType.ToString());
saveItemStatement.TryBind("@Overview", item.Overview);
saveItemStatement.TryBind("@ParentIndexNumber", item.ParentIndexNumber);
saveItemStatement.TryBind("@PremiereDate", item.PremiereDate);
@@ -3109,11 +3109,6 @@ namespace Emby.Server.Implementations.Data
return true;
}
- private bool IsValidMediaType(string value)
- {
- return IsAlphaNumeric(value);
- }
-
private bool IsValidPersonType(string value)
{
return IsAlphaNumeric(value);
@@ -4124,15 +4119,14 @@ namespace Emby.Server.Implementations.Data
}
}
- var queryMediaTypes = query.MediaTypes.Where(IsValidMediaType).ToArray();
- if (queryMediaTypes.Length == 1)
+ if (query.MediaTypes.Length == 1)
{
whereClauses.Add("MediaType=@MediaTypes");
- statement?.TryBind("@MediaTypes", queryMediaTypes[0]);
+ statement?.TryBind("@MediaTypes", query.MediaTypes[0].ToString());
}
- else if (queryMediaTypes.Length > 1)
+ else if (query.MediaTypes.Length > 1)
{
- var val = string.Join(',', queryMediaTypes.Select(i => "'" + i + "'"));
+ var val = string.Join(',', query.MediaTypes.Select(i => $"'{i}'"));
whereClauses.Add("MediaType in (" + val + ")");
}
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index c9a26a30f..3d0f9f02c 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -11,6 +11,7 @@ using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
+using EasyCaching.Core.Configurations;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions.Json;
@@ -186,11 +187,11 @@ namespace Emby.Server.Implementations.Library
{
SetDefaultAudioAndSubtitleStreamIndexes(item, source, user);
- if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Audio)
{
source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding);
}
- else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ else if (item.MediaType == MediaType.Video)
{
source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding);
source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing);
@@ -334,11 +335,11 @@ namespace Emby.Server.Implementations.Library
{
SetDefaultAudioAndSubtitleStreamIndexes(item, source, user);
- if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ if (item.MediaType == MediaType.Audio)
{
source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding);
}
- else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ else if (item.MediaType == MediaType.Video)
{
source.SupportsTranscoding = user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding);
source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing);
@@ -417,9 +418,9 @@ namespace Emby.Server.Implementations.Library
public void SetDefaultAudioAndSubtitleStreamIndexes(BaseItem item, MediaSourceInfo source, User user)
{
// Item would only be null if the app didn't supply ItemId as part of the live stream open request
- var mediaType = item is null ? MediaType.Video : item.MediaType;
+ var mediaType = item?.MediaType ?? MediaType.Video;
- if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ if (mediaType == MediaType.Video)
{
var userData = item is null ? new UserItemData() : _userDataManager.GetUserData(user, item);
@@ -428,7 +429,7 @@ namespace Emby.Server.Implementations.Library
SetDefaultAudioStreamIndex(source, userData, user, allowRememberingSelection);
SetDefaultSubtitleStreamIndex(source, userData, user, allowRememberingSelection);
}
- else if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ else if (mediaType == MediaType.Audio)
{
var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
diff --git a/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
index 5d569009d..8e34a42b3 100644
--- a/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
@@ -5,6 +5,7 @@
using System;
using System.IO;
using System.Linq;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Playlists;
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index 2c3dc1857..0343db68b 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -317,7 +317,7 @@ namespace Emby.Server.Implementations.Library
}
}
- var mediaTypes = new List();
+ var mediaTypes = new List();
if (includeItemTypes.Length == 0)
{
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
index df45793c3..89f64ee4f 100644
--- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
+++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Library.Validators
{
var movies = _libraryManager.GetItemList(new InternalItemsQuery
{
- MediaTypes = new string[] { MediaType.Video },
+ MediaTypes = new[] { MediaType.Video },
IncludeItemTypes = new[] { BaseItemKind.Movie },
IsVirtualItem = false,
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) },
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 649c49924..c783f2b01 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -10,6 +10,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -74,7 +75,7 @@ namespace Emby.Server.Implementations.Playlists
throw new ArgumentException(nameof(parentFolder));
}
- if (string.IsNullOrEmpty(options.MediaType))
+ if (options.MediaType is null || options.MediaType == MediaType.Unknown)
{
foreach (var itemId in options.ItemIdList)
{
@@ -84,7 +85,7 @@ namespace Emby.Server.Implementations.Playlists
throw new ArgumentException("No item exists with the supplied Id");
}
- if (!string.IsNullOrEmpty(item.MediaType))
+ if (item.MediaType == MediaType.Unknown)
{
options.MediaType = item.MediaType;
}
@@ -102,20 +103,20 @@ namespace Emby.Server.Implementations.Playlists
{
options.MediaType = folder.GetRecursiveChildren(i => !i.IsFolder && i.SupportsAddingToPlaylist)
.Select(i => i.MediaType)
- .FirstOrDefault(i => !string.IsNullOrEmpty(i));
+ .FirstOrDefault(i => i != MediaType.Unknown);
}
}
- if (!string.IsNullOrEmpty(options.MediaType))
+ if (options.MediaType is null || options.MediaType == MediaType.Unknown)
{
break;
}
}
}
- if (string.IsNullOrEmpty(options.MediaType))
+ if (options.MediaType is null || options.MediaType == MediaType.Unknown)
{
- options.MediaType = "Audio";
+ options.MediaType = MediaType.Audio;
}
var user = _userManager.GetUserById(options.UserId);
@@ -168,7 +169,7 @@ namespace Emby.Server.Implementations.Playlists
return path;
}
- private List GetPlaylistItems(IEnumerable itemIds, string playlistMediaType, User user, DtoOptions options)
+ private List GetPlaylistItems(IEnumerable itemIds, MediaType playlistMediaType, User user, DtoOptions options)
{
var items = itemIds.Select(i => _libraryManager.GetItemById(i)).Where(i => i is not null);
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
index 6ad6c4cbd..1d72ceae9 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Dto;
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index c9d2f67f9..1c994ac8b 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -95,7 +95,7 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
@@ -299,7 +299,7 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs
index d51a5325f..baeb8b81a 100644
--- a/Jellyfin.Api/Controllers/FilterController.cs
+++ b/Jellyfin.Api/Controllers/FilterController.cs
@@ -50,7 +50,7 @@ public class FilterController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] Guid? parentId,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.Value.Equals(default)
diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs
index 80128536d..884613afa 100644
--- a/Jellyfin.Api/Controllers/ItemsController.cs
+++ b/Jellyfin.Api/Controllers/ItemsController.cs
@@ -195,7 +195,7 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
[FromQuery] bool? isPlayed,
@@ -652,7 +652,7 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
[FromQuery] bool? isPlayed,
@@ -812,7 +812,7 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs
index 8d2a738d4..c4c89ccde 100644
--- a/Jellyfin.Api/Controllers/PlaylistsController.cs
+++ b/Jellyfin.Api/Controllers/PlaylistsController.cs
@@ -8,6 +8,7 @@ using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Api.Models.PlaylistDtos;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Playlists;
@@ -75,7 +76,7 @@ public class PlaylistsController : BaseJellyfinApiController
[FromQuery, ParameterObsolete] string? name,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder)), ParameterObsolete] IReadOnlyList ids,
[FromQuery, ParameterObsolete] Guid? userId,
- [FromQuery, ParameterObsolete] string? mediaType,
+ [FromQuery, ParameterObsolete] MediaType? mediaType,
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] CreatePlaylistDto? createPlaylistRequest)
{
if (ids.Count == 0)
diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs
index 387b3ea5a..5b4594165 100644
--- a/Jellyfin.Api/Controllers/SearchController.cs
+++ b/Jellyfin.Api/Controllers/SearchController.cs
@@ -86,7 +86,7 @@ public class SearchController : BaseJellyfinApiController
[FromQuery, Required] string searchTerm,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery] Guid? parentId,
[FromQuery] bool? isMovie,
[FromQuery] bool? isSeries,
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs
index e93456de6..e20cf034d 100644
--- a/Jellyfin.Api/Controllers/SessionController.cs
+++ b/Jellyfin.Api/Controllers/SessionController.cs
@@ -393,7 +393,7 @@ public class SessionController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task PostCapabilities(
[FromQuery] string? id,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] playableMediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] playableMediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] GeneralCommandType[] supportedCommands,
[FromQuery] bool supportsMediaControl = false,
[FromQuery] bool supportsSync = false,
diff --git a/Jellyfin.Api/Controllers/SuggestionsController.cs b/Jellyfin.Api/Controllers/SuggestionsController.cs
index 5b808f257..675757fc5 100644
--- a/Jellyfin.Api/Controllers/SuggestionsController.cs
+++ b/Jellyfin.Api/Controllers/SuggestionsController.cs
@@ -56,7 +56,7 @@ public class SuggestionsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult> GetSuggestions(
[FromRoute, Required] Guid userId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaType,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaType,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] type,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
diff --git a/Jellyfin.Api/Controllers/TrailersController.cs b/Jellyfin.Api/Controllers/TrailersController.cs
index b5b640620..9f1e0e837 100644
--- a/Jellyfin.Api/Controllers/TrailersController.cs
+++ b/Jellyfin.Api/Controllers/TrailersController.cs
@@ -160,7 +160,7 @@ public class TrailersController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
[FromQuery] bool? isPlayed,
diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs
index 74370db50..200ecea09 100644
--- a/Jellyfin.Api/Controllers/YearsController.cs
+++ b/Jellyfin.Api/Controllers/YearsController.cs
@@ -76,7 +76,7 @@ public class YearsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
@@ -191,7 +191,7 @@ public class YearsController : BaseJellyfinApiController
return _dtoService.GetBaseItemDto(item, dtoOptions);
}
- private bool FilterItem(BaseItem f, IReadOnlyCollection excludeItemTypes, IReadOnlyCollection includeItemTypes, IReadOnlyCollection mediaTypes)
+ private bool FilterItem(BaseItem f, IReadOnlyCollection excludeItemTypes, IReadOnlyCollection includeItemTypes, IReadOnlyCollection mediaTypes)
{
var baseItemKind = f.GetBaseItemKind();
// Exclude item types
@@ -207,7 +207,7 @@ public class YearsController : BaseJellyfinApiController
}
// Include MediaTypes
- if (mediaTypes.Count > 0 && !mediaTypes.Contains(f.MediaType ?? string.Empty, StringComparison.OrdinalIgnoreCase))
+ if (mediaTypes.Count > 0 && !mediaTypes.Contains(f.MediaType))
{
return false;
}
diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
index a36028cfe..321987ca7 100644
--- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs
+++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
@@ -243,7 +243,7 @@ public class MediaInfoHelper
}
// Beginning of Playback Determination
- var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)
+ var streamInfo = item.MediaType == MediaType.Audio
? streamBuilder.GetOptimalAudioStream(options)
: streamBuilder.GetOptimalVideoStream(options);
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index a653c5795..ed2358dd8 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Models.StreamingDtos;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
@@ -128,7 +129,7 @@ public static class StreamingHelpers
var item = libraryManager.GetItemById(streamingRequest.Id);
- state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);
+ state.IsInputVideo = item.MediaType == MediaType.Video;
MediaSourceInfo? mediaSource = null;
if (string.IsNullOrWhiteSpace(streamingRequest.LiveStreamId))
diff --git a/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs b/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
index 1fba32c5b..bdc488871 100644
--- a/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
+++ b/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions.Json.Converters;
namespace Jellyfin.Api.Models.PlaylistDtos;
@@ -29,5 +30,5 @@ public class CreatePlaylistDto
///
/// Gets or sets the media type.
///
- public string? MediaType { get; set; }
+ public MediaType? MediaType { get; set; }
}
diff --git a/Jellyfin.Api/Models/SessionDtos/ClientCapabilitiesDto.cs b/Jellyfin.Api/Models/SessionDtos/ClientCapabilitiesDto.cs
index b88be33b2..b021771a0 100644
--- a/Jellyfin.Api/Models/SessionDtos/ClientCapabilitiesDto.cs
+++ b/Jellyfin.Api/Models/SessionDtos/ClientCapabilitiesDto.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Session;
@@ -16,7 +17,7 @@ public class ClientCapabilitiesDto
/// Gets or sets the list of playable media types.
///
[JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
- public IReadOnlyList PlayableMediaTypes { get; set; } = Array.Empty();
+ public IReadOnlyList PlayableMediaTypes { get; set; } = Array.Empty();
///
/// Gets or sets the list of supported commands.
diff --git a/Jellyfin.Data/Enums/MediaType.cs b/Jellyfin.Data/Enums/MediaType.cs
new file mode 100644
index 000000000..b014ff366
--- /dev/null
+++ b/Jellyfin.Data/Enums/MediaType.cs
@@ -0,0 +1,32 @@
+namespace Jellyfin.Data.Enums;
+
+///
+/// Media types.
+///
+public enum MediaType
+{
+ ///
+ /// Unknown media type.
+ ///
+ Unknown = 0,
+
+ ///
+ /// Video media.
+ ///
+ Video = 1,
+
+ ///
+ /// Audio media.
+ ///
+ Audio = 2,
+
+ ///
+ /// Photo media.
+ ///
+ Photo = 3,
+
+ ///
+ /// Book media.
+ ///
+ Book = 4
+}
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
index 27726a57a..8a33383e3 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Activity;
@@ -89,14 +90,14 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return name;
}
- private static string GetPlaybackNotificationType(string mediaType)
+ private static string GetPlaybackNotificationType(MediaType mediaType)
{
- if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ if (mediaType == MediaType.Audio)
{
return NotificationType.AudioPlayback.ToString();
}
- if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ if (mediaType == MediaType.Video)
{
return NotificationType.VideoPlayback.ToString();
}
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
index 6b16477aa..4c2effc2e 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Activity;
@@ -97,14 +98,14 @@ namespace Jellyfin.Server.Implementations.Events.Consumers.Session
return name;
}
- private static string? GetPlaybackStoppedNotificationType(string mediaType)
+ private static string? GetPlaybackStoppedNotificationType(MediaType mediaType)
{
- if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
+ if (mediaType == MediaType.Audio)
{
return NotificationType.AudioPlaybackStopped.ToString();
}
- if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
+ if (mediaType == MediaType.Video)
{
return NotificationType.VideoPlaybackStopped.ToString();
}
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs
index c7216a320..243d2f04f 100644
--- a/MediaBrowser.Controller/Entities/Audio/Audio.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs
@@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.Entities.Audio
///
/// The type of the media.
[JsonIgnore]
- public override string MediaType => Model.Entities.MediaType.Audio;
+ public override MediaType MediaType => MediaType.Audio;
public override double GetDefaultPrimaryImageAspectRatio()
{
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 9f3e8eec9..f83065a01 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -422,7 +422,7 @@ namespace MediaBrowser.Controller.Entities
///
/// The type of the media.
[JsonIgnore]
- public virtual string MediaType => null;
+ public virtual MediaType MediaType => MediaType.Unknown;
[JsonIgnore]
public virtual string[] PhysicalLocations
diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs
index d75beb06d..63f9180fd 100644
--- a/MediaBrowser.Controller/Entities/Book.cs
+++ b/MediaBrowser.Controller/Entities/Book.cs
@@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Entities
}
[JsonIgnore]
- public override string MediaType => Model.Entities.MediaType.Book;
+ public override MediaType MediaType => MediaType.Book;
public override bool SupportsPlayedStatus => true;
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index a51299284..2de974349 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Entities
ImageTypes = Array.Empty();
IncludeItemTypes = Array.Empty();
ItemIds = Array.Empty();
- MediaTypes = Array.Empty();
+ MediaTypes = Array.Empty();
MinSimilarityScore = 20;
OfficialRatings = Array.Empty();
OrderBy = Array.Empty<(string, SortOrder)>();
@@ -86,7 +86,7 @@ namespace MediaBrowser.Controller.Entities
public bool? IncludeItemsByName { get; set; }
- public string[] MediaTypes { get; set; }
+ public MediaType[] MediaTypes { get; set; }
public BaseItemKind[] IncludeItemTypes { get; set; }
diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs
index ba6ce189a..cb9feacd3 100644
--- a/MediaBrowser.Controller/Entities/Photo.cs
+++ b/MediaBrowser.Controller/Entities/Photo.cs
@@ -3,6 +3,7 @@
#pragma warning disable CS1591
using System.Text.Json.Serialization;
+using Jellyfin.Data.Enums;
using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Controller.Entities
@@ -13,7 +14,7 @@ namespace MediaBrowser.Controller.Entities
public override bool SupportsLocalMetadata => false;
[JsonIgnore]
- public override string MediaType => Model.Entities.MediaType.Photo;
+ public override MediaType MediaType => MediaType.Photo;
[JsonIgnore]
public override Folder LatestItemsIndexContainer => AlbumEntity;
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index c276ab463..5f187e64e 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -476,7 +476,7 @@ namespace MediaBrowser.Controller.Entities
public static bool Filter(BaseItem item, User user, InternalItemsQuery query, IUserDataManager userDataManager, ILibraryManager libraryManager)
{
- if (query.MediaTypes.Length > 0 && !query.MediaTypes.Contains(item.MediaType ?? string.Empty, StringComparison.OrdinalIgnoreCase))
+ if (query.MediaTypes.Length > 0 && !query.MediaTypes.Contains(item.MediaType))
{
return false;
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 9f685b7e2..be2eb4d28 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
@@ -256,7 +257,7 @@ namespace MediaBrowser.Controller.Entities
///
/// The type of the media.
[JsonIgnore]
- public override string MediaType => Model.Entities.MediaType.Video;
+ public override MediaType MediaType => MediaType.Video;
public override List GetUserDataKeys()
{
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index f11e3c8f6..3c2cf8e3d 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -44,7 +44,7 @@ namespace MediaBrowser.Controller.LiveTv
public override LocationType LocationType => LocationType.Remote;
[JsonIgnore]
- public override string MediaType => ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
+ public override MediaType MediaType => ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video;
[JsonIgnore]
public bool IsMovie { get; set; }
diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs
index 498df5ab0..ca032e7f6 100644
--- a/MediaBrowser.Controller/Playlists/Playlist.cs
+++ b/MediaBrowser.Controller/Playlists/Playlist.cs
@@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Playlists
public override bool SupportsInheritedParentImages => false;
[JsonIgnore]
- public override bool SupportsPlayedStatus => string.Equals(MediaType, "Video", StringComparison.OrdinalIgnoreCase);
+ public override bool SupportsPlayedStatus => MediaType == Jellyfin.Data.Enums.MediaType.Video;
[JsonIgnore]
public override bool AlwaysScanInternalMetadataPath => true;
@@ -80,10 +80,10 @@ namespace MediaBrowser.Controller.Playlists
[JsonIgnore]
public override bool IsPreSorted => true;
- public string PlaylistMediaType { get; set; }
+ public MediaType PlaylistMediaType { get; set; }
[JsonIgnore]
- public override string MediaType => PlaylistMediaType;
+ public override MediaType MediaType => PlaylistMediaType;
[JsonIgnore]
private bool IsSharedItem
@@ -107,9 +107,9 @@ namespace MediaBrowser.Controller.Playlists
return System.IO.Path.HasExtension(path) && !Directory.Exists(path);
}
- public void SetMediaType(string value)
+ public void SetMediaType(MediaType? value)
{
- PlaylistMediaType = value;
+ PlaylistMediaType = value ?? MediaType.Unknown;
}
public override double GetDefaultPrimaryImageAspectRatio()
@@ -167,7 +167,7 @@ namespace MediaBrowser.Controller.Playlists
return base.GetChildren(user, true, query);
}
- public static List GetPlaylistItems(string playlistMediaType, IEnumerable inputItems, User user, DtoOptions options)
+ public static List GetPlaylistItems(MediaType playlistMediaType, IEnumerable inputItems, User user, DtoOptions options)
{
if (user is not null)
{
@@ -185,7 +185,7 @@ namespace MediaBrowser.Controller.Playlists
return list;
}
- private static IEnumerable GetPlaylistItems(BaseItem item, User user, string mediaType, DtoOptions options)
+ private static IEnumerable GetPlaylistItems(BaseItem item, User user, MediaType mediaType, DtoOptions options)
{
if (item is MusicGenre musicGenre)
{
diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs
index 25bf23d61..07ad529b4 100644
--- a/MediaBrowser.Controller/Session/SessionInfo.cs
+++ b/MediaBrowser.Controller/Session/SessionInfo.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Session;
@@ -60,13 +61,13 @@ namespace MediaBrowser.Controller.Session
/// Gets the playable media types.
///
/// The playable media types.
- public IReadOnlyList PlayableMediaTypes
+ public IReadOnlyList PlayableMediaTypes
{
get
{
if (Capabilities is null)
{
- return Array.Empty();
+ return Array.Empty();
}
return Capabilities.PlayableMediaTypes;
diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
index 879a3616b..e0277870d 100644
--- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
@@ -1,5 +1,7 @@
+using System;
using System.Collections.Generic;
using System.Xml;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Controller.Playlists;
@@ -31,7 +33,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "PlaylistMediaType":
- item.PlaylistMediaType = reader.ReadNormalizedString();
+ if (Enum.TryParse(reader.ReadNormalizedString(), out var mediaType))
+ {
+ item.PlaylistMediaType = mediaType;
+ }
+
break;
case "PlaylistItems":
diff --git a/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
index 847add07f..3f018cae9 100644
--- a/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Threading.Tasks;
using System.Xml;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -48,12 +49,12 @@ namespace MediaBrowser.LocalMetadata.Savers
{
var game = (Playlist)item;
- if (string.IsNullOrEmpty(game.PlaylistMediaType))
+ if (game.PlaylistMediaType == MediaType.Unknown)
{
return Task.CompletedTask;
}
- return writer.WriteElementStringAsync(null, "PlaylistMediaType", null, game.PlaylistMediaType);
+ return writer.WriteElementStringAsync(null, "PlaylistMediaType", null, game.PlaylistMediaType.ToString());
}
///
diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs
index 07bb002ea..71d0896a7 100644
--- a/MediaBrowser.Model/Dlna/DeviceProfile.cs
+++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs
@@ -1,6 +1,7 @@
#pragma warning disable CA1819 // Properties should not return arrays
using System;
using System.ComponentModel;
+using System.Linq;
using System.Xml.Serialization;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
@@ -227,9 +228,12 @@ namespace MediaBrowser.Model.Dlna
/// The GetSupportedMediaTypes.
///
/// The .
- public string[] GetSupportedMediaTypes()
+ public MediaType[] GetSupportedMediaTypes()
{
- return ContainerProfile.SplitValue(SupportedMediaTypes);
+ return ContainerProfile.SplitValue(SupportedMediaTypes)
+ .Select(m => Enum.TryParse(m, out var parsed) ? parsed : MediaType.Unknown)
+ .Where(m => m != MediaType.Unknown)
+ .ToArray();
}
///
diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs
index 8fab1ca6d..edbf2d9d4 100644
--- a/MediaBrowser.Model/Dto/BaseItemDto.cs
+++ b/MediaBrowser.Model/Dto/BaseItemDto.cs
@@ -584,7 +584,7 @@ namespace MediaBrowser.Model.Dto
/// Gets or sets the type of the media.
///
/// The type of the media.
- public string MediaType { get; set; }
+ public MediaType MediaType { get; set; }
///
/// Gets or sets the end date.
diff --git a/MediaBrowser.Model/Entities/MediaType.cs b/MediaBrowser.Model/Entities/MediaType.cs
deleted file mode 100644
index dd2ae810b..000000000
--- a/MediaBrowser.Model/Entities/MediaType.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace MediaBrowser.Model.Entities
-{
- ///
- /// Class MediaType.
- ///
- public static class MediaType
- {
- ///
- /// The video.
- ///
- public const string Video = "Video";
-
- ///
- /// The audio.
- ///
- public const string Audio = "Audio";
-
- ///
- /// The photo.
- ///
- public const string Photo = "Photo";
-
- ///
- /// The book.
- ///
- public const string Book = "Book";
- }
-}
diff --git a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs
index 847269716..62d496d04 100644
--- a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs
+++ b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Playlists;
@@ -22,7 +23,7 @@ public class PlaylistCreationRequest
///
/// Gets or sets the media type.
///
- public string? MediaType { get; set; }
+ public MediaType? MediaType { get; set; }
///
/// Gets or sets the user id.
diff --git a/MediaBrowser.Model/Search/SearchHint.cs b/MediaBrowser.Model/Search/SearchHint.cs
index 3fa7f3d56..fd911dbed 100644
--- a/MediaBrowser.Model/Search/SearchHint.cs
+++ b/MediaBrowser.Model/Search/SearchHint.cs
@@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Search
{
Name = string.Empty;
MatchedTerm = string.Empty;
- MediaType = string.Empty;
+ MediaType = Jellyfin.Data.Enums.MediaType.Unknown;
Artists = Array.Empty();
}
@@ -115,7 +115,7 @@ namespace MediaBrowser.Model.Search
/// Gets or sets the type of the media.
///
/// The type of the media.
- public string MediaType { get; set; }
+ public MediaType MediaType { get; set; }
///
/// Gets or sets the start date.
diff --git a/MediaBrowser.Model/Search/SearchQuery.cs b/MediaBrowser.Model/Search/SearchQuery.cs
index 1caed827f..b91fd8657 100644
--- a/MediaBrowser.Model/Search/SearchQuery.cs
+++ b/MediaBrowser.Model/Search/SearchQuery.cs
@@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Search
IncludePeople = true;
IncludeStudios = true;
- MediaTypes = Array.Empty();
+ MediaTypes = Array.Empty();
IncludeItemTypes = Array.Empty();
ExcludeItemTypes = Array.Empty();
}
@@ -55,7 +55,7 @@ namespace MediaBrowser.Model.Search
public bool IncludeArtists { get; set; }
- public string[] MediaTypes { get; set; }
+ public MediaType[] MediaTypes { get; set; }
public BaseItemKind[] IncludeItemTypes { get; set; }
diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs
index d692906c6..7fefce9cd 100644
--- a/MediaBrowser.Model/Session/ClientCapabilities.cs
+++ b/MediaBrowser.Model/Session/ClientCapabilities.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using Jellyfin.Data.Enums;
using MediaBrowser.Model.Dlna;
namespace MediaBrowser.Model.Session
@@ -11,12 +12,12 @@ namespace MediaBrowser.Model.Session
{
public ClientCapabilities()
{
- PlayableMediaTypes = Array.Empty();
+ PlayableMediaTypes = Array.Empty();
SupportedCommands = Array.Empty();
SupportsPersistentIdentifier = true;
}
- public IReadOnlyList PlayableMediaTypes { get; set; }
+ public IReadOnlyList PlayableMediaTypes { get; set; }
public IReadOnlyList SupportedCommands { get; set; }
diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
index f21939d2a..6eb75891a 100644
--- a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
+++ b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs
@@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.MediaInfo
{
var query = new InternalItemsQuery
{
- MediaTypes = new string[] { MediaType.Video },
+ MediaTypes = new[] { MediaType.Video },
IsVirtualItem = false,
IncludeItemTypes = types,
DtoOptions = new DtoOptions(true),
--
cgit v1.2.3
From c7a94d48ae019f41d5f06340bca7efe0788ad5ad Mon Sep 17 00:00:00 2001
From: Cody Robibero
Date: Thu, 9 Nov 2023 14:00:13 -0700
Subject: Convert ItemSortBy to enum (#9765)
* Convert ItemSortBy to enum
* Rename Unknown to Default
---
Emby.Dlna/ContentDirectory/ControlHandler.cs | 18 +-
.../Data/SqliteItemRepository.cs | 205 +++++----------------
.../Images/BaseFolderImageProvider.cs | 2 +-
.../Library/LibraryManager.cs | 8 +-
.../LiveTv/LiveTvManager.cs | 2 +-
.../Sorting/AiredEpisodeOrderComparer.cs | 3 +-
.../Sorting/AlbumArtistComparer.cs | 3 +-
.../Sorting/AlbumComparer.cs | 3 +-
.../Sorting/ArtistComparer.cs | 3 +-
.../Sorting/CommunityRatingComparer.cs | 3 +-
.../Sorting/CriticRatingComparer.cs | 3 +-
.../Sorting/DateCreatedComparer.cs | 3 +-
.../Sorting/DateLastMediaAddedComparer.cs | 3 +-
.../Sorting/DatePlayedComparer.cs | 3 +-
.../Sorting/IndexNumberComparer.cs | 3 +-
.../Sorting/IsFavoriteOrLikeComparer.cs | 3 +-
.../Sorting/IsFolderComparer.cs | 3 +-
.../Sorting/IsPlayedComparer.cs | 3 +-
.../Sorting/IsUnplayedComparer.cs | 3 +-
.../Sorting/NameComparer.cs | 3 +-
.../Sorting/OfficialRatingComparer.cs | 3 +-
.../Sorting/ParentIndexNumberComparer.cs | 3 +-
.../Sorting/PlayCountComparer.cs | 3 +-
.../Sorting/PremiereDateComparer.cs | 3 +-
.../Sorting/ProductionYearComparer.cs | 3 +-
.../Sorting/RandomComparer.cs | 3 +-
.../Sorting/RuntimeComparer.cs | 3 +-
.../Sorting/SeriesSortNameComparer.cs | 3 +-
.../Sorting/SortNameComparer.cs | 3 +-
.../Sorting/StartDateComparer.cs | 3 +-
.../Sorting/StudioComparer.cs | 3 +-
Jellyfin.Api/Controllers/ArtistsController.cs | 4 +-
Jellyfin.Api/Controllers/ChannelsController.cs | 2 +-
Jellyfin.Api/Controllers/GenresController.cs | 2 +-
Jellyfin.Api/Controllers/ItemsController.cs | 4 +-
Jellyfin.Api/Controllers/LiveTvController.cs | 4 +-
Jellyfin.Api/Controllers/MusicGenresController.cs | 2 +-
Jellyfin.Api/Controllers/TrailersController.cs | 2 +-
Jellyfin.Api/Controllers/TvShowsController.cs | 4 +-
Jellyfin.Api/Controllers/YearsController.cs | 2 +-
Jellyfin.Api/Helpers/RequestHelpers.cs | 6 +-
Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs | 2 +-
Jellyfin.Data/Enums/ItemSortBy.cs | 167 +++++++++++++++++
.../Entities/IHasDisplayOrder.cs | 2 +
.../Entities/InternalItemsQuery.cs | 4 +-
MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 8 +-
MediaBrowser.Controller/Library/ILibraryManager.cs | 4 +-
MediaBrowser.Controller/Providers/EpisodeInfo.cs | 1 +
.../Sorting/IBaseItemComparer.cs | 6 +-
MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs | 1 +
MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs | 4 +-
MediaBrowser.Model/Querying/ItemSortBy.cs | 163 ----------------
MediaBrowser.Providers/Manager/MetadataService.cs | 1 +
.../Plugins/Tmdb/TmdbClientManager.cs | 1 +
.../Helpers/RequestHelpersTests.cs | 36 ++--
55 files changed, 329 insertions(+), 416 deletions(-)
create mode 100644 Jellyfin.Data/Enums/ItemSortBy.cs
delete mode 100644 MediaBrowser.Model/Querying/ItemSortBy.cs
(limited to 'Jellyfin.Api/Models')
diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs
index abd594a3a..e685d252e 100644
--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs
+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs
@@ -917,7 +917,7 @@ namespace Emby.Dlna.ContentDirectory
private QueryResult GetGenres(BaseItem parent, InternalItemsQuery query)
{
// Don't sort
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
query.AncestorIds = new[] { parent.Id };
var genresResult = _libraryManager.GetGenres(query);
@@ -933,7 +933,7 @@ namespace Emby.Dlna.ContentDirectory
private QueryResult GetMusicGenres(BaseItem parent, InternalItemsQuery query)
{
// Don't sort
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
query.AncestorIds = new[] { parent.Id };
var genresResult = _libraryManager.GetMusicGenres(query);
@@ -949,7 +949,7 @@ namespace Emby.Dlna.ContentDirectory
private QueryResult GetMusicAlbumArtists(BaseItem parent, InternalItemsQuery query)
{
// Don't sort
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
query.AncestorIds = new[] { parent.Id };
var artists = _libraryManager.GetAlbumArtists(query);
@@ -965,7 +965,7 @@ namespace Emby.Dlna.ContentDirectory
private QueryResult GetMusicArtists(BaseItem parent, InternalItemsQuery query)
{
// Don't sort
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
query.AncestorIds = new[] { parent.Id };
var artists = _libraryManager.GetArtists(query);
return ToResult(query.StartIndex, artists);
@@ -980,7 +980,7 @@ namespace Emby.Dlna.ContentDirectory
private QueryResult GetFavoriteArtists(BaseItem parent, InternalItemsQuery query)
{
// Don't sort
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
query.AncestorIds = new[] { parent.Id };
query.IsFavorite = true;
var artists = _libraryManager.GetArtists(query);
@@ -1011,7 +1011,7 @@ namespace Emby.Dlna.ContentDirectory
/// The .
private QueryResult GetNextUp(BaseItem parent, InternalItemsQuery query)
{
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
var result = _tvSeriesManager.GetNextUp(
new NextUpQuery
@@ -1036,7 +1036,7 @@ namespace Emby.Dlna.ContentDirectory
/// The .
private QueryResult GetLatest(BaseItem parent, InternalItemsQuery query, BaseItemKind itemType)
{
- query.OrderBy = Array.Empty<(string, SortOrder)>();
+ query.OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
var items = _userViewManager.GetLatestItems(
new LatestItemsQuery
@@ -1203,9 +1203,9 @@ namespace Emby.Dlna.ContentDirectory
///
/// The .
/// True if pre-sorted.
- private static (string SortName, SortOrder SortOrder)[] GetOrderBy(SortCriteria sort, bool isPreSorted)
+ private static (ItemSortBy SortName, SortOrder SortOrder)[] GetOrderBy(SortCriteria sort, bool isPreSorted)
{
- return isPreSorted ? Array.Empty<(string, SortOrder)>() : new[] { (ItemSortBy.SortName, sort.SortOrder) };
+ return isPreSorted ? Array.Empty<(ItemSortBy, SortOrder)>() : new[] { (ItemSortBy.SortName, sort.SortOrder) };
}
///
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index e519364c2..fadd4f2f3 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -2042,7 +2042,7 @@ namespace Emby.Server.Implementations.Data
return false;
}
- var sortingFields = new HashSet(query.OrderBy.Select(i => i.OrderBy), StringComparer.OrdinalIgnoreCase);
+ var sortingFields = new HashSet(query.OrderBy.Select(i => i.OrderBy));
return sortingFields.Contains(ItemSortBy.IsFavoriteOrLiked)
|| sortingFields.Contains(ItemSortBy.IsPlayed)
@@ -2832,20 +2832,20 @@ namespace Emby.Server.Implementations.Data
if (hasSimilar || hasSearch)
{
- List<(string, SortOrder)> prepend = new List<(string, SortOrder)>(4);
+ List<(ItemSortBy, SortOrder)> prepend = new List<(ItemSortBy, SortOrder)>(4);
if (hasSearch)
{
- prepend.Add(("SearchScore", SortOrder.Descending));
+ prepend.Add((ItemSortBy.SearchScore, SortOrder.Descending));
prepend.Add((ItemSortBy.SortName, SortOrder.Ascending));
}
if (hasSimilar)
{
- prepend.Add(("SimilarityScore", SortOrder.Descending));
+ prepend.Add((ItemSortBy.SimilarityScore, SortOrder.Descending));
prepend.Add((ItemSortBy.Random, SortOrder.Ascending));
}
- var arr = new (string, SortOrder)[prepend.Count + orderBy.Count];
+ var arr = new (ItemSortBy, SortOrder)[prepend.Count + orderBy.Count];
prepend.CopyTo(arr, 0);
orderBy.CopyTo(arr, prepend.Count);
orderBy = query.OrderBy = arr;
@@ -2863,166 +2863,43 @@ namespace Emby.Server.Implementations.Data
}));
}
- private string MapOrderByField(string name, InternalItemsQuery query)
+ private string MapOrderByField(ItemSortBy sortBy, InternalItemsQuery query)
{
- if (string.Equals(name, ItemSortBy.AirTime, StringComparison.OrdinalIgnoreCase))
- {
- // TODO
- return "SortName";
- }
-
- if (string.Equals(name, ItemSortBy.Runtime, StringComparison.OrdinalIgnoreCase))
- {
- return "RuntimeTicks";
- }
-
- if (string.Equals(name, ItemSortBy.Random, StringComparison.OrdinalIgnoreCase))
- {
- return "RANDOM()";
- }
-
- if (string.Equals(name, ItemSortBy.DatePlayed, StringComparison.OrdinalIgnoreCase))
- {
- if (query.GroupBySeriesPresentationUniqueKey)
- {
- return "MAX(LastPlayedDate)";
- }
-
- return "LastPlayedDate";
- }
-
- if (string.Equals(name, ItemSortBy.PlayCount, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.PlayCount;
- }
-
- if (string.Equals(name, ItemSortBy.IsFavoriteOrLiked, StringComparison.OrdinalIgnoreCase))
- {
- return "(Select Case When IsFavorite is null Then 0 Else IsFavorite End )";
- }
-
- if (string.Equals(name, ItemSortBy.IsFolder, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.IsFolder;
- }
-
- if (string.Equals(name, ItemSortBy.IsPlayed, StringComparison.OrdinalIgnoreCase))
- {
- return "played";
- }
-
- if (string.Equals(name, ItemSortBy.IsUnplayed, StringComparison.OrdinalIgnoreCase))
- {
- return "played";
- }
-
- if (string.Equals(name, ItemSortBy.DateLastContentAdded, StringComparison.OrdinalIgnoreCase))
- {
- return "DateLastMediaAdded";
- }
-
- if (string.Equals(name, ItemSortBy.Artist, StringComparison.OrdinalIgnoreCase))
- {
- return "(select CleanValue from ItemValues where ItemId=Guid and Type=0 LIMIT 1)";
- }
-
- if (string.Equals(name, ItemSortBy.AlbumArtist, StringComparison.OrdinalIgnoreCase))
- {
- return "(select CleanValue from ItemValues where ItemId=Guid and Type=1 LIMIT 1)";
- }
-
- if (string.Equals(name, ItemSortBy.OfficialRating, StringComparison.OrdinalIgnoreCase))
- {
- return "InheritedParentalRatingValue";
- }
-
- if (string.Equals(name, ItemSortBy.Studio, StringComparison.OrdinalIgnoreCase))
- {
- return "(select CleanValue from ItemValues where ItemId=Guid and Type=3 LIMIT 1)";
- }
-
- if (string.Equals(name, ItemSortBy.SeriesDatePlayed, StringComparison.OrdinalIgnoreCase))
- {
- return "(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)";
- }
-
- if (string.Equals(name, ItemSortBy.SeriesSortName, StringComparison.OrdinalIgnoreCase))
- {
- return "SeriesName";
- }
-
- if (string.Equals(name, ItemSortBy.AiredEpisodeOrder, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.AiredEpisodeOrder;
- }
-
- if (string.Equals(name, ItemSortBy.Album, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.Album;
- }
-
- if (string.Equals(name, ItemSortBy.DateCreated, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.DateCreated;
- }
-
- if (string.Equals(name, ItemSortBy.PremiereDate, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.PremiereDate;
- }
-
- if (string.Equals(name, ItemSortBy.StartDate, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.StartDate;
- }
-
- if (string.Equals(name, ItemSortBy.Name, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.Name;
- }
-
- if (string.Equals(name, ItemSortBy.CommunityRating, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.CommunityRating;
- }
-
- if (string.Equals(name, ItemSortBy.ProductionYear, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.ProductionYear;
- }
-
- if (string.Equals(name, ItemSortBy.CriticRating, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.CriticRating;
- }
-
- if (string.Equals(name, ItemSortBy.VideoBitRate, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.VideoBitRate;
- }
-
- if (string.Equals(name, ItemSortBy.ParentIndexNumber, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.ParentIndexNumber;
- }
-
- if (string.Equals(name, ItemSortBy.IndexNumber, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.IndexNumber;
- }
-
- if (string.Equals(name, ItemSortBy.SimilarityScore, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.SimilarityScore;
- }
-
- if (string.Equals(name, ItemSortBy.SearchScore, StringComparison.OrdinalIgnoreCase))
- {
- return ItemSortBy.SearchScore;
- }
-
- // Unknown SortBy, just sort by the SortName.
- return ItemSortBy.SortName;
+ return sortBy switch
+ {
+ ItemSortBy.AirTime => "SortName", // TODO
+ ItemSortBy.Runtime => "RuntimeTicks",
+ ItemSortBy.Random => "RANDOM()",
+ ItemSortBy.DatePlayed when query.GroupBySeriesPresentationUniqueKey => "MAX(LastPlayedDate)",
+ ItemSortBy.DatePlayed => "LastPlayedDate",
+ ItemSortBy.PlayCount => "PlayCount",
+ ItemSortBy.IsFavoriteOrLiked => "(Select Case When IsFavorite is null Then 0 Else IsFavorite End )",
+ ItemSortBy.IsFolder => "IsFolder",
+ ItemSortBy.IsPlayed => "played",
+ ItemSortBy.IsUnplayed => "played",
+ ItemSortBy.DateLastContentAdded => "DateLastMediaAdded",
+ ItemSortBy.Artist => "(select CleanValue from ItemValues where ItemId=Guid and Type=0 LIMIT 1)",
+ ItemSortBy.AlbumArtist => "(select CleanValue from ItemValues where ItemId=Guid and Type=1 LIMIT 1)",
+ ItemSortBy.OfficialRating => "InheritedParentalRatingValue",
+ ItemSortBy.Studio => "(select CleanValue from ItemValues where ItemId=Guid and Type=3 LIMIT 1)",
+ ItemSortBy.SeriesDatePlayed => "(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)",
+ ItemSortBy.SeriesSortName => "SeriesName",
+ ItemSortBy.AiredEpisodeOrder => "AiredEpisodeOrder",
+ ItemSortBy.Album => "Album",
+ ItemSortBy.DateCreated => "DateCreated",
+ ItemSortBy.PremiereDate => "PremiereDate",
+ ItemSortBy.StartDate => "StartDate",
+ ItemSortBy.Name => "Name",
+ ItemSortBy.CommunityRating => "CommunityRating",
+ ItemSortBy.ProductionYear => "ProductionYear",
+ ItemSortBy.CriticRating => "CriticRating",
+ ItemSortBy.VideoBitRate => "VideoBitRate",
+ ItemSortBy.ParentIndexNumber => "ParentIndexNumber",
+ ItemSortBy.IndexNumber => "IndexNumber",
+ ItemSortBy.SimilarityScore => "SimilarityScore",
+ ItemSortBy.SearchScore => "SearchScore",
+ _ => "SortName"
+ };
}
public List GetItemIdsList(InternalItemsQuery query)
diff --git a/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs b/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
index 539d4a63a..04d90af3c 100644
--- a/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
+++ b/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Images
Recursive = true,
DtoOptions = new DtoOptions(true),
ImageTypes = new ImageType[] { ImageType.Primary },
- OrderBy = new (string, SortOrder)[]
+ OrderBy = new (ItemSortBy, SortOrder)[]
{
(ItemSortBy.IsFolder, SortOrder.Ascending),
(ItemSortBy.SortName, SortOrder.Ascending)
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 4f0983564..5c76e77be 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -1678,7 +1678,7 @@ namespace Emby.Server.Implementations.Library
/// The sort by.
/// The sort order.
/// IEnumerable{BaseItem}.
- public IEnumerable Sort(IEnumerable items, User user, IEnumerable sortBy, SortOrder sortOrder)
+ public IEnumerable Sort(IEnumerable items, User user, IEnumerable sortBy, SortOrder sortOrder)
{
var isFirst = true;
@@ -1701,7 +1701,7 @@ namespace Emby.Server.Implementations.Library
return orderedItems ?? items;
}
- public IEnumerable Sort(IEnumerable items, User user, IEnumerable<(string OrderBy, SortOrder SortOrder)> orderBy)
+ public IEnumerable Sort(IEnumerable items, User user, IEnumerable<(ItemSortBy OrderBy, SortOrder SortOrder)> orderBy)
{
var isFirst = true;
@@ -1736,9 +1736,9 @@ namespace Emby.Server.Implementations.Library
/// The name.
/// The user.
/// IBaseItemComparer.
- private IBaseItemComparer GetComparer(string name, User user)
+ private IBaseItemComparer GetComparer(ItemSortBy name, User user)
{
- var comparer = Comparers.FirstOrDefault(c => string.Equals(name, c.Name, StringComparison.OrdinalIgnoreCase));
+ var comparer = Comparers.FirstOrDefault(c => name == c.Type);
// If it requires a user, create a new one, and assign the user
if (comparer is IUserBaseItemComparer)
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index ee039ff0f..dd427c736 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.LiveTv
orderBy.Insert(0, (ItemSortBy.IsFavoriteOrLiked, SortOrder.Descending));
}
- if (!internalQuery.OrderBy.Any(i => string.Equals(i.OrderBy, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase)))
+ if (internalQuery.OrderBy.All(i => i.OrderBy != ItemSortBy.SortName))
{
orderBy.Add((ItemSortBy.SortName, SortOrder.Ascending));
}
diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
index 964004ecc..6d13c6d57 100644
--- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Sorting;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.AiredEpisodeOrder;
+ public ItemSortBy Type => ItemSortBy.AiredEpisodeOrder;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
index 67a9fbd3b..65c8599e7 100644
--- a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
@@ -16,7 +17,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.AlbumArtist;
+ public ItemSortBy Type => ItemSortBy.AlbumArtist;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/AlbumComparer.cs b/Emby.Server.Implementations/Sorting/AlbumComparer.cs
index 4bed0fca1..e07113655 100644
--- a/Emby.Server.Implementations/Sorting/AlbumComparer.cs
+++ b/Emby.Server.Implementations/Sorting/AlbumComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
@@ -15,7 +16,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.Album;
+ public ItemSortBy Type => ItemSortBy.Album;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
index a8bb55e2b..f99977e5c 100644
--- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Sorting;
@@ -12,7 +13,7 @@ namespace Emby.Server.Implementations.Sorting
public class ArtistComparer : IBaseItemComparer
{
///
- public string Name => ItemSortBy.Artist;
+ public ItemSortBy Type => ItemSortBy.Artist;
///
public int Compare(BaseItem? x, BaseItem? y)
diff --git a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
index 5cb11ab46..9e02ea2ae 100644
--- a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.CommunityRating;
+ public ItemSortBy Type => ItemSortBy.CommunityRating;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs b/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
index ba1835e4f..d4a8d4689 100644
--- a/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/CriticRatingComparer.cs
@@ -1,3 +1,4 @@
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.CriticRating;
+ public ItemSortBy Type => ItemSortBy.CriticRating;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
index 6133aaccc..b86b4432f 100644
--- a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.DateCreated;
+ public ItemSortBy Type => ItemSortBy.DateCreated;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
index b1cb123ce..e1c26d012 100644
--- a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
@@ -3,6 +3,7 @@
using System;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -34,7 +35,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.DateLastContentAdded;
+ public ItemSortBy Type => ItemSortBy.DateLastContentAdded;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
index 453d817c7..d668c17bf 100644
--- a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
@@ -2,6 +2,7 @@
using System;
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -36,7 +37,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.DatePlayed;
+ public ItemSortBy Type => ItemSortBy.DatePlayed;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs b/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs
index 1bcaccd8a..11cad6256 100644
--- a/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.IndexNumber;
+ public ItemSortBy Type => ItemSortBy.IndexNumber;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
index 73e628cf7..622a341b6 100644
--- a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
@@ -2,6 +2,7 @@
#pragma warning disable CS1591
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -21,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.IsFavoriteOrLiked;
+ public ItemSortBy Type => ItemSortBy.IsFavoriteOrLiked;
///
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/IsFolderComparer.cs b/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
index 3c5ddeefa..6f0ca59c5 100644
--- a/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsFolderComparer.cs
@@ -1,5 +1,6 @@
#pragma warning disable CS1591
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -12,7 +13,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.IsFolder;
+ public ItemSortBy Type => ItemSortBy.IsFolder;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
index 7d77a8bc5..2a3e456c2 100644
--- a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
@@ -3,6 +3,7 @@
#pragma warning disable CS1591
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -22,7 +23,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.IsUnplayed;
+ public ItemSortBy Type => ItemSortBy.IsUnplayed;
///
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
index 926835f90..afd8ccf9f 100644
--- a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
@@ -3,6 +3,7 @@
#pragma warning disable CS1591
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -22,7 +23,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.IsUnplayed;
+ public ItemSortBy Type => ItemSortBy.IsUnplayed;
///
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/NameComparer.cs b/Emby.Server.Implementations/Sorting/NameComparer.cs
index 93bec4db9..72d9c7973 100644
--- a/Emby.Server.Implementations/Sorting/NameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/NameComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.Name;
+ public ItemSortBy Type => ItemSortBy.Name;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
index ce44f99a6..b4ee2c723 100644
--- a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Globalization;
@@ -21,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.OfficialRating;
+ public ItemSortBy Type => ItemSortBy.OfficialRating;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs b/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs
index c54750843..5aeac29be 100644
--- a/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.ParentIndexNumber;
+ public ItemSortBy Type => ItemSortBy.ParentIndexNumber;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
index 16f1b79b3..12f88bf4d 100644
--- a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
@@ -1,6 +1,7 @@
#nullable disable
using Jellyfin.Data.Entities;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
@@ -23,7 +24,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.PlayCount;
+ public ItemSortBy Type => ItemSortBy.PlayCount;
///
/// Gets or sets the user data repository.
diff --git a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
index db86b8002..8c8b8824f 100644
--- a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.PremiereDate;
+ public ItemSortBy Type => ItemSortBy.PremiereDate;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
index 7fd1e024d..9aec87f18 100644
--- a/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ProductionYearComparer.cs
@@ -1,3 +1,4 @@
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.ProductionYear;
+ public ItemSortBy Type => ItemSortBy.ProductionYear;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/RandomComparer.cs b/Emby.Server.Implementations/Sorting/RandomComparer.cs
index bf0168222..6f8ea5b74 100644
--- a/Emby.Server.Implementations/Sorting/RandomComparer.cs
+++ b/Emby.Server.Implementations/Sorting/RandomComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.Random;
+ public ItemSortBy Type => ItemSortBy.Random;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
index 753e58324..3c096ab02 100644
--- a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.Runtime;
+ public ItemSortBy Type => ItemSortBy.Runtime;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
index 5b6c64f63..ed42fd6d5 100644
--- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.SeriesSortName;
+ public ItemSortBy Type => ItemSortBy.SeriesSortName;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/SortNameComparer.cs b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
index 19abafe19..314c25d12 100644
--- a/Emby.Server.Implementations/Sorting/SortNameComparer.cs
+++ b/Emby.Server.Implementations/Sorting/SortNameComparer.cs
@@ -1,4 +1,5 @@
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.SortName;
+ public ItemSortBy Type => ItemSortBy.SortName;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/StartDateComparer.cs b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
index 2759d20de..e0b438ef1 100644
--- a/Emby.Server.Implementations/Sorting/StartDateComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StartDateComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Sorting;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.StartDate;
+ public ItemSortBy Type => ItemSortBy.StartDate;
///
/// Compares the specified x.
diff --git a/Emby.Server.Implementations/Sorting/StudioComparer.cs b/Emby.Server.Implementations/Sorting/StudioComparer.cs
index 89d10f3d2..0edffb783 100644
--- a/Emby.Server.Implementations/Sorting/StudioComparer.cs
+++ b/Emby.Server.Implementations/Sorting/StudioComparer.cs
@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
@@ -14,7 +15,7 @@ namespace Emby.Server.Implementations.Sorting
/// Gets the name.
///
/// The name.
- public string Name => ItemSortBy.Studio;
+ public ItemSortBy Type => ItemSortBy.Studio;
///
/// Compares the specified x.
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index c9d2f67f9..c3c43982b 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -113,7 +113,7 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
@@ -317,7 +317,7 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
diff --git a/Jellyfin.Api/Controllers/ChannelsController.cs b/Jellyfin.Api/Controllers/ChannelsController.cs
index 11c4ac376..fdc16ee23 100644
--- a/Jellyfin.Api/Controllers/ChannelsController.cs
+++ b/Jellyfin.Api/Controllers/ChannelsController.cs
@@ -122,7 +122,7 @@ public class ChannelsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields)
{
userId = RequestHelpers.GetUserId(User, userId);
diff --git a/Jellyfin.Api/Controllers/GenresController.cs b/Jellyfin.Api/Controllers/GenresController.cs
index da60f2c60..51f04fa27 100644
--- a/Jellyfin.Api/Controllers/GenresController.cs
+++ b/Jellyfin.Api/Controllers/GenresController.cs
@@ -85,7 +85,7 @@ public class GenresController : BaseJellyfinApiController
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs
index 80128536d..891cf88a7 100644
--- a/Jellyfin.Api/Controllers/ItemsController.cs
+++ b/Jellyfin.Api/Controllers/ItemsController.cs
@@ -197,7 +197,7 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? isFavorite,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
@@ -654,7 +654,7 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? isFavorite,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 649397d68..58159406a 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -143,7 +143,7 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableUserData,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery] SortOrder? sortOrder,
[FromQuery] bool enableFavoriteSorting = false,
[FromQuery] bool addCurrentProgram = true)
@@ -547,7 +547,7 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] bool? isSports,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
diff --git a/Jellyfin.Api/Controllers/MusicGenresController.cs b/Jellyfin.Api/Controllers/MusicGenresController.cs
index 435457af6..94c899357 100644
--- a/Jellyfin.Api/Controllers/MusicGenresController.cs
+++ b/Jellyfin.Api/Controllers/MusicGenresController.cs
@@ -85,7 +85,7 @@ public class MusicGenresController : BaseJellyfinApiController
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
diff --git a/Jellyfin.Api/Controllers/TrailersController.cs b/Jellyfin.Api/Controllers/TrailersController.cs
index b5b640620..1246efd49 100644
--- a/Jellyfin.Api/Controllers/TrailersController.cs
+++ b/Jellyfin.Api/Controllers/TrailersController.cs
@@ -162,7 +162,7 @@ public class TrailersController : BaseJellyfinApiController
[FromQuery] bool? isFavorite,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
[FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs
index af403fa80..55a30d469 100644
--- a/Jellyfin.Api/Controllers/TvShowsController.cs
+++ b/Jellyfin.Api/Controllers/TvShowsController.cs
@@ -219,7 +219,7 @@ public class TvShowsController : BaseJellyfinApiController
[FromQuery] int? imageTypeLimit,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
- [FromQuery] string? sortBy)
+ [FromQuery] ItemSortBy? sortBy)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.Value.Equals(default)
@@ -289,7 +289,7 @@ public class TvShowsController : BaseJellyfinApiController
episodes = UserViewBuilder.FilterForAdjacency(episodes, adjacentTo.Value).ToList();
}
- if (string.Equals(sortBy, ItemSortBy.Random, StringComparison.OrdinalIgnoreCase))
+ if (sortBy == ItemSortBy.Random)
{
episodes.Shuffle();
}
diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs
index 74370db50..641cdd81e 100644
--- a/Jellyfin.Api/Controllers/YearsController.cs
+++ b/Jellyfin.Api/Controllers/YearsController.cs
@@ -77,7 +77,7 @@ public class YearsController : BaseJellyfinApiController
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs
index bc12ca388..be3d4dfb6 100644
--- a/Jellyfin.Api/Helpers/RequestHelpers.cs
+++ b/Jellyfin.Api/Helpers/RequestHelpers.cs
@@ -30,14 +30,14 @@ public static class RequestHelpers
/// Sort By. Comma delimited string.
/// Sort Order. Comma delimited string.
/// Order By.
- public static (string, SortOrder)[] GetOrderBy(IReadOnlyList sortBy, IReadOnlyList requestedSortOrder)
+ public static (ItemSortBy, SortOrder)[] GetOrderBy(IReadOnlyList sortBy, IReadOnlyList requestedSortOrder)
{
if (sortBy.Count == 0)
{
- return Array.Empty<(string, SortOrder)>();
+ return Array.Empty<(ItemSortBy, SortOrder)>();
}
- var result = new (string, SortOrder)[sortBy.Count];
+ var result = new (ItemSortBy, SortOrder)[sortBy.Count];
var i = 0;
// Add elements which have a SortOrder specified
for (; i < requestedSortOrder.Count; i++)
diff --git a/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs b/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
index 5e7dd689e..6a30de5e6 100644
--- a/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
+++ b/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
@@ -107,7 +107,7 @@ public class GetProgramsDto
/// Optional.
///
[JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
- public IReadOnlyList SortBy { get; set; } = Array.Empty();
+ public IReadOnlyList SortBy { get; set; } = Array.Empty();
///
/// Gets or sets sort Order - Ascending,Descending.
diff --git a/Jellyfin.Data/Enums/ItemSortBy.cs b/Jellyfin.Data/Enums/ItemSortBy.cs
new file mode 100644
index 000000000..17bf1166d
--- /dev/null
+++ b/Jellyfin.Data/Enums/ItemSortBy.cs
@@ -0,0 +1,167 @@
+namespace Jellyfin.Data.Enums;
+
+///
+/// These represent sort orders.
+///
+public enum ItemSortBy
+{
+ ///
+ /// Default sort order.
+ ///
+ Default = 0,
+
+ ///
+ /// The aired episode order.
+ ///
+ AiredEpisodeOrder = 1,
+
+ ///
+ /// The album.
+ ///
+ Album = 2,
+
+ ///
+ /// The album artist.
+ ///
+ AlbumArtist = 3,
+
+ ///
+ /// The artist.
+ ///
+ Artist = 4,
+
+ ///
+ /// The date created.
+ ///
+ DateCreated = 5,
+
+ ///
+ /// The official rating.
+ ///
+ OfficialRating = 6,
+
+ ///
+ /// The date played.
+ ///
+ DatePlayed = 7,
+
+ ///
+ /// The premiere date.
+ ///
+ PremiereDate = 8,
+
+ ///
+ /// The start date.
+ ///
+ StartDate = 9,
+
+ ///
+ /// The sort name.
+ ///
+ SortName = 10,
+
+ ///
+ /// The name.
+ ///
+ Name = 11,
+
+ ///
+ /// The random.
+ ///
+ Random = 12,
+
+ ///
+ /// The runtime.
+ ///
+ Runtime = 13,
+
+ ///
+ /// The community rating.
+ ///
+ CommunityRating = 14,
+
+ ///
+ /// The production year.
+ ///
+ ProductionYear = 15,
+
+ ///
+ /// The play count.
+ ///
+ PlayCount = 16,
+
+ ///
+ /// The critic rating.
+ ///
+ CriticRating = 17,
+
+ ///
+ /// The IsFolder boolean.
+ ///
+ IsFolder = 18,
+
+ ///
+ /// The IsUnplayed boolean.
+ ///
+ IsUnplayed = 19,
+
+ ///
+ /// The IsPlayed boolean.
+ ///
+ IsPlayed = 20,
+
+ ///
+ /// The series sort.
+ ///
+ SeriesSortName = 21,
+
+ ///
+ /// The video bitrate.
+ ///
+ VideoBitRate = 22,
+
+ ///
+ /// The air time.
+ ///
+ AirTime = 23,
+
+ ///
+ /// The studio.
+ ///
+ Studio = 24,
+
+ ///
+ /// The IsFavouriteOrLiked boolean.
+ ///
+ IsFavoriteOrLiked = 25,
+
+ ///
+ /// The last content added date.
+ ///
+ DateLastContentAdded = 26,
+
+ ///
+ /// The series last played date.
+ ///
+ SeriesDatePlayed = 27,
+
+ ///
+ /// The parent index number.
+ ///
+ ParentIndexNumber = 28,
+
+ ///
+ /// The index number.
+ ///
+ IndexNumber = 29,
+
+ ///
+ /// The similarity score.
+ ///
+ SimilarityScore = 30,
+
+ ///
+ /// The search score.
+ ///
+ SearchScore = 31,
+}
diff --git a/MediaBrowser.Controller/Entities/IHasDisplayOrder.cs b/MediaBrowser.Controller/Entities/IHasDisplayOrder.cs
index 14459624e..7a73f3eaf 100644
--- a/MediaBrowser.Controller/Entities/IHasDisplayOrder.cs
+++ b/MediaBrowser.Controller/Entities/IHasDisplayOrder.cs
@@ -1,5 +1,7 @@
#nullable disable
+using Jellyfin.Data.Enums;
+
namespace MediaBrowser.Controller.Entities
{
///
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index a51299284..fb50a4546 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.Entities
MediaTypes = Array.Empty();
MinSimilarityScore = 20;
OfficialRatings = Array.Empty();
- OrderBy = Array.Empty<(string, SortOrder)>();
+ OrderBy = Array.Empty<(ItemSortBy, SortOrder)>();
PersonIds = Array.Empty();
PersonTypes = Array.Empty();
PresetViews = Array.Empty();
@@ -284,7 +284,7 @@ namespace MediaBrowser.Controller.Entities
public bool? HasChapterImages { get; set; }
- public IReadOnlyList<(string OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
+ public IReadOnlyList<(ItemSortBy OrderBy, SortOrder SortOrder)> OrderBy { get; set; }
public DateTime? MinDateCreated { get; set; }
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index 66210cb6c..d7ccfd8ae 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
public BoxSet()
{
- DisplayOrder = ItemSortBy.PremiereDate;
+ DisplayOrder = "PremiereDate";
}
[JsonIgnore]
@@ -116,13 +116,13 @@ namespace MediaBrowser.Controller.Entities.Movies
{
var children = base.GetChildren(user, includeLinkedChildren, query);
- if (string.Equals(DisplayOrder, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(DisplayOrder, "SortName", StringComparison.OrdinalIgnoreCase))
{
// Sort by name
return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList();
}
- if (string.Equals(DisplayOrder, ItemSortBy.PremiereDate, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase))
{
// Sort by release date
return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList();
@@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
var children = base.GetRecursiveChildren(user, query);
- if (string.Equals(DisplayOrder, ItemSortBy.PremiereDate, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase))
{
// Sort by release date
return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList();
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index f34e3d68d..52d546a4f 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -199,9 +199,9 @@ namespace MediaBrowser.Controller.Library
/// The sort by.
/// The sort order.
/// IEnumerable{BaseItem}.
- IEnumerable Sort(IEnumerable items, User user, IEnumerable sortBy, SortOrder sortOrder);
+ IEnumerable Sort(IEnumerable items, User user, IEnumerable sortBy, SortOrder sortOrder);
- IEnumerable Sort(IEnumerable items, User user, IEnumerable<(string OrderBy, SortOrder SortOrder)> orderBy);
+ IEnumerable Sort(IEnumerable items, User user, IEnumerable<(ItemSortBy OrderBy, SortOrder SortOrder)> orderBy);
///
/// Gets the user root folder.
diff --git a/MediaBrowser.Controller/Providers/EpisodeInfo.cs b/MediaBrowser.Controller/Providers/EpisodeInfo.cs
index c4ad352a3..2f7ebb5cc 100644
--- a/MediaBrowser.Controller/Providers/EpisodeInfo.cs
+++ b/MediaBrowser.Controller/Providers/EpisodeInfo.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
+using Jellyfin.Data.Enums;
namespace MediaBrowser.Controller.Providers
{
diff --git a/MediaBrowser.Controller/Sorting/IBaseItemComparer.cs b/MediaBrowser.Controller/Sorting/IBaseItemComparer.cs
index 07fe1ea8a..96f8a2af5 100644
--- a/MediaBrowser.Controller/Sorting/IBaseItemComparer.cs
+++ b/MediaBrowser.Controller/Sorting/IBaseItemComparer.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Sorting
@@ -9,9 +10,8 @@ namespace MediaBrowser.Controller.Sorting
public interface IBaseItemComparer : IComparer
{
///
- /// Gets the name.
+ /// Gets the comparer type.
///
- /// The name.
- string Name { get; }
+ ItemSortBy Type { get; }
}
}
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index f913b2320..5a7193079 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -6,6 +6,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
diff --git a/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs b/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs
index 673d97a9e..d872572b7 100644
--- a/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs
+++ b/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Model.LiveTv
public LiveTvChannelQuery()
{
EnableUserData = true;
- SortBy = Array.Empty();
+ SortBy = Array.Empty();
}
///
@@ -99,7 +99,7 @@ namespace MediaBrowser.Model.LiveTv
public bool? IsSeries { get; set; }
- public string[] SortBy { get; set; }
+ public ItemSortBy[] SortBy { get; set; }
///
/// Gets or sets the sort order to return results with.
diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs
deleted file mode 100644
index 1a7c9a63b..000000000
--- a/MediaBrowser.Model/Querying/ItemSortBy.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-namespace MediaBrowser.Model.Querying
-{
- ///
- /// These represent sort orders that are known by the core.
- ///
- public static class ItemSortBy
- {
- ///
- /// The aired episode order.
- ///
- public const string AiredEpisodeOrder = "AiredEpisodeOrder";
-
- ///
- /// The album.
- ///
- public const string Album = "Album";
-
- ///
- /// The album artist.
- ///
- public const string AlbumArtist = "AlbumArtist";
-
- ///
- /// The artist.
- ///
- public const string Artist = "Artist";
-
- ///
- /// The date created.
- ///
- public const string DateCreated = "DateCreated";
-
- ///
- /// The official rating.
- ///
- public const string OfficialRating = "OfficialRating";
-
- ///
- /// The date played.
- ///
- public const string DatePlayed = "DatePlayed";
-
- ///
- /// The premiere date.
- ///
- public const string PremiereDate = "PremiereDate";
-
- ///
- /// The start date.
- ///
- public const string StartDate = "StartDate";
-
- ///
- /// The sort name.
- ///
- public const string SortName = "SortName";
-
- ///
- /// The name.
- ///
- public const string Name = "Name";
-
- ///
- /// The random.
- ///
- public const string Random = "Random";
-
- ///
- /// The runtime.
- ///
- public const string Runtime = "Runtime";
-
- ///
- /// The community rating.
- ///
- public const string CommunityRating = "CommunityRating";
-
- ///
- /// The production year.
- ///
- public const string ProductionYear = "ProductionYear";
-
- ///
- /// The play count.
- ///
- public const string PlayCount = "PlayCount";
-
- ///
- /// The critic rating.
- ///
- public const string CriticRating = "CriticRating";
-
- ///
- /// The IsFolder boolean.
- ///
- public const string IsFolder = "IsFolder";
-
- ///
- /// The IsUnplayed boolean.
- ///
- public const string IsUnplayed = "IsUnplayed";
-
- ///
- /// The IsPlayed boolean.
- ///
- public const string IsPlayed = "IsPlayed";
-
- ///
- /// The series sort.
- ///
- public const string SeriesSortName = "SeriesSortName";
-
- ///
- /// The video bitrate.
- ///
- public const string VideoBitRate = "VideoBitRate";
-
- ///
- /// The air time.
- ///
- public const string AirTime = "AirTime";
-
- ///
- /// The studio.
- ///
- public const string Studio = "Studio";
-
- ///
- /// The IsFavouriteOrLiked boolean.
- ///
- public const string IsFavoriteOrLiked = "IsFavoriteOrLiked";
-
- ///
- /// The last content added date.
- ///
- public const string DateLastContentAdded = "DateLastContentAdded";
-
- ///
- /// The series last played date.
- ///
- public const string SeriesDatePlayed = "SeriesDatePlayed";
-
- ///
- /// The parent index number.
- ///
- public const string ParentIndexNumber = "ParentIndexNumber";
-
- ///
- /// The index number.
- ///
- public const string IndexNumber = "IndexNumber";
-
- ///
- /// The similarity score.
- ///
- public const string SimilarityScore = "SimilarityScore";
-
- ///
- /// The search score.
- ///
- public const string SearchScore = "SearchScore";
- }
-}
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index e336c8825..06445c90d 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
index 500ebaf71..72e59c9ac 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
diff --git a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
index 2d7741d81..a2d1b3607 100644
--- a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
+++ b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
@@ -14,7 +14,7 @@ namespace Jellyfin.Api.Tests.Helpers
{
[Theory]
[MemberData(nameof(GetOrderBy_Success_TestData))]
- public static void GetOrderBy_Success(IReadOnlyList sortBy, IReadOnlyList requestedSortOrder, (string, SortOrder)[] expected)
+ public static void GetOrderBy_Success(IReadOnlyList sortBy, IReadOnlyList requestedSortOrder, (ItemSortBy, SortOrder)[] expected)
{
Assert.Equal(expected, RequestHelpers.GetOrderBy(sortBy, requestedSortOrder));
}
@@ -95,42 +95,42 @@ namespace Jellyfin.Api.Tests.Helpers
Assert.Throws(() => RequestHelpers.GetUserId(principal, requestUserId));
}
- public static TheoryData, IReadOnlyList, (string, SortOrder)[]> GetOrderBy_Success_TestData()
+ public static TheoryData, IReadOnlyList, (ItemSortBy, SortOrder)[]> GetOrderBy_Success_TestData()
{
- var data = new TheoryData, IReadOnlyList, (string, SortOrder)[]>();
+ var data = new TheoryData, IReadOnlyList, (ItemSortBy, SortOrder)[]>();
data.Add(
- Array.Empty(),
+ Array.Empty(),
Array.Empty(),
- Array.Empty<(string, SortOrder)>());
+ Array.Empty<(ItemSortBy, SortOrder)>());
data.Add(
- new string[]
+ new[]
{
- "IsFavoriteOrLiked",
- "Random"
+ ItemSortBy.IsFavoriteOrLiked,
+ ItemSortBy.Random
},
Array.Empty(),
- new (string, SortOrder)[]
+ new (ItemSortBy, SortOrder)[]
{
- ("IsFavoriteOrLiked", SortOrder.Ascending),
- ("Random", SortOrder.Ascending),
+ (ItemSortBy.IsFavoriteOrLiked, SortOrder.Ascending),
+ (ItemSortBy.Random, SortOrder.Ascending),
});
data.Add(
- new string[]
+ new[]
{
- "SortName",
- "ProductionYear"
+ ItemSortBy.SortName,
+ ItemSortBy.ProductionYear
},
- new SortOrder[]
+ new[]
{
SortOrder.Descending
},
- new (string, SortOrder)[]
+ new (ItemSortBy, SortOrder)[]
{
- ("SortName", SortOrder.Descending),
- ("ProductionYear", SortOrder.Descending),
+ (ItemSortBy.SortName, SortOrder.Descending),
+ (ItemSortBy.ProductionYear, SortOrder.Descending),
});
return data;
--
cgit v1.2.3