public EHentaiInfo(IConfiguration configuration, ILogger <EHentaiInfo> logger, ICache cache, ITagTranslationInfo tagTranslationInfo) { _configuration = configuration; _logger = logger; _tagTranslationInfo = tagTranslationInfo; if (!CheckCookie()) { return; } var cookieContainer = new CookieContainer(); cookieContainer.Add(new Uri("https://exhentai.org"), new Cookie("ipb_member_id", _configuration["ipb_member_id"], "/", "exhentai.org")); cookieContainer.Add(new Uri("https://exhentai.org"), new Cookie("ipb_pass_hash", _configuration["ipb_pass_hash"], "/", "exhentai.org")); cookieContainer.Add(new Uri("https://e-hentai.org"), new Cookie("ipb_member_id", _configuration["ipb_member_id"], "/", "e-hentai.org")); cookieContainer.Add(new Uri("https://e-hentai.org"), new Cookie("ipb_pass_hash", _configuration["ipb_pass_hash"], "/", "e-hentai.org")); var handler = new HttpClientHandler { CookieContainer = cookieContainer }; HttpClient = new HttpClient(handler); CachedHttpClient = new Cache <HttpClient>(HttpClient, cache); TitleRegex = new Regex(@"(?<=<h1 id=\""gj\"">).*?(?=</h1>)", RegexOptions.Compiled); TagRowRegex = new Regex(@"<tr><td class=""tc"">(?<name>.+?):<\/td>(?<content>.+?)<\/tr>", RegexOptions.Compiled); TagRegex = new Regex(@"<div id=""td_([\w\d]+:)?(?<tag>.+?)""", RegexOptions.Compiled); CoverRegex = new Regex(@"<div id=""gd1"">.*?url\((?<cover>.+?)\)", RegexOptions.Compiled); UrlRegex = new Regex(@"https?://e[x\-]hentai.org/g/(?<id>[\d\w]+?/[\d\w]+)", RegexOptions.Compiled); }
public NHentaiInfo(IConfiguration configuration, ILogger <EHentaiInfo> logger, ICache cache, ITagTranslationInfo tagTranslationInfo) { _configuration = configuration; _logger = logger; _tagTranslationInfo = tagTranslationInfo; HttpClient = new HttpClient(); CachedHttpClient = new Cache <HttpClient>(HttpClient, cache); TitleRegex = new Regex(@"(?<=<h2>).*?(?=</h2>)", RegexOptions.Compiled); UrlRegex = new Regex(@"https?://nhentai.net/g/(?<id>\d+)", RegexOptions.Compiled); CoverRegex = new Regex(@"(?<=<img.*data-src="").*?cover.*?(?="")", RegexOptions.Compiled); }