Обнновлено до .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

@@ -1,58 +1,8 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
public class YPlayContext
{
public sealed class YPlayContextConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(YLandingEntity).IsAssignableFrom(objectType);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
return null;
JObject jObject = JObject.Load(reader);
YPlayContext context;
try
{
YPlayContextType type = jObject["context"].ToObject<YPlayContextType>();
switch (type)
{
case YPlayContextType.Album:
context = jObject.ToObject<YPlayContextAlbum>();
break;
case YPlayContextType.Artist:
context = jObject.ToObject<YPlayContextArtist>();
break;
case YPlayContextType.Playlist:
context = jObject.ToObject<YPlayContextPlaylist>();
break;
default:
context = jObject.ToObject<YPlayContext>();
break;
}
}
catch (Exception ex)
{
throw new Exception($"Ошибка десериализации типа \"{jObject["type"]}\".", ex);
}
return context;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
public class YPlayContext
{
public string Client { get; set; }
public YPlayContextType Context { get; set; }
public string ContextItem { get; set; }
}
public string Client { get; set; }
public YPlayContextType Context { get; set; }
public string ContextItem { get; set; }
}

View File

@@ -1,9 +1,8 @@
using YandexMusic.API.Models.Album;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
public class YPlayContextAlbum : YPlayContext
{
public class YPlayContextAlbum : YPlayContext
{
public YAlbum Payload { get; set; }
}
public YAlbum Payload { get; set; }
}

View File

@@ -1,9 +1,8 @@
using YandexMusic.API.Models.Artist;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
public class YPlayContextArtist : YPlayContext
{
public class YPlayContextArtist : YPlayContext
{
public YArtist Payload { get; set; }
}
public YArtist Payload { get; set; }
}

View File

@@ -0,0 +1,37 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
/// <summary>Конвертер для контекста воспроизведения (альбом, исполнитель, плейлист).</summary>
public class YPlayContextConverter : JsonConverter<YPlayContext>
{
public override YPlayContext? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType != JsonTokenType.StartObject)
throw new JsonException("Ожидается объект контекста");
using var doc = JsonDocument.ParseValue(ref reader);
var root = doc.RootElement;
var contextProp = root.GetProperty("context");
var contextStr = contextProp.GetString();
if (!Enum.TryParse<YPlayContextType>(contextStr, true, out var contextType))
throw new JsonException($"Неизвестный тип контекста: {contextStr}");
var rawText = root.GetRawText();
return contextType switch
{
YPlayContextType.Album => JsonSerializer.Deserialize<YPlayContextAlbum>(rawText, options),
YPlayContextType.Artist => JsonSerializer.Deserialize<YPlayContextArtist>(rawText, options),
YPlayContextType.Playlist => JsonSerializer.Deserialize<YPlayContextPlaylist>(rawText, options),
_ => JsonSerializer.Deserialize<YPlayContext>(rawText, options)
};
}
public override void Write(Utf8JsonWriter writer, YPlayContext value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
}

View File

@@ -1,9 +1,8 @@
using YandexMusic.API.Models.Playlist;
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
public class YPlayContextPlaylist : YPlayContext
{
public class YPlayContextPlaylist : YPlayContext
{
public YPlaylist Payload { get; set; }
}
public YPlaylist Payload { get; set; }
}

View File

@@ -1,9 +1,8 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context;
public enum YPlayContextType
{
public enum YPlayContextType
{
Album,
Artist,
Playlist
}
Album,
Artist,
Playlist,
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YAlbumMenuItem : YBlockEntity
{
public class YAlbumMenuItem : YBlockEntity
{
public string Title { get; set; }
}
public string Title { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YBlockEntity
{
public class YBlockEntity
{
public string BlockEntityDataId { get; set; }
}
public string BlockEntityDataId { get; set; }
}

View File

@@ -1,16 +1,15 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
{
public class YCategory : YBlockEntity
{
public string BackgroundImageUri { get; set; }
public string CategoryId { get; set; }
public bool HasBackgroundImageText { get; set; }
public string Url { get; set; }
public string UrlScheme { get; set; }
public string VoiceTitle { get; set; }
public string TextColor { get; set; }
public string TextBackgroundColor { get; set; }
public string Title { get; set; }
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YCategory : YBlockEntity
{
public string BackgroundImageUri { get; set; }
public string CategoryId { get; set; }
public bool HasBackgroundImageText { get; set; }
public string Url { get; set; }
public string UrlScheme { get; set; }
public string VoiceTitle { get; set; }
public string TextColor { get; set; }
public string TextBackgroundColor { get; set; }
public string Title { get; set; }
}
}

View File

@@ -1,11 +1,10 @@
using YandexMusic.API.Models.Common;
using YandexMusic.API.Models.Track;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YChartItem
{
public class YChartItem
{
public YTrack Track { get; set; }
public YChart Chart { get; set; }
}
public YTrack Track { get; set; }
public YChart Chart { get; set; }
}

View File

@@ -1,10 +1,9 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public enum YChartProgress
{
public enum YChartProgress
{
New,
Up,
Down,
Same
}
New,
Up,
Down,
Same,
}

View File

@@ -1,11 +1,10 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YClientWidget : YBlockEntity
{
public class YClientWidget : YBlockEntity
{
public string ImagePath { get; set; }
public string Subtitle { get; set; }
public string Text { get; set; }
public string Title { get; set; }
public string Type { get; set; }
}
public string ImagePath { get; set; }
public string Subtitle { get; set; }
public string Text { get; set; }
public string Title { get; set; }
public string Type { get; set; }
}

View File

@@ -1,9 +1,8 @@
using YandexMusic.API.Models.Album;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityAlbum : YLandingEntity
{
public class YLandingEntityAlbum : YLandingEntity
{
public YAlbum Data { get; set; }
}
public YAlbum Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityAlbumMenuItem : YLandingEntity
{
public class YLandingEntityAlbumMenuItem : YLandingEntity
{
public YAlbumMenuItem Data { get; set; }
}
public YAlbumMenuItem Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityCategory : YLandingEntity
{
public class YLandingEntityCategory : YLandingEntity
{
public YCategory Data { get; set; }
}
public YCategory Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityChart : YLandingEntity
{
public class YLandingEntityChart : YLandingEntity
{
public YChartItem Data { get; set; }
}
public YChartItem Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityClientWidget : YLandingEntity
{
public class YLandingEntityClientWidget : YLandingEntity
{
public YClientWidget Data { get; set; }
}
public YClientWidget Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityPersonalPlaylist : YLandingEntity
{
public class YLandingEntityPersonalPlaylist : YLandingEntity
{
public YPersonalPlaylist Data { get; set; }
}
public YPersonalPlaylist Data { get; set; }
}

View File

@@ -1,10 +1,10 @@
using YandexMusic.API.Models.Landing.Entity.Entities.Context;
using System.Text.Json.Serialization;
using YandexMusic.API.Models.Landing.Entity.Entities.Context;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityPlayContext : YLandingEntity
{
public class YLandingEntityPlayContext : YLandingEntity
{
[JsonConverter(typeof(YPlayContextConverter))]
public YPlayContext Data { get; set; }
}
[JsonConverter(typeof(YPlayContextConverter))]
public YPlayContext Data { get; set; }
}

View File

@@ -1,9 +1,8 @@
using YandexMusic.API.Models.Playlist;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityPlaylist : YLandingEntity
{
public class YLandingEntityPlaylist : YLandingEntity
{
public YPlaylist Data { get; set; }
}
public YPlaylist Data { get; set; }
}

View File

@@ -1,10 +1,9 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityPodcast : YLandingEntity
{
public class YLandingEntityPodcast : YLandingEntity
{
public string Description { get; set; }
public string DescriptionFormatted { get; set; }
public DateTime LastUpdated { get; set; }
public YPodcast Data { get; set; }
}
public string Description { get; set; }
public string DescriptionFormatted { get; set; }
public DateTime LastUpdated { get; set; }
public YPodcast Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityPromotion : YLandingEntity
{
public class YLandingEntityPromotion : YLandingEntity
{
public YPromotion Data { get; set; }
}
public YPromotion Data { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingEntityStation : YLandingEntity
{
public class YLandingEntityStation : YLandingEntity
{
public YCategory Data { get; set; }
}
public YCategory Data { get; set; }
}

View File

@@ -1,10 +1,9 @@
using YandexMusic.API.Models.Radio;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YLandingStation
{
public class YLandingStation
{
public YStationId Id { get; set; }
public YStationDescription Data { get; set; }
}
public YStationId Id { get; set; }
public YStationDescription Data { get; set; }
}

View File

@@ -1,14 +1,13 @@
using YandexMusic.API.Models.Playlist;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YPersonalPlaylist
{
public class YPersonalPlaylist
{
public YPlaylist Data { get; set; }
public List<string> Description { get; set; }
public bool Notify { get; set; }
public string PreviewDescription { get; set; }
public bool Ready { get; set; }
public string Type { get; set; }
}
public YPlaylist Data { get; set; }
public List<string> Description { get; set; }
public bool Notify { get; set; }
public string PreviewDescription { get; set; }
public bool Ready { get; set; }
public string Type { get; set; }
}

View File

@@ -1,12 +1,11 @@
using YandexMusic.API.Models.Album;
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YPodcast
{
public class YPodcast
{
public string Description { get; set; }
public string DescriptionFormatted { get; set; }
public DateTime LastUpdated { get; set; }
public YAlbum Podcast { get; set; }
}
public string Description { get; set; }
public string DescriptionFormatted { get; set; }
public DateTime LastUpdated { get; set; }
public YAlbum Podcast { get; set; }
}

View File

@@ -1,15 +1,14 @@
namespace YandexMusic.API.Models.Landing.Entity.Entities
namespace YandexMusic.API.Models.Landing.Entity.Entities;
public class YPromotion
{
public class YPromotion
{
public string PromoId { get; set; }
public string Title { get; set; }
public string Subtitle { get; set; }
public string Heading { get; set; }
public string UrlScheme { get; set; }
public string Url { get; set; }
public string TextColor { get; set; }
public string Gradient { get; set; }
public string Image { get; set; }
}
public string PromoId { get; set; }
public string Title { get; set; }
public string Subtitle { get; set; }
public string Heading { get; set; }
public string UrlScheme { get; set; }
public string Url { get; set; }
public string TextColor { get; set; }
public string Gradient { get; set; }
public string Image { get; set; }
}