Make SafebooruImage inherit BooruImage
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Booru.Net.Tests
|
|||||||
{
|
{
|
||||||
var BooruClient = new BooruClient();
|
var BooruClient = new BooruClient();
|
||||||
|
|
||||||
var posts = await BooruClient.GetRealBooruImagesAsync();
|
var posts = await BooruClient.GetSafebooruImagesAsync();
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,22 +13,23 @@ namespace Booru.Net
|
|||||||
[JsonProperty("rating")]
|
[JsonProperty("rating")]
|
||||||
private string Prating { get; set; }
|
private string Prating { get; set; }
|
||||||
|
|
||||||
[JsonProperty("file_url")]
|
public virtual string ImageUrl { get; set; }
|
||||||
public string ImageUrl { get; set; }
|
|
||||||
|
public virtual string PostUrl { get; set; }
|
||||||
|
|
||||||
public Rating Rating
|
public Rating Rating
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(Prating == "s")
|
if(Prating.ToLowerInvariant().StartsWith("s"))
|
||||||
{
|
{
|
||||||
return Rating.Safe;
|
return Rating.Safe;
|
||||||
}
|
}
|
||||||
if(Prating == "q")
|
if(Prating.ToLowerInvariant().StartsWith("q"))
|
||||||
{
|
{
|
||||||
return Rating.Questionable;
|
return Rating.Questionable;
|
||||||
}
|
}
|
||||||
if(Prating == "e")
|
if(Prating.ToLowerInvariant().StartsWith("e"))
|
||||||
{
|
{
|
||||||
return Rating.Explicit;
|
return Rating.Explicit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace Booru.Net
|
namespace Booru.Net
|
||||||
{
|
{
|
||||||
public class SafebooruImage
|
public class SafebooruImage : BooruImage
|
||||||
{
|
{
|
||||||
[JsonProperty("directory")]
|
[JsonProperty("directory")]
|
||||||
public string Directory { get; set; }
|
public string Directory { get; set; }
|
||||||
@@ -14,9 +14,6 @@ namespace Booru.Net
|
|||||||
[JsonProperty("height")]
|
[JsonProperty("height")]
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
|
||||||
[JsonProperty("id")]
|
|
||||||
public int ID { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("image")]
|
[JsonProperty("image")]
|
||||||
public string Image { get; set; }
|
public string Image { get; set; }
|
||||||
|
|
||||||
@@ -29,9 +26,6 @@ namespace Booru.Net
|
|||||||
[JsonProperty("parent_id")]
|
[JsonProperty("parent_id")]
|
||||||
public int? ParentID { get; set; }
|
public int? ParentID { get; set; }
|
||||||
|
|
||||||
[JsonProperty("rating")]
|
|
||||||
public Rating Rating { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("sample")]
|
[JsonProperty("sample")]
|
||||||
public bool Sample { get; set; }
|
public bool Sample { get; set; }
|
||||||
|
|
||||||
@@ -41,21 +35,19 @@ namespace Booru.Net
|
|||||||
[JsonProperty("sample_width")]
|
[JsonProperty("sample_width")]
|
||||||
public int SampleWidth { get; set; }
|
public int SampleWidth { get; set; }
|
||||||
|
|
||||||
[JsonProperty("score")]
|
|
||||||
public int? Score { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("tags")]
|
[JsonProperty("tags")]
|
||||||
private string Ptags { get; set; }
|
private string Ptags { get; set; }
|
||||||
|
|
||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public int Width { get; set; }
|
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;
|
=> "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;
|
=> "https://safebooru.org/index.php?page=post&s=view&id=" + ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user