Skip to content

Instantly share code, notes, and snippets.

@Lucas7yoshi
Created February 20, 2019 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lucas7yoshi/286aa06a1440c5de4abce89a36baf827 to your computer and use it in GitHub Desktop.
Save Lucas7yoshi/286aa06a1440c5de4abce89a36baf827 to your computer and use it in GitHub Desktop.
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var news = News.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class News
{
[JsonProperty("_title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("_activeDate", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? ActiveDate { get; set; }
[JsonProperty("lastModified", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? LastModified { get; set; }
[JsonProperty("_locale", NullValueHandling = NullValueHandling.Ignore)]
public Locale? Locale { get; set; }
[JsonProperty("survivalmessage", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Survivalmessage { get; set; }
[JsonProperty("athenamessage", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Athenamessage { get; set; }
[JsonProperty("subgameselectdata", NullValueHandling = NullValueHandling.Ignore)]
public Subgameselectdata Subgameselectdata { get; set; }
[JsonProperty("savetheworldnews", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Savetheworldnews { get; set; }
[JsonProperty("battleroyalenews", NullValueHandling = NullValueHandling.Ignore)]
public Battleroyalenews Battleroyalenews { get; set; }
[JsonProperty("loginmessage", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Loginmessage { get; set; }
[JsonProperty("playlistimages", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Playlistimages { get; set; }
[JsonProperty("battlepassaboutmessages", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Battlepassaboutmessages { get; set; }
[JsonProperty("playlistinformation", NullValueHandling = NullValueHandling.Ignore)]
public Playlistinformation Playlistinformation { get; set; }
[JsonProperty("tournamentinformation", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Tournamentinformation { get; set; }
[JsonProperty("emergencynotice", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Emergencynotice { get; set; }
[JsonProperty("koreancafe", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Koreancafe { get; set; }
[JsonProperty("creativenews", NullValueHandling = NullValueHandling.Ignore)]
public Athenamessage Creativenews { get; set; }
[JsonProperty("_suggestedPrefetch", NullValueHandling = NullValueHandling.Ignore)]
public object[] SuggestedPrefetch { get; set; }
}
public partial class Athenamessage
{
[JsonProperty("_title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("overrideablemessage", NullValueHandling = NullValueHandling.Ignore)]
public LoginmessageClass Overrideablemessage { get; set; }
[JsonProperty("_activeDate", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? ActiveDate { get; set; }
[JsonProperty("lastModified", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? LastModified { get; set; }
[JsonProperty("_locale", NullValueHandling = NullValueHandling.Ignore)]
public Locale? Locale { get; set; }
[JsonProperty("news", NullValueHandling = NullValueHandling.Ignore)]
public PurpleNews News { get; set; }
[JsonProperty("ad_info", NullValueHandling = NullValueHandling.Ignore)]
public AdInfo AdInfo { get; set; }
[JsonProperty("cafe_info", NullValueHandling = NullValueHandling.Ignore)]
public CafeInfo CafeInfo { get; set; }
[JsonProperty("loginmessage", NullValueHandling = NullValueHandling.Ignore)]
public LoginmessageClass Loginmessage { get; set; }
[JsonProperty("playlistimages", NullValueHandling = NullValueHandling.Ignore)]
public Playlistimages Playlistimages { get; set; }
[JsonProperty("tournament_info", NullValueHandling = NullValueHandling.Ignore)]
public TournamentInfo TournamentInfo { get; set; }
}
public partial class AdInfo
{
[JsonProperty("ads", NullValueHandling = NullValueHandling.Ignore)]
public Ad[] Ads { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
}
public partial class Ad
{
[JsonProperty("sub_header", NullValueHandling = NullValueHandling.Ignore)]
public string SubHeader { get; set; }
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public Uri Image { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; set; }
[JsonProperty("header", NullValueHandling = NullValueHandling.Ignore)]
public string Header { get; set; }
}
public partial class CafeInfo
{
[JsonProperty("cafes", NullValueHandling = NullValueHandling.Ignore)]
public Cafe[] Cafes { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
}
public partial class Cafe
{
[JsonProperty("korean_cafe", NullValueHandling = NullValueHandling.Ignore)]
public string KoreanCafe { get; set; }
[JsonProperty("korean_cafe_description", NullValueHandling = NullValueHandling.Ignore)]
public string KoreanCafeDescription { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("korean_cafe_header", NullValueHandling = NullValueHandling.Ignore)]
public string KoreanCafeHeader { get; set; }
}
public partial class LoginmessageClass
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public LoginmessageMessage Message { get; set; }
}
public partial class LoginmessageMessage
{
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public Uri Image { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public MessageType? Type { get; set; }
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("body", NullValueHandling = NullValueHandling.Ignore)]
public string Body { get; set; }
}
public partial class PurpleNews
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("messages", NullValueHandling = NullValueHandling.Ignore)]
public MessageElement[] Messages { get; set; }
[JsonProperty("platform_messages", NullValueHandling = NullValueHandling.Ignore)]
public PurplePlatformMessage[] PlatformMessages { get; set; }
}
public partial class MessageElement
{
[JsonProperty("layout", NullValueHandling = NullValueHandling.Ignore)]
public string Layout { get; set; }
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public Uri Image { get; set; }
[JsonProperty("hidden", NullValueHandling = NullValueHandling.Ignore)]
public bool? Hidden { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public MessageType? Type { get; set; }
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("body", NullValueHandling = NullValueHandling.Ignore)]
public string Body { get; set; }
[JsonProperty("spotlight", NullValueHandling = NullValueHandling.Ignore)]
public bool? Spotlight { get; set; }
[JsonProperty("messagetype", NullValueHandling = NullValueHandling.Ignore)]
public Messagetype? Messagetype { get; set; }
[JsonProperty("adspace", NullValueHandling = NullValueHandling.Ignore)]
public string Adspace { get; set; }
}
public partial class PurplePlatformMessage
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public PlatformMessageMessage Message { get; set; }
[JsonProperty("platform", NullValueHandling = NullValueHandling.Ignore)]
public string Platform { get; set; }
}
public partial class PlatformMessageMessage
{
[JsonProperty("hidden", NullValueHandling = NullValueHandling.Ignore)]
public bool? Hidden { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public MessageType? Type { get; set; }
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("body", NullValueHandling = NullValueHandling.Ignore)]
public string Body { get; set; }
[JsonProperty("spotlight", NullValueHandling = NullValueHandling.Ignore)]
public bool? Spotlight { get; set; }
}
public partial class Playlistimages
{
[JsonProperty("images", NullValueHandling = NullValueHandling.Ignore)]
public Image[] Images { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
}
public partial class Image
{
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public string ImageImage { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public ImageType? Type { get; set; }
[JsonProperty("playlistname", NullValueHandling = NullValueHandling.Ignore)]
public string Playlistname { get; set; }
}
public partial class TournamentInfo
{
[JsonProperty("tournaments", NullValueHandling = NullValueHandling.Ignore)]
public Tournament[] Tournaments { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
}
public partial class Tournament
{
[JsonProperty("background_text_color", NullValueHandling = NullValueHandling.Ignore)]
public string BackgroundTextColor { get; set; }
[JsonProperty("poster_back_image", NullValueHandling = NullValueHandling.Ignore)]
public Uri PosterBackImage { get; set; }
[JsonProperty("flavor_description", NullValueHandling = NullValueHandling.Ignore)]
public string FlavorDescription { get; set; }
[JsonProperty("poster_front_image", NullValueHandling = NullValueHandling.Ignore)]
public Uri PosterFrontImage { get; set; }
[JsonProperty("short_format_title", NullValueHandling = NullValueHandling.Ignore)]
public string ShortFormatTitle { get; set; }
[JsonProperty("title_line_2", NullValueHandling = NullValueHandling.Ignore)]
public string TitleLine2 { get; set; }
[JsonProperty("title_line_1", NullValueHandling = NullValueHandling.Ignore)]
public string TitleLine1 { get; set; }
[JsonProperty("details_description", NullValueHandling = NullValueHandling.Ignore)]
public string DetailsDescription { get; set; }
[JsonProperty("long_format_title", NullValueHandling = NullValueHandling.Ignore)]
public string LongFormatTitle { get; set; }
[JsonProperty("poster_fade_color", NullValueHandling = NullValueHandling.Ignore)]
public string PosterFadeColor { get; set; }
[JsonProperty("secondary_color", NullValueHandling = NullValueHandling.Ignore)]
public string SecondaryColor { get; set; }
[JsonProperty("pin_score_requirement", NullValueHandling = NullValueHandling.Ignore)]
public long? PinScoreRequirement { get; set; }
[JsonProperty("title_color", NullValueHandling = NullValueHandling.Ignore)]
public string TitleColor { get; set; }
[JsonProperty("loading_screen_image", NullValueHandling = NullValueHandling.Ignore)]
public Uri LoadingScreenImage { get; set; }
[JsonProperty("background_right_color", NullValueHandling = NullValueHandling.Ignore)]
public string BackgroundRightColor { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public TournamentType? Type { get; set; }
[JsonProperty("pin_earned_text", NullValueHandling = NullValueHandling.Ignore)]
public string PinEarnedText { get; set; }
[JsonProperty("tournament_display_id", NullValueHandling = NullValueHandling.Ignore)]
public string TournamentDisplayId { get; set; }
[JsonProperty("highlight_color", NullValueHandling = NullValueHandling.Ignore)]
public string HighlightColor { get; set; }
[JsonProperty("schedule_info", NullValueHandling = NullValueHandling.Ignore)]
public string ScheduleInfo { get; set; }
[JsonProperty("primary_color", NullValueHandling = NullValueHandling.Ignore)]
public string PrimaryColor { get; set; }
[JsonProperty("shadow_color", NullValueHandling = NullValueHandling.Ignore)]
public string ShadowColor { get; set; }
[JsonProperty("background_left_color", NullValueHandling = NullValueHandling.Ignore)]
public string BackgroundLeftColor { get; set; }
[JsonProperty("playlist_tile_image", NullValueHandling = NullValueHandling.Ignore)]
public Uri PlaylistTileImage { get; set; }
[JsonProperty("base_color", NullValueHandling = NullValueHandling.Ignore)]
public BaseColor? BaseColor { get; set; }
}
public partial class Battleroyalenews
{
[JsonProperty("news", NullValueHandling = NullValueHandling.Ignore)]
public BattleroyalenewsNews News { get; set; }
[JsonProperty("_title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("header", NullValueHandling = NullValueHandling.Ignore)]
public string Header { get; set; }
[JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)]
public Style? Style { get; set; }
[JsonProperty("_activeDate", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? ActiveDate { get; set; }
[JsonProperty("lastModified", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? LastModified { get; set; }
[JsonProperty("_locale", NullValueHandling = NullValueHandling.Ignore)]
public Locale? Locale { get; set; }
}
public partial class BattleroyalenewsNews
{
[JsonProperty("platform_messages", NullValueHandling = NullValueHandling.Ignore)]
public FluffyPlatformMessage[] PlatformMessages { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("messages", NullValueHandling = NullValueHandling.Ignore)]
public MessageElement[] Messages { get; set; }
}
public partial class FluffyPlatformMessage
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("platform", NullValueHandling = NullValueHandling.Ignore)]
public string Platform { get; set; }
}
public partial class Playlistinformation
{
[JsonProperty("frontend_matchmaking_header_style", NullValueHandling = NullValueHandling.Ignore)]
public Style? FrontendMatchmakingHeaderStyle { get; set; }
[JsonProperty("_title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("frontend_matchmaking_header_text", NullValueHandling = NullValueHandling.Ignore)]
public string FrontendMatchmakingHeaderText { get; set; }
[JsonProperty("playlist_info", NullValueHandling = NullValueHandling.Ignore)]
public PlaylistInfo PlaylistInfo { get; set; }
[JsonProperty("_activeDate", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? ActiveDate { get; set; }
[JsonProperty("lastModified", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? LastModified { get; set; }
[JsonProperty("_locale", NullValueHandling = NullValueHandling.Ignore)]
public Locale? Locale { get; set; }
}
public partial class PlaylistInfo
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("playlists", NullValueHandling = NullValueHandling.Ignore)]
public Playlist[] Playlists { get; set; }
}
public partial class Playlist
{
[JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)]
public Uri Image { get; set; }
[JsonProperty("playlist_name", NullValueHandling = NullValueHandling.Ignore)]
public string PlaylistName { get; set; }
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public PlaylistType? Type { get; set; }
[JsonProperty("violator", NullValueHandling = NullValueHandling.Ignore)]
public Violator? Violator { get; set; }
[JsonProperty("display_name", NullValueHandling = NullValueHandling.Ignore)]
public string DisplayName { get; set; }
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; set; }
[JsonProperty("extra_images", NullValueHandling = NullValueHandling.Ignore)]
public Uri[] ExtraImages { get; set; }
[JsonProperty("special_border", NullValueHandling = NullValueHandling.Ignore)]
public Style? SpecialBorder { get; set; }
[JsonProperty("display_subname", NullValueHandling = NullValueHandling.Ignore)]
public string DisplaySubname { get; set; }
}
public partial class Subgameselectdata
{
[JsonProperty("saveTheWorldUnowned", NullValueHandling = NullValueHandling.Ignore)]
public BattleRoyale SaveTheWorldUnowned { get; set; }
[JsonProperty("_title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("battleRoyale", NullValueHandling = NullValueHandling.Ignore)]
public BattleRoyale BattleRoyale { get; set; }
[JsonProperty("creative", NullValueHandling = NullValueHandling.Ignore)]
public BattleRoyale Creative { get; set; }
[JsonProperty("saveTheWorld", NullValueHandling = NullValueHandling.Ignore)]
public BattleRoyale SaveTheWorld { get; set; }
[JsonProperty("_activeDate", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? ActiveDate { get; set; }
[JsonProperty("lastModified", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? LastModified { get; set; }
[JsonProperty("_locale", NullValueHandling = NullValueHandling.Ignore)]
public Locale? Locale { get; set; }
}
public partial class BattleRoyale
{
[JsonProperty("_type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public MessageElement Message { get; set; }
}
public enum Locale { EnUs };
public enum MessageType { CommonUiSimpleMessageBase };
public enum Messagetype { Normal, Sale };
public enum ImageType { PlaylistImageEntry };
public enum BaseColor { BaseColorFfffff, Ffffff, PurpleFfffff };
public enum TournamentType { TournamentDisplayInfo };
public enum Style { HighStakes, None };
public enum PlaylistType { FortPlaylistInfo };
public enum Violator { Empty, New };
public partial class News
{
public static News FromJson(string json) => JsonConvert.DeserializeObject<News>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this News self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
LocaleConverter.Singleton,
MessageTypeConverter.Singleton,
MessagetypeConverter.Singleton,
ImageTypeConverter.Singleton,
TournamentTypeConverter.Singleton,
BaseColorConverter.Singleton,
StyleConverter.Singleton,
PlaylistTypeConverter.Singleton,
ViolatorConverter.Singleton,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
internal class LocaleConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Locale) || t == typeof(Locale?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "en-US")
{
return Locale.EnUs;
}
throw new Exception("Cannot unmarshal type Locale");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (Locale)untypedValue;
if (value == Locale.EnUs)
{
serializer.Serialize(writer, "en-US");
return;
}
throw new Exception("Cannot marshal type Locale");
}
public static readonly LocaleConverter Singleton = new LocaleConverter();
}
internal class MessageTypeConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(MessageType) || t == typeof(MessageType?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "CommonUI Simple Message Base")
{
return MessageType.CommonUiSimpleMessageBase;
}
throw new Exception("Cannot unmarshal type MessageType");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (MessageType)untypedValue;
if (value == MessageType.CommonUiSimpleMessageBase)
{
serializer.Serialize(writer, "CommonUI Simple Message Base");
return;
}
throw new Exception("Cannot marshal type MessageType");
}
public static readonly MessageTypeConverter Singleton = new MessageTypeConverter();
}
internal class MessagetypeConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Messagetype) || t == typeof(Messagetype?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
switch (value)
{
case "normal":
return Messagetype.Normal;
case "sale":
return Messagetype.Sale;
}
throw new Exception("Cannot unmarshal type Messagetype");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (Messagetype)untypedValue;
switch (value)
{
case Messagetype.Normal:
serializer.Serialize(writer, "normal");
return;
case Messagetype.Sale:
serializer.Serialize(writer, "sale");
return;
}
throw new Exception("Cannot marshal type Messagetype");
}
public static readonly MessagetypeConverter Singleton = new MessagetypeConverter();
}
internal class ImageTypeConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(ImageType) || t == typeof(ImageType?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "PlaylistImageEntry")
{
return ImageType.PlaylistImageEntry;
}
throw new Exception("Cannot unmarshal type ImageType");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (ImageType)untypedValue;
if (value == ImageType.PlaylistImageEntry)
{
serializer.Serialize(writer, "PlaylistImageEntry");
return;
}
throw new Exception("Cannot marshal type ImageType");
}
public static readonly ImageTypeConverter Singleton = new ImageTypeConverter();
}
internal class TournamentTypeConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(TournamentType) || t == typeof(TournamentType?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "Tournament Display Info")
{
return TournamentType.TournamentDisplayInfo;
}
throw new Exception("Cannot unmarshal type TournamentType");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (TournamentType)untypedValue;
if (value == TournamentType.TournamentDisplayInfo)
{
serializer.Serialize(writer, "Tournament Display Info");
return;
}
throw new Exception("Cannot marshal type TournamentType");
}
public static readonly TournamentTypeConverter Singleton = new TournamentTypeConverter();
}
internal class BaseColorConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(BaseColor) || t == typeof(BaseColor?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
switch (value)
{
case " FFFFFF":
return BaseColor.BaseColorFfffff;
case "FFFFFF":
return BaseColor.Ffffff;
case "ffffff":
return BaseColor.PurpleFfffff;
}
throw new Exception("Cannot unmarshal type BaseColor");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (BaseColor)untypedValue;
switch (value)
{
case BaseColor.BaseColorFfffff:
serializer.Serialize(writer, " FFFFFF");
return;
case BaseColor.Ffffff:
serializer.Serialize(writer, "FFFFFF");
return;
case BaseColor.PurpleFfffff:
serializer.Serialize(writer, "ffffff");
return;
}
throw new Exception("Cannot marshal type BaseColor");
}
public static readonly BaseColorConverter Singleton = new BaseColorConverter();
}
internal class StyleConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Style) || t == typeof(Style?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
switch (value)
{
case "HighStakes":
return Style.HighStakes;
case "None":
return Style.None;
}
throw new Exception("Cannot unmarshal type Style");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (Style)untypedValue;
switch (value)
{
case Style.HighStakes:
serializer.Serialize(writer, "HighStakes");
return;
case Style.None:
serializer.Serialize(writer, "None");
return;
}
throw new Exception("Cannot marshal type Style");
}
public static readonly StyleConverter Singleton = new StyleConverter();
}
internal class PlaylistTypeConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(PlaylistType) || t == typeof(PlaylistType?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "FortPlaylistInfo")
{
return PlaylistType.FortPlaylistInfo;
}
throw new Exception("Cannot unmarshal type PlaylistType");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (PlaylistType)untypedValue;
if (value == PlaylistType.FortPlaylistInfo)
{
serializer.Serialize(writer, "FortPlaylistInfo");
return;
}
throw new Exception("Cannot marshal type PlaylistType");
}
public static readonly PlaylistTypeConverter Singleton = new PlaylistTypeConverter();
}
internal class ViolatorConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Violator) || t == typeof(Violator?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
switch (value)
{
case "":
return Violator.Empty;
case "New!":
return Violator.New;
}
throw new Exception("Cannot unmarshal type Violator");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (Violator)untypedValue;
switch (value)
{
case Violator.Empty:
serializer.Serialize(writer, "");
return;
case Violator.New:
serializer.Serialize(writer, "New!");
return;
}
throw new Exception("Cannot marshal type Violator");
}
public static readonly ViolatorConverter Singleton = new ViolatorConverter();
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Tweetinvi;
using Tweetinvi.Models;
using Tweetinvi.Parameters;
namespace TwitterNewsBot
{
class Program
{
static void Main(string[] args)
{
//PostTweet("booted");
var old = HttpGet("https://fortnitecontent-website-prod07.ol.epicgames.com/content/api/pages/fortnite-game");
while (true)
{
var current = "";
try
{
current = HttpGet("https://fortnitecontent-website-prod07.ol.epicgames.com/content/api/pages/fortnite-game");
if (old != current)
{
var oldnews = QuickType.News.FromJson(old).Battleroyalenews.News.Messages;
var news = QuickType.News.FromJson(current).Battleroyalenews.News.Messages;
if (news[0].Image.AbsoluteUri != oldnews[0].Image.AbsoluteUri)
{
if (news[0].Image.AbsoluteUri != oldnews[1].Image.AbsoluteUri && news[0].Image.AbsoluteUri != oldnews[2].Image.AbsoluteUri)
{
var image = DownloadFile(news[0].Image.AbsoluteUri).GetAwaiter().GetResult();
PostTweet($"News Update: \n\n{news[0].Adspace}\n{news[0].Title}\n{news[0].Body}", image);
}
}
if (news[1].Image.AbsoluteUri != oldnews[1].Image.AbsoluteUri)
{
if (news[1].Image.AbsoluteUri != oldnews[0].Image.AbsoluteUri && news[1].Image.AbsoluteUri != oldnews[2].Image.AbsoluteUri)
{
var image = DownloadFile(news[1].Image.AbsoluteUri).GetAwaiter().GetResult();
PostTweet($"News Update: \n\n{news[1].Adspace}\n{news[1].Title}\n{news[1].Body}", image);
}
}
if (news[2].Image.AbsoluteUri != oldnews[2].Image.AbsoluteUri)
{
if (news[2].Image.AbsoluteUri != oldnews[0].Image.AbsoluteUri && news[2].Image.AbsoluteUri != oldnews[1].Image.AbsoluteUri)
{
var image = DownloadFile(news[2].Image.AbsoluteUri).GetAwaiter().GetResult();
PostTweet($"News Update: \n\n{news[2].Adspace}\n{news[2].Title}\n{news[2].Body}", image);
}
}
}
//}
old = current;
Thread.Sleep(2500);
old = current;
}
catch (Exception ex)
{
Console.WriteLine("Error Occured\n" + ex.Message + "\n" + ex.StackTrace);
}
}
}
public static int count = 0;
public static void PostTweet(string status, byte[] file1 = null)
{
if (file1 == null)
{
Auth.SetUserCredentials("", "", "", "");
Console.WriteLine("Sending tweet");
//
var msg = Tweet.PublishTweet(status);
Thread.Sleep(10000);
msg.DestroyAsync().GetAwaiter().GetResult();
count += 0;
return;
}
if (count <= 199)
{
Auth.SetUserCredentials("", "", "", "");
Console.WriteLine("Sending tweet");
//byte[] file1 = File.ReadAllBytes(imagepath);
var media = Upload.UploadBinary(file1);
Tweet.PublishTweet(status, new PublishTweetOptionalParameters
{
Medias = new List<IMedia>() { media }
});
count += 1;
}
else if (count == 200)
{
Auth.SetUserCredentials("", "", "", "");
Console.WriteLine("Sending tweet");
//byte[] file1 = File.ReadAllBytes(imagepath);
//var media = Upload.UploadBinary(file1);
Tweet.PublishTweet("The news bot has been disabled as it has exceeded 30 posts in this session to avoid spam\n\n[Auto Post]");
count += 10000;
}
}
public static string jsonit(QuickType.MessageElement input)
{
return JsonConvert.SerializeObject(input, Formatting.Indented);
}
public static string HttpGet(string URI)
{
var sw = new Stopwatch();
sw.Start();
string s = client.GetAsync(URI).GetAwaiter().GetResult().Content.ReadAsStringAsync().GetAwaiter().GetResult();
sw.Stop();
Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + "] " + "HttpGet took " + sw.ElapsedMilliseconds + "ms");
return s;
}
public static HttpClient client = new HttpClient();
public static async Task<byte[]> DownloadFile(string url)
{
using (var result = await client.GetAsync(url))
{
//File.WriteAllBytes(path, result.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult());
return result.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment