Make SafebooruImage inherit BooruImage

master
exsersewo 5 years ago
parent f8f40f2d42
commit 6c60cf9e43
  1. 2
      Booru.Net.Tests/Program.cs
  2. 11
      Booru.Net/Models/Boards/BooruImage.cs
  3. 18
      Booru.Net/Models/Boards/SafebooruImage.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();
}

@ -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;
}

@ -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<string> Tags { get { return Ptags.Split(' '); } }
public IReadOnlyList<string> 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;
}
}

Loading…
Cancel
Save