Добавьте файлы проекта.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using YandexMusic.API.Models.Album;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
|
||||
{
|
||||
public class YPlayContextAlbum : YPlayContext
|
||||
{
|
||||
public YAlbum Payload { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using YandexMusic.API.Models.Artist;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
|
||||
{
|
||||
public class YPlayContextArtist : YPlayContext
|
||||
{
|
||||
public YArtist Payload { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
|
||||
{
|
||||
public class YPlayContextPlaylist : YPlayContext
|
||||
{
|
||||
public YPlaylist Payload { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities.Context
|
||||
{
|
||||
public enum YPlayContextType
|
||||
{
|
||||
Album,
|
||||
Artist,
|
||||
Playlist
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YAlbumMenuItem : YBlockEntity
|
||||
{
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YBlockEntity
|
||||
{
|
||||
public string BlockEntityDataId { get; set; }
|
||||
}
|
||||
}
|
||||
16
YandexMusic.API/Models/Landing/Entity/Entities/YCategory.cs
Normal file
16
YandexMusic.API/Models/Landing/Entity/Entities/YCategory.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
||||
11
YandexMusic.API/Models/Landing/Entity/Entities/YChartItem.cs
Normal file
11
YandexMusic.API/Models/Landing/Entity/Entities/YChartItem.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YChartItem
|
||||
{
|
||||
public YTrack Track { get; set; }
|
||||
public YChart Chart { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public enum YChartProgress
|
||||
{
|
||||
New,
|
||||
Up,
|
||||
Down,
|
||||
Same
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using YandexMusic.API.Models.Album;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityAlbum : YLandingEntity
|
||||
{
|
||||
public YAlbum Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityAlbumMenuItem : YLandingEntity
|
||||
{
|
||||
public YAlbumMenuItem Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityCategory : YLandingEntity
|
||||
{
|
||||
public YCategory Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityChart : YLandingEntity
|
||||
{
|
||||
public YChartItem Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityClientWidget : YLandingEntity
|
||||
{
|
||||
public YClientWidget Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityPersonalPlaylist : YLandingEntity
|
||||
{
|
||||
public YPersonalPlaylist Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using YandexMusic.API.Models.Landing.Entity.Entities.Context;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityPlayContext : YLandingEntity
|
||||
{
|
||||
[JsonConverter(typeof(YPlayContextConverter))]
|
||||
public YPlayContext Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityPlaylist : YLandingEntity
|
||||
{
|
||||
public YPlaylist Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityPodcast : YLandingEntity
|
||||
{
|
||||
public string Description { get; set; }
|
||||
public string DescriptionFormatted { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public YPodcast Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityPromotion : YLandingEntity
|
||||
{
|
||||
public YPromotion Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingEntityStation : YLandingEntity
|
||||
{
|
||||
public YCategory Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using YandexMusic.API.Models.Radio;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YLandingStation
|
||||
{
|
||||
public YStationId Id { get; set; }
|
||||
public YStationDescription Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
12
YandexMusic.API/Models/Landing/Entity/Entities/YPodcast.cs
Normal file
12
YandexMusic.API/Models/Landing/Entity/Entities/YPodcast.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using YandexMusic.API.Models.Album;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
public class YPodcast
|
||||
{
|
||||
public string Description { get; set; }
|
||||
public string DescriptionFormatted { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public YAlbum Podcast { get; set; }
|
||||
}
|
||||
}
|
||||
15
YandexMusic.API/Models/Landing/Entity/Entities/YPromotion.cs
Normal file
15
YandexMusic.API/Models/Landing/Entity/Entities/YPromotion.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace YandexMusic.API.Models.Landing.Entity.Entities
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
90
YandexMusic.API/Models/Landing/Entity/YLandingEntity.cs
Normal file
90
YandexMusic.API/Models/Landing/Entity/YLandingEntity.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using YandexMusic.API.Models.Landing.Entity.Entities;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity
|
||||
{
|
||||
public sealed class YLandingEntityConverter : JsonConverter
|
||||
{
|
||||
private YLandingEntity GetEntity(JToken jObject)
|
||||
{
|
||||
YLandingEntity entity;
|
||||
|
||||
try
|
||||
{
|
||||
YLandingEntityType type = jObject["type"].ToObject<YLandingEntityType>();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case YLandingEntityType.Album:
|
||||
entity = jObject.ToObject<YLandingEntityAlbum>();
|
||||
break;
|
||||
case YLandingEntityType.ChartItem:
|
||||
entity = jObject.ToObject<YLandingEntityChart>();
|
||||
break;
|
||||
case YLandingEntityType.PersonalPlaylist:
|
||||
entity = jObject.ToObject<YLandingEntityPersonalPlaylist>();
|
||||
break;
|
||||
case YLandingEntityType.PlayContext:
|
||||
entity = jObject.ToObject<YLandingEntityPlayContext>();
|
||||
break;
|
||||
case YLandingEntityType.Playlist:
|
||||
entity = jObject.ToObject<YLandingEntityPlaylist>();
|
||||
break;
|
||||
case YLandingEntityType.Podcast:
|
||||
entity = jObject.ToObject<YLandingEntityPodcast>();
|
||||
break;
|
||||
case YLandingEntityType.Promotion:
|
||||
entity = jObject.ToObject<YLandingEntityPromotion>();
|
||||
break;
|
||||
case YLandingEntityType.Category:
|
||||
entity = jObject.ToObject<YLandingEntityCategory>();
|
||||
break;
|
||||
case YLandingEntityType.Station:
|
||||
entity = jObject.ToObject<YLandingEntityStation>();
|
||||
break;
|
||||
case YLandingEntityType.MenuItemAlbum:
|
||||
case YLandingEntityType.MenuItemPlaylist:
|
||||
entity = jObject.ToObject<YLandingEntityAlbumMenuItem>();
|
||||
break;
|
||||
case YLandingEntityType.ClientWidget:
|
||||
entity = jObject.ToObject<YLandingEntityClientWidget>();
|
||||
break;
|
||||
default:
|
||||
entity = jObject.ToObject<YLandingEntity>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Ошибка десериализации типа \"{jObject["type"]}\".", ex);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return JArray.Load(reader)
|
||||
.Select(GetEntity)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class YLandingEntity
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public YLandingEntityType Type { get; set; }
|
||||
}
|
||||
}
|
||||
26
YandexMusic.API/Models/Landing/Entity/YLandingEntityType.cs
Normal file
26
YandexMusic.API/Models/Landing/Entity/YLandingEntityType.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing.Entity
|
||||
{
|
||||
public enum YLandingEntityType
|
||||
{
|
||||
Album,
|
||||
[EnumMember(Value = "chart-item")]
|
||||
ChartItem,
|
||||
[EnumMember(Value = "personal-playlist")]
|
||||
PersonalPlaylist,
|
||||
[EnumMember(Value = "play-context")]
|
||||
PlayContext,
|
||||
Playlist,
|
||||
Podcast,
|
||||
Promotion,
|
||||
Category,
|
||||
Station,
|
||||
[EnumMember(Value = "menu-item-album")]
|
||||
MenuItemAlbum,
|
||||
[EnumMember(Value = "menu-item-playlist")]
|
||||
MenuItemPlaylist,
|
||||
[EnumMember(Value = "client-widget")]
|
||||
ClientWidget
|
||||
}
|
||||
}
|
||||
9
YandexMusic.API/Models/Landing/YChildrenLanding.cs
Normal file
9
YandexMusic.API/Models/Landing/YChildrenLanding.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YChildrenLanding
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public bool RupEnabled { get; set; }
|
||||
public List<YLandingBlock> Blocks { get; set; }
|
||||
}
|
||||
}
|
||||
10
YandexMusic.API/Models/Landing/YLanding.cs
Normal file
10
YandexMusic.API/Models/Landing/YLanding.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLanding
|
||||
{
|
||||
public List<YLandingBlock> Blocks { get; set; }
|
||||
public string ContentId { get; set; }
|
||||
public YLandingHeaderSpecialBlock HeaderSpecialBlock { get; set; }
|
||||
public bool Pumpkin { get; set; }
|
||||
}
|
||||
}
|
||||
21
YandexMusic.API/Models/Landing/YLandingBlock.cs
Normal file
21
YandexMusic.API/Models/Landing/YLandingBlock.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using YandexMusic.API.Models.Landing.Entity;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLandingBlock
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string BackgroundImageUrl { get; set; }
|
||||
public string BackgroundVideoUrl { get; set; }
|
||||
public YLandingBlockData Data { get; set; }
|
||||
public string Description { get; set; }
|
||||
[JsonConverter(typeof(YLandingEntityConverter))]
|
||||
public List<YLandingEntity> Entities { get; set; }
|
||||
public YLandingBlockPlayContext PlayContext { get; set; }
|
||||
public string ViewAllUrl { get; set; }
|
||||
public string viewAllUrlScheme { get; set; }
|
||||
public string Title { get; set; }
|
||||
public YLandingBlockType Type { get; set; }
|
||||
public string TypeForFrom { get; set; }
|
||||
}
|
||||
}
|
||||
7
YandexMusic.API/Models/Landing/YLandingBlockData.cs
Normal file
7
YandexMusic.API/Models/Landing/YLandingBlockData.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLandingBlockData
|
||||
{
|
||||
public bool IsWizardPassed { get; set; }
|
||||
}
|
||||
}
|
||||
29
YandexMusic.API/Models/Landing/YLandingBlockType.cs
Normal file
29
YandexMusic.API/Models/Landing/YLandingBlockType.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public enum YLandingBlockType
|
||||
{
|
||||
Chart,
|
||||
[EnumMember(Value = "client-widget")]
|
||||
ClientWidget,
|
||||
[EnumMember(Value = "categories-tab")]
|
||||
CategoriesTab,
|
||||
[EnumMember(Value = "editorial-playlists")]
|
||||
EditorialPlaylists,
|
||||
Menu,
|
||||
Mixes,
|
||||
[EnumMember(Value = "new-releases")]
|
||||
NewReleases,
|
||||
[EnumMember(Value = "new-playlists")]
|
||||
NewPlaylists,
|
||||
[EnumMember(Value = "personal-playlists")]
|
||||
PersonalPlaylists,
|
||||
[EnumMember(Value = "play-contexts")]
|
||||
PlayContexts,
|
||||
Playlists,
|
||||
Podcasts,
|
||||
Promotions,
|
||||
Radio
|
||||
}
|
||||
}
|
||||
8
YandexMusic.API/Models/Landing/YLandingHeaderButton.cs
Normal file
8
YandexMusic.API/Models/Landing/YLandingHeaderButton.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLandingHeaderButton
|
||||
{
|
||||
public string Deeplink { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
13
YandexMusic.API/Models/Landing/YLandingHeaderSpecialBlock.cs
Normal file
13
YandexMusic.API/Models/Landing/YLandingHeaderSpecialBlock.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLandingHeaderSpecialBlock
|
||||
{
|
||||
public string AnimationUrl { get; set; }
|
||||
public string BgImageUrl { get; set; }
|
||||
public YLandingHeaderButton Button { get; set; }
|
||||
public string DoodleImageUrl { get; set; }
|
||||
public string EndGradientColor { get; set; }
|
||||
public string StartGradientColor { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
9
YandexMusic.API/Models/Landing/YLandingPlayContext.cs
Normal file
9
YandexMusic.API/Models/Landing/YLandingPlayContext.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Landing
|
||||
{
|
||||
public class YLandingBlockPlayContext
|
||||
{
|
||||
public string Uid { get; set; }
|
||||
public string Kind { get; set; }
|
||||
public string PlaylistUuid { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user