Skip to content

Commit

Permalink
Merge pull request #40 from Shiroechi/dev
Browse files Browse the repository at this point in the history
v2.2.3
  • Loading branch information
Shiroechi authored May 13, 2021
2 parents a5f1421 + 16c6e6e commit 4a9e6f9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
44 changes: 29 additions & 15 deletions Booru/Booru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public abstract class Booru
/// </summary>
protected bool _Authentication;

/// <summary>
/// Default user agent value.
/// </summary>
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";

#endregion Member

#region Constructor & Destructor
Expand Down Expand Up @@ -680,10 +685,10 @@ protected byte CheckPostLimit(byte postLimit)
/// Add http user agent if not exist.
/// </summary>
/// <remarks>
/// by default using browser user agent.
/// by default using google chrome browser user agent.
/// </remarks>
/// <param name="userAgent">
/// User Agrnt value.
/// User Agent value.
/// </param>
public void AddHttpUserAgent(string userAgent = "")
{
Expand All @@ -692,20 +697,23 @@ public void AddHttpUserAgent(string userAgent = "")
return;
}

if (userAgent == null || userAgent.Trim() == "")
{
userAgent = this._DefaultUserAgent;
}

if (this._HttpClient.DefaultRequestHeaders.UserAgent.Count == 0)
{
if (userAgent == null | userAgent.Trim() == "")
{
this.HttpClient.DefaultRequestHeaders.Add(
this.HttpClient.DefaultRequestHeaders.Add(
"User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36");
}
else
{
this.HttpClient.DefaultRequestHeaders.Add(
userAgent);
}
else
{
this._HttpClient.DefaultRequestHeaders.UserAgent.Clear();
this.HttpClient.DefaultRequestHeaders.Add(
"User-Agent",
userAgent);
}
}
}

Expand All @@ -732,11 +740,17 @@ public virtual bool IsOnline()
}

/// <summary>
/// Login with booru username and password.
/// Login with booru username and password.
/// </summary>
/// <param name="username">Your username.</param>
/// <param name="password">Your password.</param>
/// <returns></returns>
/// <param name="username">
/// Your username.
/// </param>
/// <param name="password">
/// Your password.
/// </param>
/// <returns>
///
/// </returns>
protected bool Authenticate(string username, string password)
{
throw new NotImplementedException($"Method { nameof(Authenticate) } is not implemented yet.");
Expand Down
13 changes: 6 additions & 7 deletions BooruDex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

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

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>true</Optimize>
<DocumentationFile>D:\Project\C#\API\BooruDex\BooruDex.xml</DocumentationFile>
<DocumentationFile></DocumentationFile>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="Litdex.Security.RNG" Version="2.4.0" />
<PackageReference Include="System.Text.Json" Version="5.0.1" />
<PackageReference Include="Litdex.Security.RNG" Version="2.5.1" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 17 additions & 6 deletions BooruDex.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a9e6f9

Please sign in to comment.