VerBump, Booru Updates, Restructuring
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
<AssemblyVersion>2020.3.24.0</AssemblyVersion>
|
||||||
|
<FileVersion>2020.3.24.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Booru.Net.Tests
|
namespace Booru.Net.Tests
|
||||||
{
|
{
|
||||||
@@ -7,14 +9,60 @@ namespace Booru.Net.Tests
|
|||||||
{
|
{
|
||||||
static void Main(string[] args) => StartAsync().GetAwaiter().GetResult();
|
static void Main(string[] args) => StartAsync().GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
|
||||||
static async Task StartAsync()
|
static async Task StartAsync()
|
||||||
{
|
{
|
||||||
var BooruClient = new BooruClient();
|
for (int x = 0; x < 8; x++)
|
||||||
|
await DoClientTest(x).ConfigureAwait(false);
|
||||||
var posts = await BooruClient.GetSafebooruImagesAsync();
|
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async Task DoClientTest(int client)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IEnumerable<BooruImage> posts = null;
|
||||||
|
|
||||||
|
Console.WriteLine(client);
|
||||||
|
|
||||||
|
switch(client)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
posts = await new DanbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
var p = await new E621Client().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
Console.WriteLine(p.Posts.All(x => x != null));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
posts = await new GelbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
posts = await new KonaChanClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
posts = await new RealbooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
posts = await new Rule34Client().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
posts = await new SafebooruClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
posts = await new YandereClient().GetImagesAsync().ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (posts != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine(posts.All(x => x != null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.Write(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
<LangVersion>Latest</LangVersion>
|
||||||
<Authors>exsersewo</Authors>
|
<Authors>exsersewo</Authors>
|
||||||
<Company />
|
<Company />
|
||||||
<Description>An asynchronous Booru based ImageBoard wrapper.
|
<Description>An asynchronous Booru based ImageBoard wrapper.
|
||||||
@@ -16,19 +17,40 @@ Gelbooru,
|
|||||||
Konachan,
|
Konachan,
|
||||||
E621 and
|
E621 and
|
||||||
Yande.re</Description>
|
Yande.re</Description>
|
||||||
<PackageProjectUrl>https://github.com/systemexit/Booru.Net</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/exsersewo/Booru.Net</PackageProjectUrl>
|
||||||
<Copyright>exsersewo</Copyright>
|
<Copyright>exsersewo</Copyright>
|
||||||
<RepositoryUrl>https://github.com/systemexit/Booru.Net</RepositoryUrl>
|
<RepositoryUrl>https://github.com/exsersewo/Booru.Net</RepositoryUrl>
|
||||||
<RepositoryType>Library</RepositoryType>
|
<RepositoryType>Library</RepositoryType>
|
||||||
<PackageTags>booru imageboard api wrapper</PackageTags>
|
<PackageTags>booru imageboard api wrapper</PackageTags>
|
||||||
<PackageLicenseUrl></PackageLicenseUrl>
|
<PackageLicenseUrl></PackageLicenseUrl>
|
||||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||||
<Version>1.0.0.4</Version>
|
<Version>2.0.0.0</Version>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
|
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||||
|
<FileVersion>2.0.0.0</FileVersion>
|
||||||
|
<PackageReleaseNotes>⚠ This version is not compatible with 1.0.0.X code ⚠
|
||||||
|
|
||||||
|
Wrapper Restructuring & Seperate out each client from the container client
|
||||||
|
Fix bugs presented from some booru's updating</PackageReleaseNotes>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<ShouldCreateLogs>True</ShouldCreateLogs>
|
||||||
|
<AdvancedSettingsExpanded>False</AdvancedSettingsExpanded>
|
||||||
|
<UpdateAssemblyVersion>True</UpdateAssemblyVersion>
|
||||||
|
<UpdateAssemblyFileVersion>True</UpdateAssemblyFileVersion>
|
||||||
|
<UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
|
||||||
|
<AssemblyVersionSettings>None.None.None.None</AssemblyVersionSettings>
|
||||||
|
<UpdatePackageVersion>False</UpdatePackageVersion>
|
||||||
|
<AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
|
||||||
|
<InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>
|
||||||
|
<AssemblyFileVersionSettings>None.None.None.None</AssemblyFileVersionSettings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
<PackageReference Include="RestEase" Version="1.4.10" />
|
||||||
|
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,142 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Booru.Net
|
|
||||||
{
|
|
||||||
public class BooruClient
|
|
||||||
{
|
|
||||||
public async Task<IReadOnlyList<SafebooruImage>> GetSafebooruImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://safebooru.org/index.php?page=dapi&s=post&q=index&json=1&tags=" + tagstring));
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<SafebooruImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<Rule34Image>> GetRule34ImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&tags=" + tagstring));
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<Rule34Image>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<RealbooruImage>> GetRealBooruImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://realbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=" + tagstring));
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<RealbooruImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<DanbooruImage>> GetDanbooruImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://danbooru.donmai.us/posts.json?tags=" + tagstring));
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<DanbooruImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<GelbooruImage>> GetGelbooruImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=" + tagstring));
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<GelbooruImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<KonaChanImage>> GetKonaChanImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://konachan.com/post.json?tags=" + tagstring));
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<KonaChanImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<E621Image>> GetE621ImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://e621.net/post/index.json?tags=" + tagstring));
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<E621Image>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
public async Task<IReadOnlyList<YandereImage>> GetYandereImagesAsync(IEnumerable<string> tags)
|
|
||||||
{
|
|
||||||
IList<string> newtags = tags.ToList();
|
|
||||||
var tagstring = String.Join("%20", newtags);
|
|
||||||
|
|
||||||
var data = await WebRequest.ReturnStringAsync(new Uri("https://yande.re/post.json?tags=" + tagstring));
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
var posts = JsonConvert.DeserializeObject<List<YandereImage>>(data);
|
|
||||||
return posts;
|
|
||||||
}
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
45
Booru.Net/Clients/DanbooruClient.cs
Normal file
45
Booru.Net/Clients/DanbooruClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class DanbooruClient : IPostsBooruClient<DanbooruImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPostsBooruClient<DanbooruImage> _api;
|
||||||
|
|
||||||
|
public DanbooruClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://danbooru.donmai.us/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPostsBooruClient<DanbooruImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<DanbooruImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<DanbooruImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_api.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/E621Client.cs
Normal file
45
Booru.Net/Clients/E621Client.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class E621Client : IPostsWrappedBooruClient<WrappedPosts<E621Image>>, IDisposable
|
||||||
|
{
|
||||||
|
IPostsWrappedBooruClient<WrappedPosts<E621Image>> _api;
|
||||||
|
|
||||||
|
public E621Client()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://e621.net/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPostsWrappedBooruClient<WrappedPosts<E621Image>>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<WrappedPosts<E621Image>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<WrappedPosts<E621Image>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/GelbooruClient.cs
Normal file
45
Booru.Net/Clients/GelbooruClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class GelbooruClient : IPHPBooruClient<GelbooruImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPHPBooruClient<GelbooruImage> _api;
|
||||||
|
|
||||||
|
public GelbooruClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://gelbooru.com/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPHPBooruClient<GelbooruImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<GelbooruImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<GelbooruImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/KonaChanClient.cs
Normal file
45
Booru.Net/Clients/KonaChanClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class KonaChanClient : IPostBooruClient<KonaChanImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPostBooruClient<KonaChanImage> _api;
|
||||||
|
|
||||||
|
public KonaChanClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://konachan.com/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPostBooruClient<KonaChanImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<KonaChanImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<KonaChanImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/RealbooruClient.cs
Normal file
45
Booru.Net/Clients/RealbooruClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class RealbooruClient : IPHPBooruClient<RealbooruImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPHPBooruClient<RealbooruImage> _api;
|
||||||
|
|
||||||
|
public RealbooruClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://realbooru.com/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPHPBooruClient<RealbooruImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IReadOnlyList<RealbooruImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> await _api.GetImagesAsync(tags).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public async Task<IReadOnlyList<RealbooruImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> await _api.GetImagesAsync(tags).ConfigureAwait(false);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/Rule34Client.cs
Normal file
45
Booru.Net/Clients/Rule34Client.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class Rule34Client : IPHPBooruClient<Rule34Image>, IDisposable
|
||||||
|
{
|
||||||
|
IPHPBooruClient<Rule34Image> _api;
|
||||||
|
|
||||||
|
public Rule34Client()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://rule34.xxx/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPHPBooruClient<Rule34Image>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<Rule34Image>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<Rule34Image>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/SafeBooruClient.cs
Normal file
45
Booru.Net/Clients/SafeBooruClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class SafebooruClient : IPHPBooruClient<SafebooruImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPHPBooruClient<SafebooruImage> _api;
|
||||||
|
|
||||||
|
public SafebooruClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://safebooru.org/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPHPBooruClient<SafebooruImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<SafebooruImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<SafebooruImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
Booru.Net/Clients/YandereClient.cs
Normal file
45
Booru.Net/Clients/YandereClient.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class YandereClient : IPostBooruClient<YandereImage>, IDisposable
|
||||||
|
{
|
||||||
|
IPostBooruClient<YandereImage> _api;
|
||||||
|
|
||||||
|
public YandereClient()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient
|
||||||
|
{
|
||||||
|
BaseAddress = new Uri("https://yande.re/")
|
||||||
|
};
|
||||||
|
httpClient.DefaultRequestHeaders.Add("User-Agent", $"Booru.Net/v{Props.LibraryVersion} (https://github.com/exsersewo/Booru.Net)");
|
||||||
|
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
Formatting = Formatting.Indented,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
_api = new RestClient(httpClient)
|
||||||
|
{
|
||||||
|
JsonSerializerSettings = settings
|
||||||
|
}.For<IPostBooruClient<YandereImage>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<YandereImage>> GetImagesAsync(IEnumerable<string> tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<YandereImage>> GetImagesAsync(params string[] tags)
|
||||||
|
=> _api.GetImagesAsync(tags);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
Booru.Net/Converters/TagGroupConverter.cs
Normal file
53
Booru.Net/Converters/TagGroupConverter.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Booru.Net.Converters
|
||||||
|
{
|
||||||
|
public class TagGroupConverter : JsonConverter
|
||||||
|
{
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(List<Dictionary<string, List<string>>>);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var token = JToken.Load(reader);
|
||||||
|
|
||||||
|
List<Dictionary<string, List<string>>> container = new List<Dictionary<string, List<string>>>();
|
||||||
|
|
||||||
|
foreach(var el in token.Children<JObject>())
|
||||||
|
{
|
||||||
|
Dictionary<string, List<string>> att = new Dictionary<string, List<string>>();
|
||||||
|
foreach (JProperty prop in el.Properties())
|
||||||
|
{
|
||||||
|
List<string> children = new List<string>();
|
||||||
|
|
||||||
|
foreach(var child in prop.Value.Children())
|
||||||
|
{
|
||||||
|
children.Add(child.Value<string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
att.Add(prop.Name, children);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.Add(att);
|
||||||
|
}
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Booru.Net/Interfaces/IIndexBooruClient.cs
Normal file
13
Booru.Net/Interfaces/IIndexBooruClient.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public interface IIndexBooruClient<T> : IDisposable
|
||||||
|
{
|
||||||
|
[Get("index.json")]
|
||||||
|
public Task<IReadOnlyList<T>> GetImagesAsync([Query("tags")] IEnumerable<string> tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Booru.Net/Interfaces/IPHPBooruClient.cs
Normal file
13
Booru.Net/Interfaces/IPHPBooruClient.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public interface IPHPBooruClient<T> : IDisposable
|
||||||
|
{
|
||||||
|
[Get("index.php?page=dapi&s=post&q=index&json=1")]
|
||||||
|
public Task<IReadOnlyList<T>> GetImagesAsync([Query("tags")] IEnumerable<string> tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Booru.Net/Interfaces/IPostBooruClient.cs
Normal file
13
Booru.Net/Interfaces/IPostBooruClient.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public interface IPostBooruClient<T> : IDisposable
|
||||||
|
{
|
||||||
|
[Get("post.json")]
|
||||||
|
public Task<IReadOnlyList<T>> GetImagesAsync([Query("tags")] IEnumerable<string> tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Booru.Net/Interfaces/IPostsBooruClient.cs
Normal file
13
Booru.Net/Interfaces/IPostsBooruClient.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public interface IPostsBooruClient<T> : IDisposable
|
||||||
|
{
|
||||||
|
[Get("posts.json")]
|
||||||
|
public Task<IReadOnlyList<T>> GetImagesAsync([Query("tags")] IEnumerable<string> tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Booru.Net/Interfaces/IPostsWrappedBooruClient.cs
Normal file
13
Booru.Net/Interfaces/IPostsWrappedBooruClient.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using RestEase;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public interface IPostsWrappedBooruClient<T> : IDisposable
|
||||||
|
{
|
||||||
|
[Get("posts.json")]
|
||||||
|
public Task<T> GetImagesAsync([Query("tags")] IEnumerable<string> tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,23 @@
|
|||||||
namespace Booru.Net
|
using Booru.Net.Converters;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
{
|
{
|
||||||
public class E621Image : GelbooruImage
|
public class E621Image : BooruImage
|
||||||
{
|
{
|
||||||
|
[JsonProperty("score")]
|
||||||
|
public E621Score Score { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("directory")]
|
||||||
|
public string Directory { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("tags")]
|
||||||
|
[JsonConverter(typeof(TagGroupConverter))]
|
||||||
|
private List<Dictionary<string, List<string>>> PTags { get; set; }
|
||||||
|
|
||||||
|
public IReadOnlyList<Dictionary<string, List<string>>> Tags { get { return PTags.AsReadOnly(); } }
|
||||||
|
|
||||||
public override string PostUrl { get { return "https://e621.net/post/show/" + ID; } }
|
public override string PostUrl { get { return "https://e621.net/post/show/" + ID; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
Booru.Net/Models/Boards/E621Score.cs
Normal file
16
Booru.Net/Models/Boards/E621Score.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class E621Score
|
||||||
|
{
|
||||||
|
[JsonProperty("up")]
|
||||||
|
public int Up { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("down")]
|
||||||
|
private int Down { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("total")]
|
||||||
|
private int Total { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,9 @@ namespace Booru.Net
|
|||||||
{
|
{
|
||||||
public class GelbooruImage : BooruImage
|
public class GelbooruImage : BooruImage
|
||||||
{
|
{
|
||||||
|
[JsonProperty("score")]
|
||||||
|
public int? Score { get; set; }
|
||||||
|
|
||||||
[JsonProperty("directory")]
|
[JsonProperty("directory")]
|
||||||
public string Directory { get; set; }
|
public string Directory { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ namespace Booru.Net
|
|||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("score")]
|
||||||
|
public int? Score { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<string> Tags
|
public IReadOnlyList<string> Tags
|
||||||
=> Ptags.Split(' ');
|
=> Ptags.Split(' ');
|
||||||
|
|
||||||
|
|||||||
9
Booru.Net/Models/Boards/WrappedPosts.cs
Normal file
9
Booru.Net/Models/Boards/WrappedPosts.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
public class WrappedPosts<T>
|
||||||
|
{
|
||||||
|
public IReadOnlyList<T> Posts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,9 +7,6 @@ namespace Booru.Net
|
|||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
[JsonProperty("score")]
|
|
||||||
public int Score { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("rating")]
|
[JsonProperty("rating")]
|
||||||
private string Prating { get; set; }
|
private string Prating { get; set; }
|
||||||
|
|
||||||
13
Booru.Net/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
13
Booru.Net/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Any CPU</Platform>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<PublishDir>bin\Release\netstandard2.0\publish\</PublishDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
12
Booru.Net/Props.cs
Normal file
12
Booru.Net/Props.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Booru.Net
|
||||||
|
{
|
||||||
|
static class Props
|
||||||
|
{
|
||||||
|
public static string LibraryVersion { get; } =
|
||||||
|
typeof(SafebooruClient).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ??
|
||||||
|
typeof(SafebooruClient).GetTypeInfo().Assembly.GetName().Version.ToString(3) ??
|
||||||
|
"Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Booru.Net
|
|
||||||
{
|
|
||||||
class WebRequest
|
|
||||||
{
|
|
||||||
public static HttpWebRequest CreateWebRequest(Uri uri)
|
|
||||||
{
|
|
||||||
var ver = Assembly.GetExecutingAssembly().GetName().Version;
|
|
||||||
|
|
||||||
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.Version11;
|
|
||||||
|
|
||||||
return cli;
|
|
||||||
}
|
|
||||||
public static async Task<string> ReturnStringAsync(Uri url)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var client = CreateWebRequest(url);
|
|
||||||
|
|
||||||
var resp = (HttpWebResponse)(await client.GetResponseAsync());
|
|
||||||
if (resp.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
var reader = new StreamReader(resp.GetResponseStream());
|
|
||||||
var responce = await reader.ReadToEndAsync();
|
|
||||||
resp.Dispose();
|
|
||||||
client.Abort();
|
|
||||||
return responce;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
resp.Dispose();
|
|
||||||
client.Abort();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user