Files
YandexMusic/YandexMusic.API/API/YArtistAPI.cs
FrigaT 36e28ce3fe
All checks were successful
Release / pack-and-publish (release) Successful in 36s
Полностью переписанное api
2026-04-19 17:00:05 +03:00

27 lines
1011 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using YandexMusic.API.Models.Artist;
using YandexMusic.API.Requests.Artist;
namespace YandexMusic.API;
/// <summary>API для работы с исполнителями.</summary>
public class YArtistAPI : YCommonAPI
{
public YArtistAPI(YandexMusicApi api) : base(api) { }
public Task<YArtistBriefInfo?> GetAsync(string artistId)
=> new YGetArtistBuilder(Api).ExecuteAsync(artistId);
public Task<List<YArtist>?> GetAsync(IEnumerable<string> artistIds)
=> new YGetArtistsBuilder(Api).ExecuteAsync(artistIds);
public Task<YTracksPage?> GetTracksAsync(string artistId, int page = 0, int pageSize = 20)
=> new YGetArtistTrackBuilder(Api).ExecuteAsync((artistId, page, pageSize));
public async Task<YTracksPage?> GetAllTracksAsync(string artistId)
{
var info = await GetAsync(artistId);
if (info?.Artist?.Counts?.Tracks == null)
return null;
return await GetTracksAsync(artistId, pageSize: info.Artist.Counts.Tracks);
}
}