Добавьте файлы проекта.
This commit is contained in:
54
YandexMusic.API/Models/Radio/Restriction/YRestriction.cs
Normal file
54
YandexMusic.API/Models/Radio/Restriction/YRestriction.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
namespace YandexMusic.API.Models.Radio.Restriction
|
||||
{
|
||||
public sealed class YRestrictionConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return typeof(YRestriction).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);
|
||||
YRestriction restriction;
|
||||
|
||||
try
|
||||
{
|
||||
YRestrictionType type = jObject["type"].ToObject<YRestrictionType>();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case YRestrictionType.Enum:
|
||||
restriction = jObject.ToObject<YRestrictionEnum>();
|
||||
break;
|
||||
case YRestrictionType.DiscreteScale:
|
||||
restriction = jObject.ToObject<YRestrictionDiscreteScale>();
|
||||
break;
|
||||
default:
|
||||
restriction = jObject.ToObject<YRestriction>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Ошибка десериализации типа \"{objectType.Name}\".", ex);
|
||||
}
|
||||
|
||||
return restriction;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class YRestriction
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public YRestrictionType Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace YandexMusic.API.Models.Radio.Restriction
|
||||
{
|
||||
public class YRestrictionDiscreteScale : YRestriction
|
||||
{
|
||||
public YRestrictionValue<int> Min { get; set; }
|
||||
public YRestrictionValue<int> Max { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace YandexMusic.API.Models.Radio.Restriction
|
||||
{
|
||||
public class YRestrictionEnum : YRestriction
|
||||
{
|
||||
public List<YRestrictionValue<string>> PossibleValues { get; set; }
|
||||
}
|
||||
}
|
||||
12
YandexMusic.API/Models/Radio/Restriction/YRestrictionType.cs
Normal file
12
YandexMusic.API/Models/Radio/Restriction/YRestrictionType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio.Restriction
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum YRestrictionType
|
||||
{
|
||||
[EnumMember(Value = "discrete-scale")]
|
||||
DiscreteScale,
|
||||
Enum
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace YandexMusic.API.Models.Radio.Restriction
|
||||
{
|
||||
public class YRestrictionValue<T>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public T Value { get; set; }
|
||||
}
|
||||
}
|
||||
14
YandexMusic.API/Models/Radio/YAdParams.cs
Normal file
14
YandexMusic.API/Models/Radio/YAdParams.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YAdParams
|
||||
{
|
||||
public decimal AdVolume { get; set; }
|
||||
public string CategoryId { get; set; }
|
||||
public int GenreId { get; set; }
|
||||
public string GenreName { get; set; }
|
||||
public string OtherParams { get; set; }
|
||||
public string PageRef { get; set; }
|
||||
public string PartnerId { get; set; }
|
||||
public string TargetRef { get; set; }
|
||||
}
|
||||
}
|
||||
12
YandexMusic.API/Models/Radio/YBrand.cs
Normal file
12
YandexMusic.API/Models/Radio/YBrand.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YBrand
|
||||
{
|
||||
public string AdvertiserUrl { get; set; }
|
||||
public string BackgroundColor { get; set; }
|
||||
public string BackgroundImageUri { get; set; }
|
||||
public string GlowColor { get; set; }
|
||||
public string MainImageUri { get; set; }
|
||||
public string Theme { get; set; }
|
||||
}
|
||||
}
|
||||
12
YandexMusic.API/Models/Radio/YSequenceItem.cs
Normal file
12
YandexMusic.API/Models/Radio/YSequenceItem.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YSequenceItem
|
||||
{
|
||||
public bool Liked { get; set; }
|
||||
public YTrack Track { get; set; }
|
||||
public YTrackParameters TrackParameters { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
18
YandexMusic.API/Models/Radio/YStation.cs
Normal file
18
YandexMusic.API/Models/Radio/YStation.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using YandexMusic.API.Models.Common;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStation : YBaseModel
|
||||
{
|
||||
public YAdParams AdParams { get; set; }
|
||||
public string CustomName { get; set; }
|
||||
public YStationData Data { get; set; }
|
||||
public string Explanation { get; set; }
|
||||
public List<YPrerolls> Prerolls { get; set; }
|
||||
public string RupTitle { get; set; }
|
||||
public string RupDescription { get; set; }
|
||||
public YStationSettings Settings { get; set; }
|
||||
public YStationSettings2 Settings2 { get; set; }
|
||||
public YStationDescription Station { get; set; }
|
||||
}
|
||||
}
|
||||
13
YandexMusic.API/Models/Radio/YStationData.cs
Normal file
13
YandexMusic.API/Models/Radio/YStationData.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using YandexMusic.API.Models.Artist;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationData
|
||||
{
|
||||
public List<YArtist> Artists { get; set; }
|
||||
public YBrand Brand { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ImageUri { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
17
YandexMusic.API/Models/Radio/YStationDescription.cs
Normal file
17
YandexMusic.API/Models/Radio/YStationDescription.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationDescription
|
||||
{
|
||||
public string FullImageUrl { get; set; }
|
||||
public YStationIcon GeocellIcon { get; set; }
|
||||
public YStationIcon Icon { get; set; }
|
||||
public YStationId Id { get; set; }
|
||||
public string IdForFrom { get; set; }
|
||||
public string MtsFullImageUrl { get; set; }
|
||||
public YStationIcon MtsIcon { get; set; }
|
||||
public string Name { get; set; }
|
||||
public YStationId ParentId { get; set; }
|
||||
public YStationRestrictions Restrictions { get; set; }
|
||||
public YStationRestrictions2 Restrictions2 { get; set; }
|
||||
}
|
||||
}
|
||||
11
YandexMusic.API/Models/Radio/YStationFeedback.cs
Normal file
11
YandexMusic.API/Models/Radio/YStationFeedback.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
internal sealed class YStationFeedback
|
||||
{
|
||||
public YStationFeedbackType Type { get; set; }
|
||||
public long Timestamp { get; set; }
|
||||
public string From { get; set; }
|
||||
public double TotalPlayedSeconds { get; set; }
|
||||
public string TrackId { get; set; }
|
||||
}
|
||||
}
|
||||
10
YandexMusic.API/Models/Radio/YStationFeedbackType.cs
Normal file
10
YandexMusic.API/Models/Radio/YStationFeedbackType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public enum YStationFeedbackType
|
||||
{
|
||||
RadioStarted,
|
||||
TrackStarted,
|
||||
TrackFinished,
|
||||
Skip
|
||||
}
|
||||
}
|
||||
8
YandexMusic.API/Models/Radio/YStationIcon.cs
Normal file
8
YandexMusic.API/Models/Radio/YStationIcon.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationIcon
|
||||
{
|
||||
public string BackgroundColor { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
}
|
||||
}
|
||||
8
YandexMusic.API/Models/Radio/YStationId.cs
Normal file
8
YandexMusic.API/Models/Radio/YStationId.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationId
|
||||
{
|
||||
public string Tag { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
16
YandexMusic.API/Models/Radio/YStationRestrictions.cs
Normal file
16
YandexMusic.API/Models/Radio/YStationRestrictions.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using YandexMusic.API.Models.Radio.Restriction;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationRestrictions
|
||||
{
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Diversity { get; set; }
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Energy { get; set; }
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Language { get; set; }
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Mood { get; set; }
|
||||
}
|
||||
}
|
||||
14
YandexMusic.API/Models/Radio/YStationRestrictions2.cs
Normal file
14
YandexMusic.API/Models/Radio/YStationRestrictions2.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using YandexMusic.API.Models.Radio.Restriction;
|
||||
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationRestrictions2
|
||||
{
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Diversity { get; set; }
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction Language { get; set; }
|
||||
[JsonConverter(typeof(YRestrictionConverter))]
|
||||
public YRestriction MoodEnergy { get; set; }
|
||||
}
|
||||
}
|
||||
11
YandexMusic.API/Models/Radio/YStationSequence.cs
Normal file
11
YandexMusic.API/Models/Radio/YStationSequence.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationSequence
|
||||
{
|
||||
public string BatchId { get; set; }
|
||||
public YStationId Id { get; set; }
|
||||
public bool Pumpkin { get; set; }
|
||||
public string RadioSessionId { get; set; }
|
||||
public List<YSequenceItem> Sequence { get; set; }
|
||||
}
|
||||
}
|
||||
10
YandexMusic.API/Models/Radio/YStationSettings.cs
Normal file
10
YandexMusic.API/Models/Radio/YStationSettings.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationSettings
|
||||
{
|
||||
public string Diversity { get; set; }
|
||||
public string Energy { get; set; }
|
||||
public string Language { get; set; }
|
||||
public string Mood { get; set; }
|
||||
}
|
||||
}
|
||||
9
YandexMusic.API/Models/Radio/YStationSettings2.cs
Normal file
9
YandexMusic.API/Models/Radio/YStationSettings2.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationSettings2
|
||||
{
|
||||
public string Diversity { get; set; }
|
||||
public string Language { get; set; }
|
||||
public string MoodEnergy { get; set; }
|
||||
}
|
||||
}
|
||||
9
YandexMusic.API/Models/Radio/YStationsDashboard.cs
Normal file
9
YandexMusic.API/Models/Radio/YStationsDashboard.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YStationsDashboard
|
||||
{
|
||||
public string DashboardId { get; set; }
|
||||
public bool Pumpkin { get; set; }
|
||||
public List<YStation> Stations { get; set; }
|
||||
}
|
||||
}
|
||||
9
YandexMusic.API/Models/Radio/YTrackParameters.cs
Normal file
9
YandexMusic.API/Models/Radio/YTrackParameters.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace YandexMusic.API.Models.Radio
|
||||
{
|
||||
public class YTrackParameters
|
||||
{
|
||||
public int Bpm { get; set; }
|
||||
public int Hue { get; set; }
|
||||
public decimal Energy { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user