Добавлен вывод названия трека и обложки в плеере
This commit is contained in:
@@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PlaylistShared.Api.Entities;
|
||||
using PlaylistShared.Api.Services;
|
||||
using PlaylistShared.Shared;
|
||||
using PlaylistShared.Shared.DTO;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace PlaylistShared.Api.Controllers;
|
||||
@@ -70,6 +72,24 @@ public class AudioController : ControllerBase
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
[HttpGet("track-info/{trackId}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ApiResponse<TrackInfoDto>>> GetTrackInfo(string trackId, [FromQuery] string? access_token = null, [FromQuery] string? shared_id = null)
|
||||
{
|
||||
var user = await GetUserFromToken(access_token);
|
||||
if (user == null) user = await GetUserFromSharedPlaylistId(shared_id);
|
||||
if (user == null) return Unauthorized();
|
||||
|
||||
var track = await _yandexService.GetYTrackAsync(user, trackId);
|
||||
if (track == null) return NotFound();
|
||||
|
||||
return Ok(ApiResponse<TrackInfoDto>.Ok(new TrackInfoDto
|
||||
{
|
||||
Title = track.Title,
|
||||
CoverUri = track.CoverUri,
|
||||
}));
|
||||
}
|
||||
|
||||
private async Task<ApplicationUser?> GetUserFromToken(string? token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token)) return null;
|
||||
|
||||
Reference in New Issue
Block a user