Обнновлено до .net10

This commit is contained in:
FrigaT
2026-04-10 15:05:32 +03:00
parent 11d0b0d72f
commit 8444fc5f8e
386 changed files with 6361 additions and 7164 deletions

View File

@@ -6,21 +6,20 @@ using YandexMusic.API.Models.Radio;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
{
[YApiRequest(WebRequestMethods.Http.Get, "rotor/station/{type}:{tag}/info")]
public class YGetStationBuilder : YRequestBuilder<YResponse<List<YStation>>, (string type, string tag)>
{
public YGetStationBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
namespace YandexMusic.API.Requests.Radio;
protected override Dictionary<string, string> GetSubstitutions((string type, string tag) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.type },
{ "tag", tuple.tag }
};
}
[YApiRequest(WebRequestMethods.Http.Get, "rotor/station/{type}:{tag}/info")]
public class YGetStationBuilder : YRequestBuilder<YResponse<List<YStation>>, (string type, string tag)>
{
public YGetStationBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
protected override Dictionary<string, string> GetSubstitutions((string type, string tag) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.type },
{ "tag", tuple.tag }
};
}
}

View File

@@ -7,33 +7,32 @@ using YandexMusic.API.Models.Radio;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
namespace YandexMusic.API.Requests.Radio;
[YApiRequest(WebRequestMethods.Http.Get, "rotor/station/{type}:{tag}/tracks")]
public class YGetStationTracksBuilder : YRequestBuilder<YResponse<YStationSequence>, (YStationDescription station, string prevTrackId)>
{
[YApiRequest(WebRequestMethods.Http.Get, "rotor/station/{type}:{tag}/tracks")]
public class YGetStationTracksBuilder : YRequestBuilder<YResponse<YStationSequence>, (YStationDescription station, string prevTrackId)>
public YGetStationTracksBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
public YGetStationTracksBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
}
protected override Dictionary<string, string> GetSubstitutions((YStationDescription station, string prevTrackId) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.station.Id.Type },
{ "tag", tuple.station.Id.Tag },
};
}
protected override Dictionary<string, string> GetSubstitutions((YStationDescription station, string prevTrackId) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.station.Id.Type },
{ "tag", tuple.station.Id.Tag },
};
}
protected override NameValueCollection GetQueryParams((YStationDescription station, string prevTrackId) tuple)
{
NameValueCollection query = new() {
{ "settings2", "true" }
};
protected override NameValueCollection GetQueryParams((YStationDescription station, string prevTrackId) tuple)
{
NameValueCollection query = new() {
{ "settings2", "true" }
};
if (!string.IsNullOrEmpty(tuple.prevTrackId))
query.Add("queue", tuple.prevTrackId);
if (!string.IsNullOrEmpty(tuple.prevTrackId))
query.Add("queue", tuple.prevTrackId);
return base.GetQueryParams(tuple);
}
return base.GetQueryParams(tuple);
}
}

View File

@@ -6,13 +6,12 @@ using YandexMusic.API.Models.Radio;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
namespace YandexMusic.API.Requests.Radio;
[YApiRequest(WebRequestMethods.Http.Get, "rotor/stations/list")]
public class YGetStationsBuilder : YRequestBuilder<YResponse<List<YStation>>, object>
{
[YApiRequest(WebRequestMethods.Http.Get, "rotor/stations/list")]
public class YGetStationsBuilder : YRequestBuilder<YResponse<List<YStation>>, object>
public YGetStationsBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
public YGetStationsBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
}
}

View File

@@ -6,13 +6,12 @@ using YandexMusic.API.Models.Radio;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
namespace YandexMusic.API.Requests.Radio;
[YApiRequest(WebRequestMethods.Http.Get, "rotor/stations/dashboard")]
public class YGetStationsDashboardBuilder : YRequestBuilder<YResponse<YStationsDashboard>, object>
{
[YApiRequest(WebRequestMethods.Http.Get, "rotor/stations/dashboard")]
public class YGetStationsDashboardBuilder : YRequestBuilder<YResponse<YStationsDashboard>, object>
public YGetStationsDashboardBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
public YGetStationsDashboardBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
}
}

View File

@@ -11,36 +11,35 @@ using YandexMusic.API.Models.Radio;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
namespace YandexMusic.API.Requests.Radio;
[YApiRequest(WebRequestMethods.Http.Post, "rotor/station/{type}:{tag}/settings2")]
public class YSetSettings2Builder : YRequestBuilder<YResponse<string>, (YStationDescription station, YStationSettings2 settings2)>
{
[YApiRequest(WebRequestMethods.Http.Post, "rotor/station/{type}:{tag}/settings2")]
public class YSetSettings2Builder : YRequestBuilder<YResponse<string>, (YStationDescription station, YStationSettings2 settings2)>
public YSetSettings2Builder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
public YSetSettings2Builder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
{
}
}
protected override Dictionary<string, string> GetSubstitutions((YStationDescription station, YStationSettings2 settings2) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.station.Id.Type },
{ "tag", tuple.station.Id.Tag },
};
}
protected override Dictionary<string, string> GetSubstitutions((YStationDescription station, YStationSettings2 settings2) tuple)
{
return new Dictionary<string, string> {
{ "type", tuple.station.Id.Type },
{ "tag", tuple.station.Id.Tag },
};
}
protected override HttpContent GetContent((YStationDescription station, YStationSettings2 settings2) tuple)
protected override HttpContent GetContent((YStationDescription station, YStationSettings2 settings2) tuple)
{
JsonSerializerOptions settings = new()
{
JsonSerializerOptions settings = new()
{
Converters = {
new JsonStringEnumConverter()
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
Converters = {
new JsonStringEnumConverter()
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
return JsonContent.Create(tuple.settings2, new MediaTypeHeaderValue("application/json"), settings);
}
return JsonContent.Create(tuple.settings2, new MediaTypeHeaderValue("application/json"), settings);
}
}

View File

@@ -12,61 +12,60 @@ using YandexMusic.API.Models.Track;
using YandexMusic.API.Requests.Common;
using YandexMusic.API.Requests.Common.Attributes;
namespace YandexMusic.API.Requests.Radio
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)>
{
[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)
{
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
};
protected override Dictionary<string, string> GetSubstitutions((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
YStationFeedback feedBack = new()
{
return new Dictionary<string, string> {
{ "type", tuple.station.Station.Id.Type },
{ "tag", tuple.station.Station.Id.Tag }
};
}
Type = tuple.type,
From = tuple.station.Station.IdForFrom,
Timestamp = timestamp
};
protected override HttpContent GetContent((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
{
long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
if (tuple.track != null)
feedBack.TrackId = tuple.track.Id;
JsonSerializerOptions settings = new()
{
Converters = {
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
},
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
};
if (tuple.totalPlayedSeconds > 0)
feedBack.TotalPlayedSeconds = tuple.totalPlayedSeconds;
YStationFeedback feedBack = new()
{
Type = tuple.type,
From = tuple.station.Station.IdForFrom,
Timestamp = timestamp
};
return JsonContent.Create(feedBack, new MediaTypeHeaderValue("application/json"), settings); ;
}
if (tuple.track != null)
feedBack.TrackId = tuple.track.Id;
protected override NameValueCollection GetQueryParams((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
{
NameValueCollection query = new();
if (tuple.totalPlayedSeconds > 0)
feedBack.TotalPlayedSeconds = tuple.totalPlayedSeconds;
if (!string.IsNullOrWhiteSpace(tuple.batchId))
query.Add("batch-id", tuple.batchId);
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;
}
return query;
}
}