@@ -62,8 +62,7 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
6262
6363 IDocument document = null ;
6464
65- try
66- {
65+ try {
6766 var response = await Client . Request ( Endpoint )
6867 . OnError ( r =>
6968 {
@@ -96,26 +95,7 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
9695 return ;
9796 } , cancellationToken : token ) ;
9897
99- /*
100- var response = await Client.Request(URL_QUERY)
101- .OnError(r =>
102- {
103- // Debug.WriteLine($"{r.Exception}", Name);
104- // r.ExceptionHandled = true;
105- Logger.LogError(r.Exception, $"{Name}");
106- Debugger.Break();
107- #if !DEBUG
108- r.ExceptionHandled = true;
109- #endif
110- }
111- )
112- .SetQueryParam("url", query.Upload)
113- .WithTimeout(Timeout)
114- .GetAsync(cancellationToken: ct);
115- */
116-
117- if ( response != null )
118- {
98+ if ( response != null ) {
11999 var s = await response . GetStringAsync ( ) . ConfigureAwait ( false ) ;
120100
121101 var parser = new HtmlParser ( ) ;
@@ -124,18 +104,17 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
124104 // goto ret;
125105
126106 }
127- else
128- {
107+ else {
129108 // Debugger.Break();
130109 }
131110
132111 response ? . Dispose ( ) ;
133112
134113 goto ret ;
135114 }
136- catch ( Exception e )
137- {
115+ catch ( Exception e ) {
138116 Debug . WriteLine ( $ "{ e . Message } !") ;
117+ Logger . LogError ( e , "{Func}: {Name}" , nameof ( GetDocumentAsync ) , Name ) ;
139118 goto ret ;
140119 }
141120
@@ -166,8 +145,7 @@ protected override ValueTask<IEnumerable<IqdbItem>> GetItems(IEnumerable<IHtmlCo
166145 {
167146 var buf = new List < IqdbItem > ( ) ;
168147
169- foreach ( var c in source )
170- {
148+ foreach ( var c in source ) {
171149 var iq = IqdbItem . ParseResultItem ( c , r ) ;
172150 buf . Add ( iq ) ;
173151 }
@@ -182,22 +160,19 @@ protected override bool Validate(IDocument doc, SearchResult sr)
182160 if ( ! b )
183161 goto ret ;
184162
185- if ( doc is { Body : not null } bod )
186- {
163+ if ( doc is { Body : not null } bod ) {
187164
188- if ( doc . GetElementsByClassName ( "err" ) is { Length : > 0 } err )
189- {
165+ if ( doc . GetElementsByClassName ( "err" ) is { Length : > 0 } err ) {
190166 var fe = err [ 0 ] ;
191167 sr . Status = SearchResultStatus . UnknownError ;
192168 sr . ErrorMessage = $ "{ fe . TextContent } ";
193169 b = false ;
194170 goto ret ;
195171 }
196172
197- if ( bod . QuerySelector ( Serialization . S_Iqdb_NoMatches ) != null )
198- {
173+ if ( bod . QuerySelector ( Serialization . S_Iqdb_NoMatches ) != null ) {
199174 sr . Flags |= SearchResultFlags . NoResults ;
200- b = false ;
175+ b = false ;
201176 }
202177 }
203178
@@ -237,24 +212,21 @@ public static IqdbItem ParseResultItem(IHtmlCollection<IElement> tr, SearchResul
237212
238213 //img.ChildNodes[0].ChildNodes[0].TryGetAttribute("href")
239214
240- try
241- {
215+ try {
242216 //url = src.FirstChild.ChildNodes[2].ChildNodes[0].TryGetAttribute("href");
243217
244218 url = img . ChildNodes [ 0 ] . ChildNodes [ 0 ] . TryGetAttribute ( Serialization . Atr_href ) ;
245219
246220 // Links must begin with http:// in order to work with "start"
247221
248222 }
249- catch
250- {
223+ catch {
251224 // ignored
252225 }
253226
254227 int w = 0 , h = 0 ;
255228
256- if ( tr . Length >= 4 )
257- {
229+ if ( tr . Length >= 4 ) {
258230 var res = tr [ 3 ] ;
259231
260232 string [ ] wh = res . TextContent . Split ( Strings . Constants . MUL_SIGN ) ;
@@ -270,35 +242,30 @@ public static IqdbItem ParseResultItem(IHtmlCollection<IElement> tr, SearchResul
270242
271243 double ? sim ;
272244
273- if ( tr . Length >= 5 )
274- {
245+ if ( tr . Length >= 5 ) {
275246 var simNode = tr [ 4 ] ;
276247 string simStr = simNode . TextContent . Split ( '%' ) [ 0 ] ;
277248 sim = double . Parse ( simStr ) ;
278249 sim = Math . Round ( sim . Value , 2 ) ;
279250 }
280- else
281- {
251+ else {
282252 sim = null ;
283253 }
284254
285255 Url uri ;
286256
287- if ( url != null )
288- {
257+ if ( url != null ) {
289258 // Url u = url;
290259
291- if ( url . StartsWith ( "//" ) )
292- {
260+ if ( url . StartsWith ( "//" ) ) {
293261 url = "https:" + url ;
294262
295263 // url = url[2..];
296264 }
297265
298266 uri = url ;
299267 }
300- else
301- {
268+ else {
302269 uri = null ;
303270 }
304271
0 commit comments