diff --git a/Booru.Net.Tests/Program.cs b/Booru.Net.Tests/Program.cs index ceae5a0..8c6eb5e 100644 --- a/Booru.Net.Tests/Program.cs +++ b/Booru.Net.Tests/Program.cs @@ -12,7 +12,7 @@ namespace Booru.Net.Tests { var BooruClient = new BooruClient(); - var posts = await BooruClient.GetRealBooruImagesAsync(); + var posts = await BooruClient.GetSafebooruImagesAsync(); Console.ReadLine(); } diff --git a/Booru.Net/Models/Boards/BooruImage.cs b/Booru.Net/Models/Boards/BooruImage.cs index 060da94..43f7113 100644 --- a/Booru.Net/Models/Boards/BooruImage.cs +++ b/Booru.Net/Models/Boards/BooruImage.cs @@ -13,22 +13,23 @@ namespace Booru.Net [JsonProperty("rating")] private string Prating { get; set; } - [JsonProperty("file_url")] - public string ImageUrl { get; set; } + public virtual string ImageUrl { get; set; } + + public virtual string PostUrl { get; set; } public Rating Rating { get { - if(Prating == "s") + if(Prating.ToLowerInvariant().StartsWith("s")) { return Rating.Safe; } - if(Prating == "q") + if(Prating.ToLowerInvariant().StartsWith("q")) { return Rating.Questionable; } - if(Prating == "e") + if(Prating.ToLowerInvariant().StartsWith("e")) { return Rating.Explicit; } diff --git a/Booru.Net/Models/Boards/SafebooruImage.cs b/Booru.Net/Models/Boards/SafebooruImage.cs index 5d44a45..90640c8 100644 --- a/Booru.Net/Models/Boards/SafebooruImage.cs +++ b/Booru.Net/Models/Boards/SafebooruImage.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Booru.Net { - public class SafebooruImage + public class SafebooruImage : BooruImage { [JsonProperty("directory")] public string Directory { get; set; } @@ -14,9 +14,6 @@ namespace Booru.Net [JsonProperty("height")] public int Height { get; set; } - [JsonProperty("id")] - public int ID { get; set; } - [JsonProperty("image")] public string Image { get; set; } @@ -29,9 +26,6 @@ namespace Booru.Net [JsonProperty("parent_id")] public int? ParentID { get; set; } - [JsonProperty("rating")] - public Rating Rating { get; set; } - [JsonProperty("sample")] public bool Sample { get; set; } @@ -41,21 +35,19 @@ namespace Booru.Net [JsonProperty("sample_width")] public int SampleWidth { get; set; } - [JsonProperty("score")] - public int? Score { get; set; } - [JsonProperty("tags")] private string Ptags { get; set; } [JsonProperty("width")] public int Width { get; set; } - public IReadOnlyList Tags { get { return Ptags.Split(' '); } } + public IReadOnlyList Tags + => Ptags.Split(' '); - public virtual string ImageUrl + public override string ImageUrl => "https://safebooru.org/images/" + Directory + "/" + Image; - public virtual string PostUrl + public override string PostUrl => "https://safebooru.org/index.php?page=post&s=view&id=" + ID; } }