33
44global using R1 = SmartImage . Lib . Resources ;
55global using Url = Flurl . Url ;
6+ using System . Collections . Frozen ;
67using System . Diagnostics ;
78using System . Net . Http . Headers ;
89using System . Runtime . CompilerServices ;
1213using Microsoft . Extensions . Logging ;
1314using Microsoft . Net . Http . Headers ;
1415using SmartImage . Lib . Clients ;
16+ using SmartImage . Lib . Cookies ;
1517using SmartImage . Lib . Engines . Impl . Search ;
1618using SmartImage . Lib . Engines . Impl . Search . Other ;
1719using SmartImage . Lib . Results ;
@@ -24,14 +26,7 @@ namespace SmartImage.Lib.Engines;
2426
2527#nullable enable
2628
27- public interface ISearchQueryVerifiable
28- {
29-
30- public ValueTask < bool > VerifyQueryAsync ( SearchQuery query ) ;
31-
32- }
33-
34- public abstract class BaseSearchEngine : IDisposable , IEquatable < BaseSearchEngine >
29+ public abstract class BaseSearchEngine : IDisposable , IEquatable < BaseSearchEngine > , ISearchConfigReceiver
3530{
3631
3732 static BaseSearchEngine ( )
@@ -90,62 +85,6 @@ protected BaseSearchEngine([NN] Url baseUrl)
9085
9186 protected static FlurlClient Client { get ; }
9287
93- public static IEnumerable < BaseSearchEngine > GetSelectedEngines ( SearchEngineOptions options )
94- {
95- /*return BaseSearchEngine.All.Where(e =>
96- {
97- return e.EngineOption != default && options.HasFlag(e.EngineOption);
98- })
99- .ToArray();*/
100-
101- if ( options . HasFlag ( SearchEngineOptions . SauceNao ) )
102- yield return new SauceNaoEngine ( ) ;
103-
104- if ( options . HasFlag ( SearchEngineOptions . ImgOps ) )
105- yield return new ImgOpsEngine ( ) ;
106-
107- if ( options . HasFlag ( SearchEngineOptions . GoogleImages ) )
108- yield return new GoogleImagesEngine ( ) ;
109-
110- if ( options . HasFlag ( SearchEngineOptions . TinEye ) )
111- yield return new TinEyeEngine ( ) ;
112-
113- if ( options . HasFlag ( SearchEngineOptions . Iqdb ) )
114- yield return new IqdbEngine ( ) ;
115-
116- if ( options . HasFlag ( SearchEngineOptions . TraceMoe ) )
117- yield return new TraceMoeEngine ( ) ;
118-
119- if ( options . HasFlag ( SearchEngineOptions . KarmaDecay ) )
120- yield return new KarmaDecayEngine ( ) ;
121-
122- if ( options . HasFlag ( SearchEngineOptions . Yandex ) )
123- yield return new YandexEngine ( ) ;
124-
125- if ( options . HasFlag ( SearchEngineOptions . Bing ) )
126- yield return new BingEngine ( ) ;
127-
128- if ( options . HasFlag ( SearchEngineOptions . Ascii2D ) )
129- yield return new Ascii2DEngine ( ) ;
130-
131- if ( options . HasFlag ( SearchEngineOptions . RepostSleuth ) )
132- yield return new RepostSleuthEngine ( ) ;
133-
134- if ( options . HasFlag ( SearchEngineOptions . EHentai ) )
135- yield return new EHentaiEngine ( ) ;
136-
137- if ( options . HasFlag ( SearchEngineOptions . ArchiveMoe ) )
138- yield return new ArchiveMoeEngine ( ) ;
139-
140- if ( options . HasFlag ( SearchEngineOptions . Iqdb3D ) )
141- yield return new Iqdb3DEngine ( ) ;
142-
143- if ( options . HasFlag ( SearchEngineOptions . Fluffle ) )
144- yield return new FluffleEngine ( ) ;
145-
146- if ( options . HasFlag ( SearchEngineOptions . GoogleLens ) )
147- yield return new GoogleLensEngine ( ) ;
148- }
14988
15089 /*public Task<SearchResult> GetTaskAsync(SearchQuery query, CancellationToken token = default)
15190 {
@@ -209,6 +148,8 @@ public override string ToString()
209148 return $ "{ Name } : { BaseUrl } { Timeout } ";
210149 }
211150
151+ public abstract ValueTask < bool > ApplyConfigAsync ( SearchConfig cfg , CancellationToken ct = default ) ;
152+
212153 // public abstract ValueTask ApplyConfigAsync(SearchConfig cfg, CancellationToken ct = default);
213154
214155 public override bool Equals ( object ? obj )
@@ -254,4 +195,62 @@ public bool Equals(BaseSearchEngine? other)
254195 public static bool operator != ( BaseSearchEngine ? left , BaseSearchEngine ? right )
255196 => ! Equals ( left , right ) ;
256197
198+
199+ public static IEnumerable < BaseSearchEngine > GetSelectedEngines ( SearchEngineOptions options )
200+ {
201+ /*return BaseSearchEngine.All.Where(e =>
202+ {
203+ return e.EngineOption != default && options.HasFlag(e.EngineOption);
204+ })
205+ .ToArray();*/
206+
207+ if ( options . HasFlag ( SearchEngineOptions . SauceNao ) )
208+ yield return new SauceNaoEngine ( ) ;
209+
210+ if ( options . HasFlag ( SearchEngineOptions . ImgOps ) )
211+ yield return new ImgOpsEngine ( ) ;
212+
213+ if ( options . HasFlag ( SearchEngineOptions . GoogleImages ) )
214+ yield return new GoogleImagesEngine ( ) ;
215+
216+ if ( options . HasFlag ( SearchEngineOptions . TinEye ) )
217+ yield return new TinEyeEngine ( ) ;
218+
219+ if ( options . HasFlag ( SearchEngineOptions . Iqdb ) )
220+ yield return new IqdbEngine ( ) ;
221+
222+ if ( options . HasFlag ( SearchEngineOptions . TraceMoe ) )
223+ yield return new TraceMoeEngine ( ) ;
224+
225+ if ( options . HasFlag ( SearchEngineOptions . KarmaDecay ) )
226+ yield return new KarmaDecayEngine ( ) ;
227+
228+ if ( options . HasFlag ( SearchEngineOptions . Yandex ) )
229+ yield return new YandexEngine ( ) ;
230+
231+ if ( options . HasFlag ( SearchEngineOptions . Bing ) )
232+ yield return new BingEngine ( ) ;
233+
234+ if ( options . HasFlag ( SearchEngineOptions . Ascii2D ) )
235+ yield return new Ascii2DEngine ( ) ;
236+
237+ if ( options . HasFlag ( SearchEngineOptions . RepostSleuth ) )
238+ yield return new RepostSleuthEngine ( ) ;
239+
240+ if ( options . HasFlag ( SearchEngineOptions . EHentai ) )
241+ yield return new EHentaiEngine ( ) ;
242+
243+ if ( options . HasFlag ( SearchEngineOptions . ArchiveMoe ) )
244+ yield return new ArchiveMoeEngine ( ) ;
245+
246+ if ( options . HasFlag ( SearchEngineOptions . Iqdb3D ) )
247+ yield return new Iqdb3DEngine ( ) ;
248+
249+ if ( options . HasFlag ( SearchEngineOptions . Fluffle ) )
250+ yield return new FluffleEngine ( ) ;
251+
252+ if ( options . HasFlag ( SearchEngineOptions . GoogleLens ) )
253+ yield return new GoogleLensEngine ( ) ;
254+ }
255+
257256}
0 commit comments