mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Adds music page play affordances and shuffle playback
Adds play and shuffle actions to music library, artist, and album cards. Adds the library play context and the uniform shuffle endpoint. Expands the player bar with queue covers, now playing details, and release type. Updates the bundled themes, API documentation, and the user manual.
This commit is contained in:
1 parent
93821a2776
commit
067e9a21d0
132 files changed
+2935
-715
No files matched your search
+1
@@ -12,6 +12,7 @@ public static partial class ApiRoutes
|
||||
{
|
||||
public const string ADD_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks";
|
||||
public const string GET_TRACK_BY_ID = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
|
||||
public const string SHUFFLE_TRACKS = "/libraries/{libraryId}/tracks/shuffle";
|
||||
public const string UPDATE_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
|
||||
public const string DELETE_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
|
||||
public const string STREAM_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/stream";
|
||||
|
||||
+2
@@ -340,6 +340,7 @@ public class AddAlbumEndpointSummary : Summary<AddAlbumEndpoint, AddAlbumRequest
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistName, "The name of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.LibraryId, "The Id of the media library the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.Title, "The title of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.OriginalTitle, "The original title of the album, if applicable.");
|
||||
@@ -380,6 +381,7 @@ public class AddAlbumEndpointSummary : Summary<AddAlbumEndpoint, AddAlbumRequest
|
||||
example: new AlbumResponse(
|
||||
Id: albumId,
|
||||
ArtistId: artistId,
|
||||
ArtistName: "Queen",
|
||||
LibraryId: libraryId,
|
||||
Metadata: new(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+2
@@ -32,6 +32,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, EmptyRequest>
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistName, "The name of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.LibraryId, "The Id of the media library the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.Title, "The title of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.OriginalTitle, "The original title of the album, if applicable.");
|
||||
@@ -72,6 +73,7 @@ public class GetAlbumEndpointSummary : Summary<GetAlbumEndpoint, EmptyRequest>
|
||||
example: new AlbumResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new MusicAlbumMetadataDto(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+2
@@ -144,6 +144,7 @@ public class UpdateAlbumEndpointSummary : Summary<UpdateAlbumEndpoint, UpdateAlb
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistName, "The name of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.LibraryId, "The Id of the media library the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.Title, "The title of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.OriginalTitle, "The original title of the album, if applicable.");
|
||||
@@ -184,6 +185,7 @@ public class UpdateAlbumEndpointSummary : Summary<UpdateAlbumEndpoint, UpdateAlb
|
||||
example: new AlbumResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new MusicAlbumMetadataDto(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+1
@@ -549,6 +549,7 @@ public class AddArtistEndpointSummary : Summary<AddArtistEndpoint, AddArtistRequ
|
||||
new(
|
||||
Id: albumId,
|
||||
ArtistId: artistId,
|
||||
ArtistName: "Queen",
|
||||
LibraryId: libraryId,
|
||||
Metadata: new(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+1
@@ -79,6 +79,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, EmptyRequest>
|
||||
new(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+3
@@ -32,6 +32,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, E
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistName, "The name of the artist the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.LibraryId, "The Id of the media library the album belongs to.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.Title, "The title of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.Metadata!.OriginalTitle, "The original title of the album, if applicable.");
|
||||
@@ -74,6 +75,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, E
|
||||
new AlbumResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new MusicAlbumMetadataDto(
|
||||
Title: "A Night at the Opera",
|
||||
@@ -249,6 +251,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, E
|
||||
new AlbumResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new MusicAlbumMetadataDto(
|
||||
Title: "The Works",
|
||||
|
||||
+2
@@ -91,6 +91,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
new(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new(
|
||||
Title: "A Night at the Opera",
|
||||
@@ -216,6 +217,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
new(
|
||||
Id: Guid.NewGuid(),
|
||||
ArtistId: Guid.NewGuid(),
|
||||
ArtistName: "Queen",
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new(
|
||||
Title: "Heroes",
|
||||
|
||||
+1
@@ -546,6 +546,7 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
new AlbumResponse(
|
||||
Id: albumId,
|
||||
ArtistId: artistId,
|
||||
ArtistName: "Queen",
|
||||
LibraryId: libraryId,
|
||||
Metadata: new MusicAlbumMetadataDto(
|
||||
Title: "A Night at the Opera",
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.ShuffleTracks;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.ShuffleTracks;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/tracks/shuffle</c> route.
|
||||
/// </summary>
|
||||
public class ShuffleTracksEndpoint : BaseEndpoint<ShuffleTracksRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<ShuffleTracksQuery, Result<IReadOnlyList<ShuffleTrackResponse>>> _shuffleTracksQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ShuffleTracksEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="shuffleTracksQueryHandler">Injected service for handling shuffle tracks queries.</param>
|
||||
public ShuffleTracksEndpoint(IQueryHandler<ShuffleTracksQuery, Result<IReadOnlyList<ShuffleTrackResponse>>> shuffleTracksQueryHandler)
|
||||
{
|
||||
_shuffleTracksQueryHandler = shuffleTracksQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.POST);
|
||||
Routes(ApiRoutes.Tracks.SHUFFLE_TRACKS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a random selection of tracks of the library identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the selection size, the optional scope and the tracks to exclude.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ShuffleTracksRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// Take the unique identifier from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
Result<IReadOnlyList<ShuffleTrackResponse>> result = await _shuffleTracksQueryHandler.HandleAsync(request.ToQuery(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.ShuffleTracks;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ShuffleTracksEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ShuffleTracksEndpointSummary : Summary<ShuffleTracksEndpoint, ShuffleTracksRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ShuffleTracksEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ShuffleTracksEndpointSummary()
|
||||
{
|
||||
Summary = "Draws a random selection of tracks from a media library, an artist or an album.";
|
||||
Description = "Returns uniformly random tracks from every track of the whole library, of one artist, or of one album, selected by the database itself. The client can pass the tracks it already queued to exclude them, so consecutive batches of a shuffle do not repeat a track. The request is returned to an Admin, who can shuffle all libraries, or to the owner of the library.";
|
||||
|
||||
ExampleRequest = new ShuffleTracksRequest(
|
||||
Count: 100,
|
||||
ArtistId: null,
|
||||
AlbumId: null,
|
||||
ExcludedTrackIds: [Guid.NewGuid(), Guid.NewGuid()]
|
||||
);
|
||||
|
||||
RequestParam(r => r.Count, "The maximum number of tracks to return, between 1 and 500.");
|
||||
RequestParam(r => r.ArtistId, "The artist whose tracks are sampled. Optional.");
|
||||
RequestParam(r => r.AlbumId, "The album whose tracks are sampled. Optional.");
|
||||
RequestParam(r => r.ExcludedTrackIds, "The tracks that must not be returned. Optional.");
|
||||
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.TrackId, "The Id of the track.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.Title, "The title of the track.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.DurationInSeconds, "The duration of the track in seconds.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.AlbumId, "The Id of the album the track belongs to.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.AlbumTitle, "The title of the album the track belongs to.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
ResponseParam<ShuffleTrackResponse>(r => r.CoverPath, "The path of the cover of the album, if available.");
|
||||
|
||||
Response(200, "The random selection of tracks is returned.",
|
||||
example: new List<ShuffleTrackResponse>
|
||||
{
|
||||
new(
|
||||
TrackId: Guid.NewGuid(),
|
||||
Title: "Bohemian Rhapsody",
|
||||
DurationInSeconds: 354,
|
||||
AlbumId: Guid.NewGuid(),
|
||||
AlbumTitle: "A Night at the Opera",
|
||||
ArtistId: Guid.NewGuid(),
|
||||
CoverPath: "/music/queen/a-night-at-the-opera/cover.jpg"
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/tracks/shuffle"
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/tracks/shuffle",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/tracks/shuffle",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"ShuffleTrackCountMustBeGreaterThanZero",
|
||||
"ShuffleTrackCountMustBeAtMost500"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user