Полностью переписанное api
All checks were successful
Release / pack-and-publish (release) Successful in 36s
All checks were successful
Release / pack-and-publish (release) Successful in 36s
This commit is contained in:
@@ -1,113 +1,37 @@
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Radio;
|
||||
using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Radio;
|
||||
|
||||
namespace YandexMusic.API;
|
||||
|
||||
/// <summary>
|
||||
/// API для взаимодействия с радио
|
||||
/// </summary>
|
||||
public partial class YRadioAPI : YCommonAPI
|
||||
/// <summary>API для работы с радио.</summary>
|
||||
public class YRadioAPI : YCommonAPI
|
||||
{
|
||||
public YRadioAPI(YandexMusicApi yandex) : base(yandex)
|
||||
{
|
||||
}
|
||||
public YRadioAPI(YandexMusicApi api) : base(api) { }
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка рекомендованных радиостанций
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<YStationsDashboard>> GetStationsDashboardAsync(AuthStorage storage)
|
||||
{
|
||||
return new YGetStationsDashboardBuilder(api, storage)
|
||||
.Build(null)
|
||||
.GetResponseAsync();
|
||||
}
|
||||
public Task<YStationsDashboard?> GetStationsDashboardAsync()
|
||||
=> new YGetStationsDashboardBuilder(Api).ExecuteAsync(null!);
|
||||
|
||||
/// <summary>
|
||||
/// Получение списка радиостанций
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<List<YStation>>> GetStationsAsync(AuthStorage storage)
|
||||
{
|
||||
return new YGetStationsBuilder(api, storage)
|
||||
.Build(null)
|
||||
.GetResponseAsync();
|
||||
}
|
||||
public Task<List<YStation>?> GetStationsAsync()
|
||||
=> new YGetStationsBuilder(Api).ExecuteAsync(null!);
|
||||
|
||||
/// <summary>
|
||||
/// Получение информации о радиостанции
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <param name="type">Тип</param>
|
||||
/// <param name="tag">Тэг</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<List<YStation>>> GetStationAsync(AuthStorage storage, string type, string tag)
|
||||
{
|
||||
return new YGetStationBuilder(api, storage)
|
||||
.Build((type, tag))
|
||||
.GetResponseAsync();
|
||||
}
|
||||
public Task<List<YStation>?> GetStationAsync(string type, string tag)
|
||||
=> new YGetStationBuilder(Api).ExecuteAsync((type, tag));
|
||||
|
||||
/// <summary>
|
||||
/// Получение информации о радиостанции
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <param name="id">Идентификатор станции</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<List<YStation>>> GetStationAsync(AuthStorage storage, YStationId id)
|
||||
{
|
||||
return GetStationAsync(storage, id.Type, id.Tag);
|
||||
}
|
||||
public Task<List<YStation>?> GetStationAsync(YStationId id)
|
||||
=> GetStationAsync(id.Type, id.Tag);
|
||||
|
||||
/// <summary>
|
||||
/// Получение последовательности треков радиостанции
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <param name="station">Радиостанция</param>
|
||||
/// <param name="prevTrackId">Идентификатор предыдущего трека</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<YStationSequence>> GetStationTracksAsync(AuthStorage storage, YStation station, string prevTrackId = "")
|
||||
{
|
||||
return new YGetStationTracksBuilder(api, storage)
|
||||
.Build((station.Station, prevTrackId))
|
||||
.GetResponseAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка настроек подбора треков
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <param name="station">Радиостанция</param>
|
||||
/// <param name="settings">Настройки</param>
|
||||
/// <returns></returns>
|
||||
public Task<YResponse<string>> SetStationSettings2Async(AuthStorage storage, YStation station, YStationSettings2 settings)
|
||||
{
|
||||
return new YSetSettings2Builder(api, storage)
|
||||
.Build((station.Station, settings))
|
||||
.GetResponseAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отправка обратной связи на действия при прослушивании радио
|
||||
/// </summary>
|
||||
/// <param name="storage">Хранилище</param>
|
||||
/// <param name="station">Радиостанция</param>
|
||||
/// <param name="type">Тип обратной связи</param>
|
||||
/// <param name="track">Трек</param>
|
||||
/// <param name="batchId">Уникальный идентификатор партии треков. Возвращается при получении треков</param>
|
||||
/// <param name="totalPlayedSeconds">Сколько было проиграно секунд трека перед действием</param>
|
||||
/// <returns></returns>
|
||||
public Task<string> SendStationFeedBackAsync(AuthStorage storage, YStation station, YStationFeedbackType type, YTrack track = null, string batchId = "", double totalPlayedSeconds = 0)
|
||||
{
|
||||
return new YSetStationFeedbackBuilder(api, storage)
|
||||
.Build((type, station, track, batchId, totalPlayedSeconds))
|
||||
.GetResponseAsync();
|
||||
}
|
||||
public Task<YStationSequence?> GetStationTracksAsync(YStation station, string prevTrackId = "")
|
||||
=> new YGetStationTracksBuilder(Api).ExecuteAsync((station.Station, prevTrackId));
|
||||
|
||||
public Task<string?> SetStationSettings2Async(YStation station, YStationSettings2 settings)
|
||||
=> new YSetSettings2Builder(Api).ExecuteAsync((station.Station, settings));
|
||||
|
||||
public Task<string?> SendStationFeedbackAsync(
|
||||
YStation station,
|
||||
YStationFeedbackType type,
|
||||
YTrack? track = null,
|
||||
string batchId = "",
|
||||
double totalPlayedSeconds = 0)
|
||||
=> new YSetStationFeedbackBuilder(Api).ExecuteAsync((type, station, track, batchId, totalPlayedSeconds));
|
||||
}
|
||||
Reference in New Issue
Block a user