Skip to content

Commit

Permalink
flaresolverr support
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyFart committed Dec 7, 2024
1 parent 87b37e7 commit 16ff9d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Core/Configs/BookGetterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Core.Extensions;
using Core.Misc.TempFolder;
using FlareSolverrSharp;
using Microsoft.Extensions.Logging;

namespace Core.Configs;
Expand Down Expand Up @@ -97,7 +98,20 @@ private static HttpClient GetClient(Options options, CookieContainer container,
handler.UseProxy = true;
}

if (!string.IsNullOrWhiteSpace(options.Flare)) {
var chandler = new ClearanceHandler(options.Flare) {
MaxTimeout = options.Timeout,
InnerHandler = handler
};

var cclient = new HttpClient(chandler);
cclient.Timeout = TimeSpan.FromSeconds(options.Timeout);

return cclient;
}

var client = new HttpClient(handler);

client.Timeout = TimeSpan.FromSeconds(options.Timeout);

return client;
Expand Down
3 changes: 3 additions & 0 deletions Core/Configs/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public Options(IEnumerable<string> url) {

[Option("proxy", Required = false, HelpText = "Прокси в формате <host>:<port>")]
public string Proxy { get; set; }

[Option("flare", Required = false, HelpText = "Адрес flaresolverr")]
public string Flare { get; set; }

[Option('s', "save", Required = false, HelpText = "Директория для сохранения книги")]
public string SavePath { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.1.2" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="FlareSolverrSharp" Version="3.0.7" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
<PackageReference Include="HtmlAgilityPack.CssSelectors.NetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion Core/Logic/Getters/MangaMammyGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override async Task<Book> Get(Uri url) {
Chapters = await FillChapters(doc, url),
Title = doc.GetTextBySelector("h1"),
Author = GetAuthor(doc, url),
Annotation = doc.QuerySelector("div.manga-excerpt").InnerHtml
Annotation = doc.QuerySelector("div.manga-excerpt")?.InnerHtml
};

return book;
Expand Down

0 comments on commit 16ff9d6

Please sign in to comment.