From 76ae599bd3ccfd9808f50dbf5d935aa430783e60 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Fri, 10 Mar 2023 17:46:59 +0100 Subject: [PATCH 1/5] Fix playlist creation and removal --- .../Playlists/PlaylistManager.cs | 46 +++++++++++++++---- Jellyfin.Api/Controllers/UserController.cs | 8 +++- .../Entities/IHasShares.cs | 11 ----- MediaBrowser.Controller/Entities/Share.cs | 13 ------ .../Playlists/IPlaylistManager.cs | 8 ++++ MediaBrowser.Controller/Playlists/Playlist.cs | 1 + .../Parsers/BaseItemXmlParser.cs | 16 +++++++ .../Savers/BaseXmlSaver.cs | 20 ++++---- MediaBrowser.Model/Entities/IHasShares.cs | 12 +++++ MediaBrowser.Model/Entities/Share.cs | 17 +++++++ .../Playlists/PlaylistCreationRequest.cs | 39 +++++++++++----- 11 files changed, 137 insertions(+), 54 deletions(-) delete mode 100644 MediaBrowser.Controller/Entities/IHasShares.cs delete mode 100644 MediaBrowser.Controller/Entities/Share.cs create mode 100644 MediaBrowser.Model/Entities/IHasShares.cs create mode 100644 MediaBrowser.Model/Entities/Share.cs diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 2717c392b2..8cba652e7b 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -135,16 +135,8 @@ namespace Emby.Server.Implementations.Playlists { Name = name, Path = path, - Shares = new[] - { - new Share - { - UserId = options.UserId.Equals(default) - ? null - : options.UserId.ToString("N", CultureInfo.InvariantCulture), - CanEdit = true - } - } + OwnerUserId = options.UserId, + Shares = options.Shares }; playlist.SetMediaType(options.MediaType); @@ -537,5 +529,39 @@ namespace Emby.Server.Implementations.Playlists return _libraryManager.RootFolder.Children.OfType().FirstOrDefault(i => string.Equals(i.GetType().Name, TypeName, StringComparison.Ordinal)) ?? _libraryManager.GetUserRootFolder().Children.OfType().FirstOrDefault(i => string.Equals(i.GetType().Name, TypeName, StringComparison.Ordinal)); } + + public async Task RemovePlaylists(Guid userId) + { + var playlists = GetPlaylists(userId); + foreach (var playlist in playlists) + { + // Update owner if shared + var rankedShares = playlist.Shares.OrderByDescending(x => x.CanEdit).ToArray(); + if (rankedShares.Length > 0 && Guid.TryParse(rankedShares[0].UserId, out var guid)) + { + playlist.OwnerUserId = guid; + playlist.Shares = rankedShares.Skip(1).ToArray(); + await playlist.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + + if (playlist.IsFile) + { + SavePlaylistFile(playlist); + } + } + else + { + // Remove playlist if not shared + _libraryManager.DeleteItem( + playlist, + new DeleteOptions + { + DeleteFileLocation = false, + DeleteFromExternalProvider = false + }, + playlist.GetParent(), + false); + } + } + } } } diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs index b0973b8a14..09bf895505 100644 --- a/Jellyfin.Api/Controllers/UserController.cs +++ b/Jellyfin.Api/Controllers/UserController.cs @@ -15,6 +15,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.QuickConnect; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Configuration; @@ -41,6 +42,7 @@ public class UserController : BaseJellyfinApiController private readonly IServerConfigurationManager _config; private readonly ILogger _logger; private readonly IQuickConnect _quickConnectManager; + private readonly IPlaylistManager _playlistManager; /// /// Initializes a new instance of the class. @@ -53,6 +55,7 @@ public class UserController : BaseJellyfinApiController /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. + /// Instance of the interface. public UserController( IUserManager userManager, ISessionManager sessionManager, @@ -61,7 +64,8 @@ public class UserController : BaseJellyfinApiController IAuthorizationContext authContext, IServerConfigurationManager config, ILogger logger, - IQuickConnect quickConnectManager) + IQuickConnect quickConnectManager, + IPlaylistManager playlistManager) { _userManager = userManager; _sessionManager = sessionManager; @@ -71,6 +75,7 @@ public class UserController : BaseJellyfinApiController _config = config; _logger = logger; _quickConnectManager = quickConnectManager; + _playlistManager = playlistManager; } /// @@ -153,6 +158,7 @@ public class UserController : BaseJellyfinApiController } await _sessionManager.RevokeUserTokens(user.Id, null).ConfigureAwait(false); + await _playlistManager.RemovePlaylists(userId).ConfigureAwait(false); await _userManager.DeleteUserAsync(userId).ConfigureAwait(false); return NoContent(); } diff --git a/MediaBrowser.Controller/Entities/IHasShares.cs b/MediaBrowser.Controller/Entities/IHasShares.cs deleted file mode 100644 index e6fa27703b..0000000000 --- a/MediaBrowser.Controller/Entities/IHasShares.cs +++ /dev/null @@ -1,11 +0,0 @@ -#nullable disable - -#pragma warning disable CA1819, CS1591 - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasShares - { - Share[] Shares { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/Share.cs b/MediaBrowser.Controller/Entities/Share.cs deleted file mode 100644 index 64f446eef2..0000000000 --- a/MediaBrowser.Controller/Entities/Share.cs +++ /dev/null @@ -1,13 +0,0 @@ -#nullable disable - -#pragma warning disable CS1591 - -namespace MediaBrowser.Controller.Entities -{ - public class Share - { - public string UserId { get; set; } - - public bool CanEdit { get; set; } - } -} diff --git a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs index f6c5920709..201dadb3d2 100644 --- a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs +++ b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs @@ -56,5 +56,13 @@ namespace MediaBrowser.Controller.Playlists /// The new index. /// Task. Task MoveItemAsync(string playlistId, string entryId, int newIndex); + + /// + /// Removed all playlists of a user. + /// If the playlist is shared, ownership is transferred. + /// + /// The user id. + /// Task. + Task RemovePlaylists(Guid userId); } } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index e6bcc9ea85..2ed05a32c0 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -15,6 +15,7 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Playlists diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index c8912807ea..a01490c96c 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Xml; using Jellyfin.Extensions; using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using Microsoft.Extensions.Logging; @@ -636,6 +637,21 @@ namespace MediaBrowser.LocalMetadata.Parsers break; } + case "OwnerUserId": + { + var val = reader.ReadElementContentAsString(); + + if (Guid.TryParse(val, out var guid) && !guid.Equals(Guid.Empty)) + { + if (item is Playlist playlist) + { + playlist.OwnerUserId = guid; + } + } + + break; + } + case "Format3D": { var val = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index d92b504740..1f9c562bac 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -395,6 +395,7 @@ namespace MediaBrowser.LocalMetadata.Savers if (item is Playlist playlist && !Playlist.IsPlaylistFile(playlist.Path)) { + await writer.WriteElementStringAsync(null, "OwnerUserId", null, playlist.OwnerUserId.ToString("N")).ConfigureAwait(false); await AddLinkedChildren(playlist, writer, "PlaylistItems", "PlaylistItem").ConfigureAwait(false); } @@ -418,16 +419,19 @@ namespace MediaBrowser.LocalMetadata.Savers foreach (var share in item.Shares) { - await writer.WriteStartElementAsync(null, "Share", null).ConfigureAwait(false); + if (share.UserId is not null) + { + await writer.WriteStartElementAsync(null, "Share", null).ConfigureAwait(false); - await writer.WriteElementStringAsync(null, "UserId", null, share.UserId).ConfigureAwait(false); - await writer.WriteElementStringAsync( - null, - "CanEdit", - null, - share.CanEdit.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()).ConfigureAwait(false); + await writer.WriteElementStringAsync(null, "UserId", null, share.UserId).ConfigureAwait(false); + await writer.WriteElementStringAsync( + null, + "CanEdit", + null, + share.CanEdit.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()).ConfigureAwait(false); - await writer.WriteEndElementAsync().ConfigureAwait(false); + await writer.WriteEndElementAsync().ConfigureAwait(false); + } } await writer.WriteEndElementAsync().ConfigureAwait(false); diff --git a/MediaBrowser.Model/Entities/IHasShares.cs b/MediaBrowser.Model/Entities/IHasShares.cs new file mode 100644 index 0000000000..b34d1a0376 --- /dev/null +++ b/MediaBrowser.Model/Entities/IHasShares.cs @@ -0,0 +1,12 @@ +namespace MediaBrowser.Model.Entities; + +/// +/// Interface for access to shares. +/// +public interface IHasShares +{ + /// + /// Gets or sets the shares. + /// + Share[] Shares { get; set; } +} diff --git a/MediaBrowser.Model/Entities/Share.cs b/MediaBrowser.Model/Entities/Share.cs new file mode 100644 index 0000000000..186aad1892 --- /dev/null +++ b/MediaBrowser.Model/Entities/Share.cs @@ -0,0 +1,17 @@ +namespace MediaBrowser.Model.Entities; + +/// +/// Class to hold data on sharing permissions. +/// +public class Share +{ + /// + /// Gets or sets the user id. + /// + public string? UserId { get; set; } + + /// + /// Gets or sets a value indicating whether the user has edit permissions. + /// + public bool CanEdit { get; set; } +} diff --git a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs index e8ee494034..8472697164 100644 --- a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs +++ b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs @@ -1,19 +1,36 @@ -#nullable disable -#pragma warning disable CS1591 - using System; using System.Collections.Generic; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Model.Playlists; -namespace MediaBrowser.Model.Playlists +/// +/// A playlist creation request. +/// +public class PlaylistCreationRequest { - public class PlaylistCreationRequest - { - public string Name { get; set; } + /// + /// Gets or sets the name. + /// + public string? Name { get; set; } + + /// + /// Gets or sets the list of items. + /// + public IReadOnlyList ItemIdList { get; set; } = Array.Empty(); - public IReadOnlyList ItemIdList { get; set; } = Array.Empty(); + /// + /// Gets or sets the media type. + /// + public string? MediaType { get; set; } - public string MediaType { get; set; } + /// + /// Gets or sets the user id. + /// + public Guid UserId { get; set; } - public Guid UserId { get; set; } - } + /// + /// Gets or sets the shares. + /// + public Share[]? Shares { get; set; } } From 8d158df67856bbb9de696f5caa0ec475b172ced2 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Fri, 10 Mar 2023 19:16:57 +0100 Subject: [PATCH 2/5] Add migration to properly set playlist owner --- .../Playlists/PlaylistManager.cs | 14 ++++ Jellyfin.Server/Migrations/MigrationRunner.cs | 3 +- .../Migrations/Routines/FixPlaylistOwner.cs | 67 +++++++++++++++++++ .../Playlists/IPlaylistManager.cs | 7 ++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 8cba652e7b..c15c2c4008 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -563,5 +563,19 @@ namespace Emby.Server.Implementations.Playlists } } } + + public async Task UpdatePlaylist(Playlist playlist) + { + var currentPlaylist = (Playlist)_libraryManager.GetItemById(playlist.Id); + currentPlaylist.OwnerUserId = playlist.OwnerUserId; + currentPlaylist.Shares = playlist.Shares; + + await playlist.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + + if (playlist.IsFile) + { + SavePlaylistFile(currentPlaylist); + } + } } } diff --git a/Jellyfin.Server/Migrations/MigrationRunner.cs b/Jellyfin.Server/Migrations/MigrationRunner.cs index d4bf81f10b..866262d22f 100644 --- a/Jellyfin.Server/Migrations/MigrationRunner.cs +++ b/Jellyfin.Server/Migrations/MigrationRunner.cs @@ -40,7 +40,8 @@ namespace Jellyfin.Server.Migrations typeof(Routines.ReaddDefaultPluginRepository), typeof(Routines.MigrateDisplayPreferencesDb), typeof(Routines.RemoveDownloadImagesInAdvance), - typeof(Routines.MigrateAuthenticationDb) + typeof(Routines.MigrateAuthenticationDb), + typeof(Routines.FixPlaylistOwner) }; /// diff --git a/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs b/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs new file mode 100644 index 0000000000..d5736fd3c3 --- /dev/null +++ b/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs @@ -0,0 +1,67 @@ +using System; +using System.Linq; + +using Jellyfin.Data.Enums; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Playlists; +using Microsoft.Extensions.Logging; + +namespace Jellyfin.Server.Migrations.Routines; + +/// +/// Properly set playlist owner. +/// +internal class FixPlaylistOwner : IMigrationRoutine +{ + private readonly ILogger _logger; + private readonly ILibraryManager _libraryManager; + private readonly IPlaylistManager _playlistManager; + + public FixPlaylistOwner( + ILogger logger, + ILibraryManager libraryManager, + IPlaylistManager playlistManager) + { + _logger = logger; + _libraryManager = libraryManager; + _playlistManager = playlistManager; + } + + /// + public Guid Id => Guid.Parse("{615DFA9E-2497-4DBB-A472-61938B752C5B}"); + + /// + public string Name => "FixPlaylistOwner"; + + /// + public bool PerformOnNewInstall => false; + + /// + public void Perform() + { + var playlists = _libraryManager.GetItemList(new InternalItemsQuery + { + IncludeItemTypes = new[] { BaseItemKind.Playlist } + }) + .Cast() + .Where(x => x.OwnerUserId.Equals(Guid.Empty)) + .ToArray(); + + if (playlists.Length > 0) + { + foreach (var playlist in playlists) + { + var shares = playlist.Shares; + var firstEditShare = shares.First(x => x.CanEdit); + if (firstEditShare is not null && Guid.TryParse(firstEditShare.UserId, out var guid)) + { + playlist.OwnerUserId = guid; + playlist.Shares = shares.Where(x => x != firstEditShare).ToArray(); + + _playlistManager.UpdatePlaylist(playlist).GetAwaiter().GetResult(); + } + } + } + } +} diff --git a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs index 201dadb3d2..22f974420f 100644 --- a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs +++ b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs @@ -64,5 +64,12 @@ namespace MediaBrowser.Controller.Playlists /// The user id. /// Task. Task RemovePlaylists(Guid userId); + + /// + /// Updates a playlist. + /// + /// The updated playlist. + /// Task. + Task UpdatePlaylist(Playlist playlist); } } From 82080bd1ef056153fd54e05fb9decbf5f5830572 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sun, 12 Mar 2023 19:42:18 +0100 Subject: [PATCH 3/5] Apply review suggestions --- Emby.Server.Implementations/Playlists/PlaylistManager.cs | 6 +++--- Jellyfin.Api/Controllers/UserController.cs | 2 +- Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs | 2 +- MediaBrowser.Controller/Playlists/IPlaylistManager.cs | 4 ++-- MediaBrowser.Controller/Playlists/Playlist.cs | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index c15c2c4008..853daf7247 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -530,7 +530,7 @@ namespace Emby.Server.Implementations.Playlists _libraryManager.GetUserRootFolder().Children.OfType().FirstOrDefault(i => string.Equals(i.GetType().Name, TypeName, StringComparison.Ordinal)); } - public async Task RemovePlaylists(Guid userId) + public async Task RemovePlaylistsAsync(Guid userId) { var playlists = GetPlaylists(userId); foreach (var playlist in playlists) @@ -564,7 +564,7 @@ namespace Emby.Server.Implementations.Playlists } } - public async Task UpdatePlaylist(Playlist playlist) + public async Task UpdatePlaylistAsync(Playlist playlist) { var currentPlaylist = (Playlist)_libraryManager.GetItemById(playlist.Id); currentPlaylist.OwnerUserId = playlist.OwnerUserId; @@ -572,7 +572,7 @@ namespace Emby.Server.Implementations.Playlists await playlist.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); - if (playlist.IsFile) + if (currentPlaylist.IsFile) { SavePlaylistFile(currentPlaylist); } diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs index 09bf895505..e495288670 100644 --- a/Jellyfin.Api/Controllers/UserController.cs +++ b/Jellyfin.Api/Controllers/UserController.cs @@ -158,7 +158,7 @@ public class UserController : BaseJellyfinApiController } await _sessionManager.RevokeUserTokens(user.Id, null).ConfigureAwait(false); - await _playlistManager.RemovePlaylists(userId).ConfigureAwait(false); + await _playlistManager.RemovePlaylistsAsync(userId).ConfigureAwait(false); await _userManager.DeleteUserAsync(userId).ConfigureAwait(false); return NoContent(); } diff --git a/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs b/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs index d5736fd3c3..55aadae79a 100644 --- a/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs +++ b/Jellyfin.Server/Migrations/Routines/FixPlaylistOwner.cs @@ -59,7 +59,7 @@ internal class FixPlaylistOwner : IMigrationRoutine playlist.OwnerUserId = guid; playlist.Shares = shares.Where(x => x != firstEditShare).ToArray(); - _playlistManager.UpdatePlaylist(playlist).GetAwaiter().GetResult(); + _playlistManager.UpdatePlaylistAsync(playlist).GetAwaiter().GetResult(); } } } diff --git a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs index 22f974420f..d889436629 100644 --- a/MediaBrowser.Controller/Playlists/IPlaylistManager.cs +++ b/MediaBrowser.Controller/Playlists/IPlaylistManager.cs @@ -63,13 +63,13 @@ namespace MediaBrowser.Controller.Playlists /// /// The user id. /// Task. - Task RemovePlaylists(Guid userId); + Task RemovePlaylistsAsync(Guid userId); /// /// Updates a playlist. /// /// The updated playlist. /// Task. - Task UpdatePlaylist(Playlist playlist); + Task UpdatePlaylistAsync(Playlist playlist); } } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 2ed05a32c0..344e996ea8 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -233,7 +233,8 @@ namespace MediaBrowser.Controller.Playlists return base.IsVisible(user); } - if (user.Id.Equals(OwnerUserId)) + var userId = user.Id; + if (userId.Equals(OwnerUserId)) { return true; } @@ -241,10 +242,9 @@ namespace MediaBrowser.Controller.Playlists var shares = Shares; if (shares.Length == 0) { - return base.IsVisible(user); + return false; } - var userId = user.Id; return shares.Any(share => Guid.TryParse(share.UserId, out var id) && id.Equals(userId)); } From eba24d188d3ff9747e2c39281e3f64d5fdd53899 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sat, 18 Mar 2023 08:25:34 +0100 Subject: [PATCH 4/5] Update Emby.Server.Implementations/Playlists/PlaylistManager.cs Co-authored-by: Joe Rogers <1337joe@users.noreply.github.com> --- Emby.Server.Implementations/Playlists/PlaylistManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 853daf7247..4d1b454288 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -136,7 +136,7 @@ namespace Emby.Server.Implementations.Playlists Name = name, Path = path, OwnerUserId = options.UserId, - Shares = options.Shares + Shares = options.Shares ?? Array.Empty() }; playlist.SetMediaType(options.MediaType); From 9211a73e4011c0c610fdbcf24e0723a3552f22fa Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sat, 25 Mar 2023 18:41:09 +0100 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Cody Robibero --- Emby.Server.Implementations/Playlists/PlaylistManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 4d1b454288..6176879b66 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -530,6 +530,7 @@ namespace Emby.Server.Implementations.Playlists _libraryManager.GetUserRootFolder().Children.OfType().FirstOrDefault(i => string.Equals(i.GetType().Name, TypeName, StringComparison.Ordinal)); } + /// public async Task RemovePlaylistsAsync(Guid userId) { var playlists = GetPlaylists(userId); @@ -564,6 +565,7 @@ namespace Emby.Server.Implementations.Playlists } } + /// public async Task UpdatePlaylistAsync(Playlist playlist) { var currentPlaylist = (Playlist)_libraryManager.GetItemById(playlist.Id);