@@ -45,20 +45,18 @@ public sealed class EHentaiEngine : WebSearchEngine, IConfig, INotifyPropertyCha
4545 CookieContainer = new ( ) { } ,
4646
4747 } ;
48-
48+
4949 public override Url BaseUrl => IsLoggedIn ? ExHentaiBase : EHentaiBase ;
5050
5151 private Url LookupUrl => IsLoggedIn ? ExHentaiLookup : EHentaiLookup ;
5252
53- public CookieCollection Cookies { get ; }
54-
5553 public override SearchEngineOptions EngineOption => SearchEngineOptions . EHentai ;
5654
5755 protected override string NodesSelector => Serialization . S_EHentai ;
5856
5957 public bool IsLoggedIn { get ; private set ; }
6058
61- #region
59+ #region
6260
6361 private static readonly Url EHentaiIndex = "https://forums.e-hentai.org/index.php" ;
6462 public static readonly Url EHentaiBase = "https://e-hentai.org/" ;
@@ -74,7 +72,6 @@ static EHentaiEngine() { }
7472 public EHentaiEngine ( ) : base ( EHentaiBase )
7573 {
7674 m_client = new HttpClient ( m_clientHandler ) ;
77- Cookies = new ( ) ;
7875 IsLoggedIn = false ;
7976 }
8077
@@ -136,6 +133,15 @@ public async Task<bool> LoginAsync(bool useEx = false)
136133 return x . Host . Contains ( HOST_EX ) ;
137134 } ) ;
138135
136+ /*var fcc = CookiesManager.Cookies.Where(x =>
137+ {
138+ if (!useEx) {
139+ return x.Domain.Contains(HOST_EH);
140+ }
141+
142+ return x.Domain.Contains(HOST_EX);
143+ });*/
144+
139145 /*var content = new MultipartFormDataContent()
140146 {
141147 { new StringContent("1"), "CookieDate" },
@@ -158,10 +164,12 @@ public async Task<bool> LoginAsync(bool useEx = false)
158164 .WithCookies(out var cj)
159165 .PostAsync(content);*/
160166
161- foreach ( var fc in fcc ) {
162- Cookies . Add ( fc . AsCookie ( ) ) ;
167+ foreach ( var cookie in fcc ) {
168+ m_clientHandler . CookieContainer . Add ( cookie . AsCookie ( ) ) ;
163169 }
164170
171+ // foreach (var fc in fcc) { }
172+
165173 var res2 = await GetSessionAsync ( ) ;
166174
167175 return IsLoggedIn = res2 . ResponseMessage . IsSuccessStatusCode ;
@@ -211,8 +219,8 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
211219 // data.Add(new FileContent(f.FullName), "sfile", "a.jpg");
212220
213221 //todo
214- m_clientHandler . CookieContainer . Add ( Cookies ) ;
215-
222+ /* m_clientHandler.CookieContainer.Add(Cookies);
223+
216224 Debug.WriteLine($"{LookupUrl}", nameof(GetDocumentAsync));
217225
218226 var req = new HttpRequestMessage(HttpMethod.Post, LookupUrl)
@@ -228,7 +236,23 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
228236
229237 var content = await res.Content.ReadAsStringAsync(token);
230238
231- sr . RawUrl = res . RequestMessage . RequestUri ;
239+ sr.RawUrl = res.RequestMessage.RequestUri;*/
240+
241+ var req = new FlurlRequest ( LookupUrl )
242+ {
243+ Content = data ,
244+ Headers =
245+ {
246+ { "User-Agent" , HttpUtilities . UserAgent }
247+ } ,
248+ Verb = HttpMethod . Post ,
249+
250+ } ;
251+
252+ var res = await Client . SendAsync ( req , cancellationToken : token ) ;
253+ var content = await res . GetStringAsync ( ) ;
254+
255+ sr . RawUrl = res . ResponseMessage . RequestMessage . RequestUri ;
232256
233257 if ( content . Contains ( "Please wait a bit longer between each file search." ) ) {
234258 Debug . WriteLine ( $ "cooldown", Name ) ;
@@ -242,7 +266,7 @@ protected override async Task<IDocument> GetDocumentAsync(SearchResult sr, Searc
242266
243267 private Task < IFlurlResponse > GetSessionAsync ( )
244268 {
245- return ExHentaiBase . WithCookies ( Cookies )
269+ return ExHentaiBase . WithCookies ( m_clientHandler . CookieContainer )
246270 . WithHeaders ( new
247271 {
248272 User_Agent = HttpUtilities . UserAgent
@@ -293,7 +317,7 @@ public override void Dispose()
293317 {
294318 m_client . Dispose ( ) ;
295319 m_clientHandler . Dispose ( ) ;
296- Cookies . Clear ( ) ;
320+
297321 IsLoggedIn = false ;
298322 }
299323
0 commit comments