Add playlist ACL endpoints

This commit is contained in:
Shadowghost
2024-03-26 15:29:48 +01:00
parent 2e9aa146a5
commit 88b3490d17
6 changed files with 235 additions and 47 deletions

View File

@@ -4,12 +4,21 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Playlists;
namespace MediaBrowser.Controller.Playlists
{
public interface IPlaylistManager
{
/// <summary>
/// Gets the playlist.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="playlistId">The playlist identifier.</param>
/// <returns>Playlist.</returns>
Playlist GetPlaylist(Guid userId, Guid playlistId);
/// <summary>
/// Gets the playlists.
/// </summary>
@@ -17,6 +26,32 @@ namespace MediaBrowser.Controller.Playlists
/// <returns>IEnumerable&lt;Playlist&gt;.</returns>
IEnumerable<Playlist> GetPlaylists(Guid userId);
/// <summary>
/// Toggle OpenAccess policy of the playlist.
/// </summary>
/// <param name="playlistId">The playlist identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <returns>Task.</returns>
Task ToggleOpenAccess(Guid playlistId, Guid userId);
/// <summary>
/// Adds a share to the playlist.
/// </summary>
/// <param name="playlistId">The playlist identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <param name="share">The share.</param>
/// <returns>Task.</returns>
Task AddToShares(Guid playlistId, Guid userId, Share share);
/// <summary>
/// Rremoves a share from the playlist.
/// </summary>
/// <param name="playlistId">The playlist identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <param name="share">The share.</param>
/// <returns>Task.</returns>
Task RemoveFromShares(Guid playlistId, Guid userId, Share share);
/// <summary>
/// Creates the playlist.
/// </summary>

View File

@@ -16,20 +16,19 @@ 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
{
public class Playlist : Folder, IHasShares
{
public static readonly IReadOnlyList<string> SupportedExtensions = new[]
{
public static readonly IReadOnlyList<string> SupportedExtensions =
[
".m3u",
".m3u8",
".pls",
".wpl",
".zpl"
};
];
public Playlist()
{
@@ -41,7 +40,7 @@ namespace MediaBrowser.Controller.Playlists
public bool OpenAccess { get; set; }
public Share[] Shares { get; set; }
public IReadOnlyList<Share> Shares { get; set; }
[JsonIgnore]
public bool IsFile => IsPlaylistFile(Path);
@@ -192,9 +191,9 @@ namespace MediaBrowser.Controller.Playlists
return LibraryManager.GetItemList(new InternalItemsQuery(user)
{
Recursive = true,
IncludeItemTypes = new[] { BaseItemKind.Audio },
GenreIds = new[] { musicGenre.Id },
OrderBy = new[] { (ItemSortBy.AlbumArtist, SortOrder.Ascending), (ItemSortBy.Album, SortOrder.Ascending), (ItemSortBy.SortName, SortOrder.Ascending) },
IncludeItemTypes = [BaseItemKind.Audio],
GenreIds = [musicGenre.Id],
OrderBy = [(ItemSortBy.AlbumArtist, SortOrder.Ascending), (ItemSortBy.Album, SortOrder.Ascending), (ItemSortBy.SortName, SortOrder.Ascending)],
DtoOptions = options
});
}
@@ -204,9 +203,9 @@ namespace MediaBrowser.Controller.Playlists
return LibraryManager.GetItemList(new InternalItemsQuery(user)
{
Recursive = true,
IncludeItemTypes = new[] { BaseItemKind.Audio },
ArtistIds = new[] { musicArtist.Id },
OrderBy = new[] { (ItemSortBy.AlbumArtist, SortOrder.Ascending), (ItemSortBy.Album, SortOrder.Ascending), (ItemSortBy.SortName, SortOrder.Ascending) },
IncludeItemTypes = [BaseItemKind.Audio],
ArtistIds = [musicArtist.Id],
OrderBy = [(ItemSortBy.AlbumArtist, SortOrder.Ascending), (ItemSortBy.Album, SortOrder.Ascending), (ItemSortBy.SortName, SortOrder.Ascending)],
DtoOptions = options
});
}
@@ -217,8 +216,8 @@ namespace MediaBrowser.Controller.Playlists
{
Recursive = true,
IsFolder = false,
OrderBy = new[] { (ItemSortBy.SortName, SortOrder.Ascending) },
MediaTypes = new[] { mediaType },
OrderBy = [(ItemSortBy.SortName, SortOrder.Ascending)],
MediaTypes = [mediaType],
EnableTotalRecordCount = false,
DtoOptions = options
};
@@ -226,7 +225,7 @@ namespace MediaBrowser.Controller.Playlists
return folder.GetItemList(query);
}
return new[] { item };
return [item];
}
public override bool IsVisible(User user)
@@ -248,7 +247,7 @@ namespace MediaBrowser.Controller.Playlists
}
var shares = Shares;
if (shares.Length == 0)
if (shares.Count == 0)
{
return false;
}