Add Tests, Add UserAgent, Upgrade Protocol Support to HTTP1.1 & remove whitespace. Plus VerBump
This commit is contained in:
12
Booru.Net.Tests/Booru.Net.Tests.csproj
Normal file
12
Booru.Net.Tests/Booru.Net.Tests.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Booru.Net\Booru.Net.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
20
Booru.Net.Tests/Program.cs
Normal file
20
Booru.Net.Tests/Program.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
namespace Booru.Net.Tests
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args) => StartAsync().GetAwaiter().GetResult();
|
||||
|
||||
|
||||
static async Task StartAsync()
|
||||
{
|
||||
var BooruClient = new BooruClient();
|
||||
|
||||
var posts = await BooruClient.GetE621ImagesAsync("nintendo");
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27703.2026
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booru.Net", "Booru.Net\Booru.Net.csproj", "{BC612FDE-FC2D-42D8-AD7F-988874B6A839}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Booru.Net", "Booru.Net\Booru.Net.csproj", "{BC612FDE-FC2D-42D8-AD7F-988874B6A839}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booru.Net.Tests", "Booru.Net.Tests\Booru.Net.Tests.csproj", "{747B6EAC-E4EB-4882-BDEB-5DEF9A3CA3E3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{BC612FDE-FC2D-42D8-AD7F-988874B6A839}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BC612FDE-FC2D-42D8-AD7F-988874B6A839}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BC612FDE-FC2D-42D8-AD7F-988874B6A839}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{747B6EAC-E4EB-4882-BDEB-5DEF9A3CA3E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{747B6EAC-E4EB-4882-BDEB-5DEF9A3CA3E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{747B6EAC-E4EB-4882-BDEB-5DEF9A3CA3E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{747B6EAC-E4EB-4882-BDEB-5DEF9A3CA3E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -23,6 +23,7 @@ Yande.re</Description>
|
||||
<PackageTags>booru imageboard api wrapper</PackageTags>
|
||||
<PackageLicenseUrl>https://github.com/exsersewo/Booru.Net/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<Version>1.0.0.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -121,5 +121,22 @@ namespace Booru.Net
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<SafebooruImage>> GetSafebooruImagesAsync(params string[] tags)
|
||||
=> await GetSafebooruImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<Rule34Image>> GetRule34ImagesAsync(params string[] tags)
|
||||
=> await GetRule34ImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<RealbooruImage>> GetRealBooruImagesAsync(params string[] tags)
|
||||
=> await GetRealBooruImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<DanbooruImage>> GetDanbooruImagesAsync(params string[] tags)
|
||||
=> await GetDanbooruImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<GelbooruImage>> GetGelbooruImagesAsync(params string[] tags)
|
||||
=> await GetGelbooruImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<KonaChanImage>> GetKonaChanImagesAsync(params string[] tags)
|
||||
=> await GetKonaChanImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<E621Image>> GetE621ImagesAsync(params string[] tags)
|
||||
=> await GetE621ImagesAsync(tags.AsEnumerable());
|
||||
public async Task<IReadOnlyList<YandereImage>> GetYandereImagesAsync(params string[] tags)
|
||||
=> await GetYandereImagesAsync(tags.AsEnumerable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
{
|
||||
public class E621Image : GelbooruImage
|
||||
{
|
||||
public override string PostUrl { get { return "https://e621.net/post/show/" + ID; } }
|
||||
public override string PostUrl { get { return "https://e621.net/post/show/" + ID; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ namespace Booru.Net
|
||||
{
|
||||
[JsonProperty("directory")]
|
||||
public string Directory { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("tags")]
|
||||
private string Ptags { get; set; }
|
||||
|
||||
|
||||
public IReadOnlyList<string> Tags { get { return Ptags.Split(' '); } }
|
||||
|
||||
|
||||
public virtual string PostUrl { get { return "https://gelbooru.com/index.php?page=post&s=view&id=" + ID; } }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Booru.Net
|
||||
{
|
||||
@@ -9,12 +10,14 @@ namespace Booru.Net
|
||||
{
|
||||
public static HttpWebRequest CreateWebRequest(Uri uri)
|
||||
{
|
||||
var cli = (HttpWebRequest)System.Net.WebRequest.Create(uri);
|
||||
var ver = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
cli.AllowAutoRedirect = true;
|
||||
var cli = (HttpWebRequest)System.Net.WebRequest.Create(uri);
|
||||
cli.UserAgent = "Mozilla/5.0 Booru.Net/{VERSION} +https://github.com/exsersewo/Booru.Net".Replace("{VERSION}", $"{ver.Major}.{ver.MajorRevision}.{ver.Minor}.{ver.MinorRevision}");
|
||||
cli.AllowAutoRedirect = true;
|
||||
cli.KeepAlive = false;
|
||||
cli.Timeout = 20000;
|
||||
cli.ProtocolVersion = HttpVersion.Version10;
|
||||
cli.ProtocolVersion = HttpVersion.Version11;
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user