Skip to content

Commit 7fba08c

Browse files
committed
...
1 parent 07d2d09 commit 7fba08c

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

SmartImage.Lib/Engines/Impl/Search/IqdbEngine.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Flurl.Http;
1313
using Kantan.Net.Utilities;
1414
using Kantan.Text;
15+
using Microsoft.Extensions.Logging;
1516
using SmartImage.Lib.Results;
1617
using SmartImage.Lib.Utilities;
1718

@@ -34,7 +35,7 @@ protected IqdbEngine(string b, string e) : base(b, e)
3435
{
3536
MaxSize = MAX_FILE_SIZE; // NOTE: assuming IQDB uses kilobytes instead of kibibytes
3637

37-
// Timeout = TimeSpan.FromSeconds(10);
38+
Timeout = TimeSpan.FromSeconds(30);
3839
}
3940

4041
private const int MAX_FILE_SIZE = 8_388_608;
@@ -54,7 +55,7 @@ private async Task<IDocument> GetDocumentAsync(SearchQuery query, CancellationTo
5455
IDocument document = null;
5556

5657
try {
57-
var response = await Client.Request(EndpointUrl)
58+
/*var response = await Client.Request(EndpointUrl)
5859
.OnError(r =>
5960
{
6061
Debug.WriteLine($"{r.Exception}", Name);
@@ -73,8 +74,22 @@ private async Task<IDocument> GetDocumentAsync(SearchQuery query, CancellationTo
7374
}
7475
7576
return;
76-
}, cancellationToken: ct);
77-
77+
}, cancellationToken: ct);*/
78+
var response = await Client.Request(URL_QUERY)
79+
.OnError(r =>
80+
{
81+
// Debug.WriteLine($"{r.Exception}", Name);
82+
// r.ExceptionHandled = true;
83+
Logger.LogError(r.Exception, $"{Name}");
84+
Debugger.Break();
85+
#if !DEBUG
86+
r.ExceptionHandled = true;
87+
#endif
88+
}
89+
)
90+
.SetQueryParam("url", query.Upload)
91+
.WithTimeout(Timeout)
92+
.GetAsync(cancellationToken: ct);
7893
if (response != null) {
7994
var s = await response.GetStringAsync();
8095

SmartImage.Lib/Engines/Impl/Search/SauceNaoEngine.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,13 @@ private static void Parse(INode result, SearchResult sr)
406406

407407
Url url = urls.FirstOrDefault();
408408

409-
var site = url.Host.Replace("www", "");
410-
site = site.Split('.', StringSplitOptions.RemoveEmptyEntries)[0];
409+
string site = null;
411410

411+
if (Url.IsValid(url)) {
412+
site = url.Host.Replace("www", "");
413+
site = site.Split('.', StringSplitOptions.RemoveEmptyEntries)[0];
414+
415+
}
412416

413417
var sndr = new SearchResultItem(sr)
414418
{

0 commit comments

Comments
 (0)