Skip to content

Commit 4a9e6f9

Browse files
authored
Merge pull request #40 from Shiroechi/dev
v2.2.3
2 parents a5f1421 + 16c6e6e commit 4a9e6f9

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

Booru/Booru.cs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public abstract class Booru
8686
/// </summary>
8787
protected bool _Authentication;
8888

89+
/// <summary>
90+
/// Default user agent value.
91+
/// </summary>
92+
protected string _DefaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36";
93+
8994
#endregion Member
9095

9196
#region Constructor & Destructor
@@ -680,10 +685,10 @@ protected byte CheckPostLimit(byte postLimit)
680685
/// Add http user agent if not exist.
681686
/// </summary>
682687
/// <remarks>
683-
/// by default using browser user agent.
688+
/// by default using google chrome browser user agent.
684689
/// </remarks>
685690
/// <param name="userAgent">
686-
/// User Agrnt value.
691+
/// User Agent value.
687692
/// </param>
688693
public void AddHttpUserAgent(string userAgent = "")
689694
{
@@ -692,20 +697,23 @@ public void AddHttpUserAgent(string userAgent = "")
692697
return;
693698
}
694699

700+
if (userAgent == null || userAgent.Trim() == "")
701+
{
702+
userAgent = this._DefaultUserAgent;
703+
}
704+
695705
if (this._HttpClient.DefaultRequestHeaders.UserAgent.Count == 0)
696706
{
697-
if (userAgent == null | userAgent.Trim() == "")
698-
{
699-
this.HttpClient.DefaultRequestHeaders.Add(
707+
this.HttpClient.DefaultRequestHeaders.Add(
700708
"User-Agent",
701-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36");
702-
}
703-
else
704-
{
705-
this.HttpClient.DefaultRequestHeaders.Add(
709+
userAgent);
710+
}
711+
else
712+
{
713+
this._HttpClient.DefaultRequestHeaders.UserAgent.Clear();
714+
this.HttpClient.DefaultRequestHeaders.Add(
706715
"User-Agent",
707716
userAgent);
708-
}
709717
}
710718
}
711719

@@ -732,11 +740,17 @@ public virtual bool IsOnline()
732740
}
733741

734742
/// <summary>
735-
/// Login with booru username and password.
743+
/// Login with booru username and password.
736744
/// </summary>
737-
/// <param name="username">Your username.</param>
738-
/// <param name="password">Your password.</param>
739-
/// <returns></returns>
745+
/// <param name="username">
746+
/// Your username.
747+
/// </param>
748+
/// <param name="password">
749+
/// Your password.
750+
/// </param>
751+
/// <returns>
752+
///
753+
/// </returns>
740754
protected bool Authenticate(string username, string password)
741755
{
742756
throw new NotImplementedException($"Method { nameof(Authenticate) } is not implemented yet.");

BooruDex.csproj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
5+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
66
<Authors>Shiroechi</Authors>
77
<PackageProjectUrl>https://github.com/Shiroechi/BooruDex</PackageProjectUrl>
88
<RepositoryUrl>https://github.com/Shiroechi/BooruDex</RepositoryUrl>
99
<RepositoryType>git</RepositoryType>
1010
<PackageTags>Imageboard Image Booru Danbooru Gelbooru Gelbooru02 Moebooru Yandere Konachan Safebooru Lolibooru Rule34 Behoimi Realbooru</PackageTags>
1111
<NeutralLanguage>en</NeutralLanguage>
1212
<Description>Library to access the booru website using public API. This library only support GET method, it means only listing and searching only.</Description>
13-
<PackageReleaseNotes>- Update dependencies
14-
- Update User Agent</PackageReleaseNotes>
15-
<Version>2.2.1</Version>
13+
<PackageReleaseNotes>- Update depedencies</PackageReleaseNotes>
14+
<Version>2.2.3</Version>
1615
<AssemblyName>BooruDex</AssemblyName>
1716
<RootNamespace>BooruDex</RootNamespace>
1817
<PackageLicenseFile>LICENSE</PackageLicenseFile>
@@ -23,7 +22,7 @@
2322

2423
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2524
<Optimize>true</Optimize>
26-
<DocumentationFile>D:\Project\C#\API\BooruDex\BooruDex.xml</DocumentationFile>
25+
<DocumentationFile></DocumentationFile>
2726
</PropertyGroup>
2827

2928
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -34,8 +33,8 @@
3433
</PropertyGroup>
3534

3635
<ItemGroup>
37-
<PackageReference Include="Litdex.Security.RNG" Version="2.4.0" />
38-
<PackageReference Include="System.Text.Json" Version="5.0.1" />
36+
<PackageReference Include="Litdex.Security.RNG" Version="2.5.1" />
37+
<PackageReference Include="System.Text.Json" Version="5.0.2" />
3938
</ItemGroup>
4039

4140
<ItemGroup>

BooruDex.xml

Lines changed: 17 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)