Добавьте файлы проекта.

This commit is contained in:
FrigaT
2026-04-10 12:12:33 +03:00
parent 9615cf42ee
commit 11d0b0d72f
383 changed files with 9661 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
using System.Collections.Specialized;
using System.Net;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using YandexMusic.API.Common;
using YandexMusic.API.Models.Radio;
using YandexMusic.API.Models.Track;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
{
[YApiRequest(WebRequestMethods.Http.Post, "rotor/station/{type}:{tag}/feedback")]
public class YSetStationFeedbackBuilder : YRequestBuilder<string, (YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds)>
{
public YSetStationFeedbackBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
protected override Dictionary<string, string> GetSubstitutions((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.station.Station.Id.Type },
{ "tag", tuple.station.Station.Id.Tag }
};
}
protected override HttpContent GetContent((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
{
long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
JsonSerializerOptions settings = new()
{
Converters = {
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
YStationFeedback feedBack = new()
{
Type = tuple.type,
From = tuple.station.Station.IdForFrom,
Timestamp = timestamp
};
if (tuple.track != null)
feedBack.TrackId = tuple.track.Id;
if (tuple.totalPlayedSeconds > 0)
feedBack.TotalPlayedSeconds = tuple.totalPlayedSeconds;
return JsonContent.Create(feedBack, new MediaTypeHeaderValue("application/json"), settings); ;
}
protected override NameValueCollection GetQueryParams((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
{
NameValueCollection query = new();
if (!string.IsNullOrWhiteSpace(tuple.batchId))
query.Add("batch-id", tuple.batchId);
return query;
}
}
}