Добален поиск по трекам
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using PlaylistShared.Api.Entities;
|
||||
using PlaylistShared.Shared.DTO;
|
||||
using YandexMusic;
|
||||
using YandexMusic.API.Extensions.API;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
@@ -94,4 +95,22 @@ public class YandexMusicService
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<YandexTrackSearchResult>> SearchTracksAsync(ApplicationUser user, string query, int limit = 20)
|
||||
{
|
||||
var client = await CreateClientAsync(user);
|
||||
if (client == null) return new List<YandexTrackSearchResult>();
|
||||
|
||||
var searchResult = await client.SearchAsync(query, YandexMusic.API.Models.Common.YSearchType.Track, page: 0, pageSize: limit);
|
||||
if (searchResult?.Tracks?.Results == null) return new List<YandexTrackSearchResult>();
|
||||
|
||||
return searchResult.Tracks.Results.Select(t => new YandexTrackSearchResult
|
||||
{
|
||||
TrackId = t.Id,
|
||||
Title = t.Title,
|
||||
Artists = t.Artists?.Select(a => a.Name).ToList() ?? new List<string>(),
|
||||
CoverUri = t.CoverUri ?? string.Empty,
|
||||
DurationMs = t.DurationMs,
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user