The Free Software Media System - Server Backend & API
Lowercase CollectionTypeOptions to match legacy experience (#11272)
Cody Robibero3ade3a8e6320
diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.csindex b34d0f21ef..e414792ba0 100644--- a/Emby.Server.Implementations/Collections/CollectionManager.cs+++ b/Emby.Server.Implementations/Collections/CollectionManager.cs@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Collectionsvar name = _localizationManager.GetLocalizedString("Collections");- await _libraryManager.AddVirtualFolder(name, CollectionTypeOptions.BoxSets, libraryOptions, true).ConfigureAwait(false);+ await _libraryManager.AddVirtualFolder(name, CollectionTypeOptions.boxsets, libraryOptions, true).ConfigureAwait(false);return FindFolders(path).First();}diff --git a/MediaBrowser.Model/Entities/CollectionTypeOptions.cs b/MediaBrowser.Model/Entities/CollectionTypeOptions.csindex e1894d84ad..fc4cfdd66c 100644--- a/MediaBrowser.Model/Entities/CollectionTypeOptions.cs+++ b/MediaBrowser.Model/Entities/CollectionTypeOptions.cs@@ -1,16 +1,49 @@-#pragma warning disable CS1591+#pragma warning disable SA1300 // Lowercase required for backwards compat.-namespace MediaBrowser.Model.Entities+namespace MediaBrowser.Model.Entities;++/// <summary>+/// The collection type options.+/// </summary>+public enum CollectionTypeOptions{- public enum CollectionTypeOptions- {- Movies = 0,- TvShows = 1,- Music = 2,- MusicVideos = 3,- HomeVideos = 4,- BoxSets = 5,- Books = 6,- Mixed = 7- }+ /// <summary>+ /// Movies.+ /// </summary>+ movies = 0,++ /// <summary>+ /// TV Shows.+ /// </summary>+ tvshows = 1,++ /// <summary>+ /// Music.+ /// </summary>+ music = 2,++ /// <summary>+ /// Music Videos.+ /// </summary>+ musicvideos = 3,++ /// <summary>+ /// Home Videos (and Photos).+ /// </summary>+ homevideos = 4,++ /// <summary>+ /// Box Sets.+ /// </summary>+ boxsets = 5,++ /// <summary>+ /// Books.+ /// </summary>+ books = 6,++ /// <summary>+ /// Mixed Movies and TV Shows.+ /// </summary>+ mixed = 7}diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.csindex 2b2bda12c3..89bb72c3c8 100644--- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs+++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs@@ -37,7 +37,6 @@ namespace MediaBrowser.Model.Entities/// Gets or sets the type of the collection./// </summary>/// <value>The type of the collection.</value>- [JsonConverter(typeof(JsonLowerCaseConverter<CollectionTypeOptions?>))]public CollectionTypeOptions? CollectionType { get; set; }public LibraryOptions LibraryOptions { get; set; }diff --git a/src/Jellyfin.Extensions/Json/Converters/JsonLowerCaseConverter.cs b/src/Jellyfin.Extensions/Json/Converters/JsonLowerCaseConverter.csdeleted file mode 100644index cd582ced64..0000000000--- a/src/Jellyfin.Extensions/Json/Converters/JsonLowerCaseConverter.cs+++ /dev/null@@ -1,25 +0,0 @@-using System;-using System.Text.Json;-using System.Text.Json.Serialization;--namespace Jellyfin.Extensions.Json.Converters-{- /// <summary>- /// Converts an object to a lowercase string.- /// </summary>- /// <typeparam name="T">The object type.</typeparam>- public class JsonLowerCaseConverter<T> : JsonConverter<T>- {- /// <inheritdoc />- public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)- {- return JsonSerializer.Deserialize<T>(ref reader, options);- }-- /// <inheritdoc />- public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)- {- writer.WriteStringValue(value?.ToString()?.ToLowerInvariant());- }- }-}diff --git a/src/Jellyfin.LiveTv/Recordings/RecordingsManager.cs b/src/Jellyfin.LiveTv/Recordings/RecordingsManager.csindex 92605a1eb9..2f4caa3867 100644--- a/src/Jellyfin.LiveTv/Recordings/RecordingsManager.cs+++ b/src/Jellyfin.LiveTv/Recordings/RecordingsManager.cs@@ -159,7 +159,7 @@ public sealed class RecordingsManager : IRecordingsManager, IDisposable{Locations = [customPath],Name = "Recorded Movies",- CollectionType = CollectionTypeOptions.Movies+ CollectionType = CollectionTypeOptions.movies};}@@ -172,7 +172,7 @@ public sealed class RecordingsManager : IRecordingsManager, IDisposable{Locations = [customPath],Name = "Recorded Shows",- CollectionType = CollectionTypeOptions.TvShows+ CollectionType = CollectionTypeOptions.tvshows};}}diff --git a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonLowerCaseConverterTests.cs b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonLowerCaseConverterTests.csdeleted file mode 100644index 16c69ca489..0000000000--- a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonLowerCaseConverterTests.cs+++ /dev/null@@ -1,71 +0,0 @@-using System.Text.Json;-using System.Text.Json.Serialization;-using Jellyfin.Extensions.Json.Converters;-using MediaBrowser.Model.Entities;-using Xunit;--namespace Jellyfin.Extensions.Tests.Json.Converters-{- public class JsonLowerCaseConverterTests- {- private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()- {- Converters =- {- new JsonStringEnumConverter()- }- };-- [Theory]- [InlineData(null, "{\"CollectionType\":null}")]- [InlineData(CollectionTypeOptions.Movies, "{\"CollectionType\":\"movies\"}")]- [InlineData(CollectionTypeOptions.MusicVideos, "{\"CollectionType\":\"musicvideos\"}")]- public void Serialize_CollectionTypeOptions_Correct(CollectionTypeOptions? collectionType, string expected)- {- Assert.Equal(expected, JsonSerializer.Serialize(new TestContainer(collectionType), _jsonOptions));- }-- [Theory]- [InlineData("{\"CollectionType\":null}", null)]- [InlineData("{\"CollectionType\":\"movies\"}", CollectionTypeOptions.Movies)]- [InlineData("{\"CollectionType\":\"musicvideos\"}", CollectionTypeOptions.MusicVideos)]- public void Deserialize_CollectionTypeOptions_Correct(string json, CollectionTypeOptions? result)- {- var res = JsonSerializer.Deserialize<TestContainer>(json, _jsonOptions);- Assert.NotNull(res);- Assert.Equal(result, res!.CollectionType);- }-- [Theory]- [InlineData(null)]- [InlineData(CollectionTypeOptions.Movies)]- [InlineData(CollectionTypeOptions.MusicVideos)]- public void RoundTrip_CollectionTypeOptions_Correct(CollectionTypeOptions? value)- {- var res = JsonSerializer.Deserialize<TestContainer>(JsonSerializer.Serialize(new TestContainer(value), _jsonOptions), _jsonOptions);- Assert.NotNull(res);- Assert.Equal(value, res!.CollectionType);- }-- [Theory]- [InlineData("{\"CollectionType\":null}")]- [InlineData("{\"CollectionType\":\"movies\"}")]- [InlineData("{\"CollectionType\":\"musicvideos\"}")]- public void RoundTrip_String_Correct(string json)- {- var res = JsonSerializer.Serialize(JsonSerializer.Deserialize<TestContainer>(json, _jsonOptions), _jsonOptions);- Assert.Equal(json, res);- }-- private sealed class TestContainer- {- public TestContainer(CollectionTypeOptions? collectionType)- {- CollectionType = collectionType;- }-- [JsonConverter(typeof(JsonLowerCaseConverter<CollectionTypeOptions?>))]- public CollectionTypeOptions? CollectionType { get; set; }- }- }-}