public async Task LoginAsync(CancellationToken token) { Net = new NetOperator(Settings, this); const string loginhost = "https://iapi.sankakucomplex.com"; var accountIndex = new Random().Next(0, _user.Length); var tempuser = _user[accountIndex]; var temppass = GetSankakuPwHash(_pass[accountIndex]); var tempappkey = GetSankakuAppkey(tempuser); var content = new FormUrlEncodedContent(new Dictionary <string, string> { { "login", tempuser }, { "password_hash", temppass }, { "appkey", tempappkey } }); Net.HttpClientHandler.UseCookies = true; var client = Net.Client; client.DefaultRequestHeaders.UserAgent.ParseAdd("SCChannelApp/2.3 (Android; idol)"); client.DefaultRequestHeaders.Referrer = new Uri(HomeUrl); client.DefaultRequestHeaders.Accept.ParseAdd("application/json"); var respose = await client.PostAsync(new Uri($"{loginhost}/user/authenticate.json"), content, token); if (respose.IsSuccessStatusCode) { IsUserLogin = true; } else { Ex.ShowMessage("idol登陆失败", null, Ex.MessagePos.Window); } _idolQuery = $"{loginhost}/post/index.json?login={tempuser}&password_hash={temppass}&appkey={tempappkey}&"; }
public async Task <MoeItems> GetRealPageImagesAsyncFromXml(SearchPara para, CancellationToken token) { var client = new NetOperator(Settings).Client; var query = GetPageQuery(para); var xmlRes = await client.GetAsync(query, token); var xmlStr = await xmlRes.Content.ReadAsStreamAsync(); var xml = XDocument.Load(xmlStr); var imageItems = new MoeItems(); if (xml.Root == null) { return(imageItems); } foreach (var post in xml.Root.Elements()) { token.ThrowIfCancellationRequested(); var img = new MoeItem(this, para); var tags = post.Attribute("tags")?.Value ?? ""; foreach (var tag in tags.Split(' ')) { if (!tag.IsEmpty()) { img.Tags.Add(tag.Trim()); } } img.Id = post.Attribute("id")?.Value.ToInt() ?? 0; img.Width = post.Attribute("width")?.Value.ToInt() ?? 0; img.Height = post.Attribute("height")?.Value.ToInt() ?? 0; img.Uploader = post.Attribute("author")?.Value; img.Source = post.Attribute("source")?.Value; img.IsExplicit = post.Attribute("rating")?.Value.ToLower() != "s"; img.DetailUrl = GetDetailPageUrl(img); img.Date = post.Attribute("created_at")?.Value.ToDateTime(); if (img.Date == null) { img.DateString = post.Attribute("created_at")?.Value; } img.Score = post.Attribute("score")?.Value.ToInt() ?? 0; img.Urls.Add(1, $"{UrlPre}{post.Attribute("preview_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(2, $"{UrlPre}{post.Attribute("sample_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(3, $"{UrlPre}{post.Attribute("jpeg_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(4, $"{UrlPre}{post.Attribute("file_url")?.Value}", img.DetailUrl); img.OriginString = $"{post}"; if (GetDetailTaskFunc != null) { img.GetDetailTaskFunc = async() => await GetDetailTaskFunc(img, para, token); } imageItems.Add(img); } var count = xml.Root.Attribute("count")?.Value.ToInt(); var offset = xml.Root.Attribute("offset")?.Value.ToInt(); Extend.ShowMessage($"共搜索到{count}张图片,当前第{offset+1}张,第{para.PageIndex}页,共{count / para.Count}页", null, Extend.MessagePos.InfoBar); return(imageItems); }
public void Login() { Net = new NetOperator(Settings, this); var cc = SiteSettings.GetCookieContainer(); if (cc != null) { Net.SetCookie(cc); } }
public override async Task <SearchedPage> GetRealPageAsync(SearchPara para, CancellationToken token) { var islogin = CheckIsLogin(); if (!islogin) { return(null); } if (Net == null) { Net = new NetOperator(Settings, this); Net.SetCookie(SiteSettings.GetCookieContainer()); } var net = Net.CloneWithCookie(); net.SetTimeOut(40); var imgs = new SearchedPage(); if (para.MirrorSite.IsDefault) { switch ((SearchTypeEnum)para.Lv2MenuIndex) { case SearchTypeEnum.TagOrNew: await SearchByNewOrTag(net, imgs, para, token); break; case SearchTypeEnum.Author: // 作者 member id word = "4338012"; // test if (para.Keyword.ToInt() == 0) { Ex.ShowMessage("参数错误,必须在关键词中指定画师 id(纯数字)", null, Ex.MessagePos.Window); } else { await SearchByAuthor(net, imgs, para.Keyword.Trim(), para, token); } break; case SearchTypeEnum.Rank: await SearchByRank(net, imgs, para, token); break; } } else { await SearchViaMirrorSite(net, imgs, para, token); } token.ThrowIfCancellationRequested(); return(imgs); }
public void Login() { Net = new NetOperator(Settings, this); var cc = SiteSettings.GetCookieContainer(); if (cc == null) { return; } Net.SetCookie(cc); IsUserLogin = true; }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { if (Net?.HttpClientHandler?.CookieContainer == null) { Net = new NetOperator(Settings, HomeUrl); Net.HttpClientHandler.AllowAutoRedirect = true; Net.HttpClientHandler.UseCookies = true; var cc = GetCookies(); if (cc == null) { Extend.ShowMessage("需要重新登录Pixiv站点", null, Extend.MessagePos.Window); Net = null; return(null); } Net.HttpClientHandler.CookieContainer = cc; Net.SetTimeOut(40); } else { Net = Net.CloneWithOldCookie(); } var imgs = new MoeItems(); switch ((SearchTypeEnum)para.SubMenuIndex) { case SearchTypeEnum.TagOrNew: await SearchByNewOrTag(imgs, para, token); break; case SearchTypeEnum.Author: // 作者 member id word = "4338012"; // test if (para.Keyword.ToInt() == 0) { Extend.ShowMessage("参数错误,必须在关键词中指定画师 id(纯数字)", null, Extend.MessagePos.Window); } else { await SearchByAuthor(imgs, para.Keyword.Trim(), para, token); } break; case SearchTypeEnum.Rank: await SearchByRank(imgs, para, token); break; } token.ThrowIfCancellationRequested(); return(imgs); }
public async void Login(CancellationToken token) { Net = new NetOperator(Settings, HomeUrl); var index = new Random().Next(0, _user.Length); var loginurl = "https://www.zerochan.net/login"; var response = await Net.Client.PostAsync(loginurl, new StringContent($"ref=%2F&login=Login&name={_user[index]}&password={_pass[index]}"), token); if (response.IsSuccessStatusCode) { IsLogon = true; } }
public override async Task <SearchedPage> GetRealPageAsync(SearchPara para, CancellationToken token) { //var homeUrl = para.IsShowExplicit ? HomeUrl : SafeHomeUrl; var homeUrl = HomeUrl; var pairs = new Pairs { { "page", $"{para.PageIndex}" }, { "limit", $"{para.CountLimit}" }, { "tags", para.Keyword.ToEncodedUrl() } }; var query = $"{homeUrl}/post.json{pairs.ToPairsString()}"; var net = new NetOperator(Settings, this); var json = await net.GetJsonAsync(query, token : token); var imageItems = new SearchedPage(); foreach (var item in Ex.GetList(json)) { var img = new MoeItem(this, para); img.Width = $"{item.width}".ToInt(); img.Height = $"{item.height}".ToInt(); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.score}".ToInt(); img.Uploader = $"{item.author}"; img.UploaderId = $"{item.creator_id}"; foreach (var tag in $"{item.tags}".Split(' ').SkipWhile(string.IsNullOrWhiteSpace)) { img.Tags.Add(tag.Trim()); } img.IsExplicit = $"{item.rating}" == "e"; img.DetailUrl = $"{homeUrl}/post/show/{img.Id}"; img.Date = $"{item.created_at}".ToDateTime(); if (img.Date == null) { img.DateString = $"{item.created_at}"; } img.Urls.Add(DownloadTypeEnum.Thumbnail, $"{item.preview_url}"); img.Urls.Add(DownloadTypeEnum.Medium, $"{item.sample_url}"); img.Urls.Add(DownloadTypeEnum.Origin, $"{item.file_url}", img.DetailUrl, filesize: $"{item.file_size}".ToUlong()); img.Source = $"{item.source}"; img.OriginString = $"{item}"; imageItems.Add(img); } return(imageItems); }
public static async Task GetDetailTask(MoeItem img, SearchPara para, CancellationToken token) { var url = img.DetailUrl; var net = new NetOperator(img.Site.Settings, img.Site); var html = await net.GetHtmlAsync(url, null, false, token); if (html == null) { return; } var nodes = html.DocumentNode; img.Artist = nodes.SelectSingleNode("*//li[@class='tag-type-artist']/a[2]")?.InnerText.Trim(); img.Character = nodes.SelectSingleNode("*//li[@class='tag-type-character']/a[2]")?.InnerText.Trim(); img.Copyright = nodes.SelectSingleNode("*//li[@class='tag-type-copyright']/a[2]")?.InnerText.Trim(); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { var list = new AutoHintItems(); var net = new NetOperator(Settings, this); var json = await net.GetJsonAsync(GetHintQuery(para), token : token); foreach (var item in Ex.GetList(json)) { list.Add(new AutoHintItem { Word = $"{item.value}", Count = $"{item.post_count}" }); } return(list); }
//public override async Task<bool> ThumbAsync(MoeItem item, CancellationToken token) //{ // if (!IsLogin()) return false; // var r = await AccountNet.Client.PostAsync() //} public bool Login() { AccountNet = new NetOperator(Settings, HomeUrl); AccountNet.HttpClientHandler.AllowAutoRedirect = true; AccountNet.HttpClientHandler.UseCookies = true; var cc = GetCookies(); if (cc == null) { Extend.ShowMessage("需要重新登录", null, Extend.MessagePos.Window); AccountNet = null; return(false); } AccountNet.HttpClientHandler.CookieContainer = cc; AccountNet.SetTimeOut(40); return(true); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { var list = new AutoHintItems(); var net = new NetOperator(Settings); switch (SiteType) { case SiteTypeEnum.Xml: var xml = await net.GetXmlAsync(GetHintQuery(para), token); if (xml == null) { return(list); } var root = xml.SelectSingleNode("tags"); if (root?.ChildNodes == null) { return(list); } foreach (XmlElement child in root.ChildNodes) { list.Add(new AutoHintItem { Word = child.GetAttribute("name"), Count = child.GetAttribute("count") }); } return(list); case SiteTypeEnum.Json: var json = await net.GetJsonAsync(GetHintQuery(para), token); foreach (var item in Extend.GetList(json)) { list.Add(new AutoHintItem { Word = $"{item.name}", Count = $"{item.post_count}" }); } return(list); } return(list); }
public async Task Init(Settings setting, MoeSite site) { Site = site; DataContext = setting; Closing += OnClosing; this.SetWindowFluent(setting); try { MainBrowser.CoreWebView2InitializationCompleted += MainBrowserOnCoreWebView2InitializationCompleted; if (MainBrowser == null) { return; } var option = new CoreWebView2EnvironmentOptions(); switch (NetOperator.GetProxyMode(setting, site.SiteSettings)) { case Settings.ProxyModeEnum.None: option.AdditionalBrowserArguments = "--no-proxy-server"; break; case Settings.ProxyModeEnum.Custom: option.AdditionalBrowserArguments = $"--proxy-server=http://{setting.ProxySetting}"; break; case Settings.ProxyModeEnum.Ie: break; } Environment = await CoreWebView2Environment.CreateAsync(null, App.AppDataDir, option); AuthButton.Click += AuthButtonOnClick; GoToLoginPageButton.Click += GoToLoginPageButtonOnClick; var _ = MainBrowser.EnsureCoreWebView2Async(Environment); } catch (Exception ex) { var result = MessageBox.Show(this, "未找到WebView2组件,需要下载吗?(需要Webview2组件才能显示网页登录界面)", App.DisplayName, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { "https://go.microsoft.com/fwlink/p/?LinkId=2124703".GoUrl(); } Ex.Log(ex); Close(); } }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { if (Net == null) { Net = new NetOperator(Settings, HomeUrl); } const string api = "https://api.yuriimg.com/posts"; var pairs = new Pairs { { "page", $"{para.PageIndex}" }, { "tags", para.Keyword.ToEncodedUrl() } }; var json = await Net.GetJsonAsync(api, token, pairs); if (json?.posts == null) { return(null); } var imgs = new MoeItems(); foreach (var post in json.posts) { var img = new MoeItem(this, para); img.IsExplicit = $"{post.rating}" == "e"; if (CurrentSiteSetting.LoginCookie.IsEmpty() && img.IsExplicit) { continue; } img.Id = $"{post.pid}".ToInt(); img.Sid = $"{post.id}"; img.Width = $"{post.width}".ToInt(); img.Height = $"{post.height}".ToInt(); img.Urls.Add(1, $"https://i.yuriimg.com/{post.src}/yuriimg.com%20{post.id}%20contain.jpg"); img.DetailUrl = $"{HomeUrl}/show/{post.id}"; img.GetDetailTaskFunc = async() => await GetDetailTask(img, $"{post.id}", token); img.OriginString = $"{post}"; imgs.Add(img); } return(imgs); }
public async Task SearchByKeyword(SearchPara para, MoeItems imgs, CancellationToken token) { const string api = "https://api.bilibili.com/x/web-interface/search/type"; var newOrHotOrder = para.Lv3MenuIndex == 0 ? "pubdate" : "stow"; var drawOrPhotoCatId = para.Lv2MenuIndex == 0 ? "1" : "2"; var pairs = new Pairs { { "search_type", "photo" }, { "page", $"{para.PageIndex}" }, { "order", newOrHotOrder }, { "keyword", para.Keyword.ToEncodedUrl() }, { "category_id", drawOrPhotoCatId } }; var net = new NetOperator(Settings, this); var json = await net.GetJsonAsync(api, pairs, token : token); if (json == null) { return; } foreach (var item in Ex.GetList(json.data?.result)) { var img = new MoeItem(this, para); img.Urls.Add(1, $"{item.cover}@336w_336h_1e_1c.jpg"); img.Urls.Add(2, $"{item.cover}@1024w_768h.jpg"); img.Urls.Add(4, $"{item.cover}"); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.like}".ToInt(); img.Rank = $"{item.rank_offset}".ToInt(); img.Title = $"{item.title}"; img.Uploader = $"{item.uname}"; img.GetDetailTaskFunc = async cancellationToken => await GetSearchByKeywordDetailTask(img, para, cancellationToken); img.DetailUrl = $"https://h.bilibili.com/{img.Id}"; img.OriginString = $"{item}"; imgs.Add(img); } var c = $"{json.data?.numResults}".ToInt(); Ex.ShowMessage($"共搜索到{c}张,已加载至{para.PageIndex}页,共{c / para.CountLimit}页", null, Ex.MessagePos.InfoBar); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { if (AutoHintNet == null) { AutoHintNet = new NetOperator(Settings, HomeUrl); } AutoHintNet.SetReferer($"{HomeUrl}/?lang=zh_CN"); //AutoHintNet.Client.DefaultRequestHeaders.Add("content-type", "multipart/form-data; boundary=----WebKitFormBoundaryzFqgWZTqudUG0vBb"); var re = new AutoHintItems(); var mulform = new MultipartFormDataContent("----WebKitFormBoundaryzFqgWZTqudUG0vBb"); var content = new FormUrlEncodedContent(new Pairs { { "tag", para.Keyword.Trim() } }); mulform.Add(content); var url = $"{HomeUrl}/pictures/autocomplete_tag"; var response = await AutoHintNet.Client.PostAsync(url, mulform, token); // todo 这里post数据获取失败,希望有大神能够解决 if (!response.IsSuccessStatusCode) { return(new AutoHintItems()); } var txt = await response.Content.ReadAsStringAsync(); //JSON format response dynamic json = JsonConvert.DeserializeObject(txt); dynamic list = ((JProperty)json).Value; foreach (var item in list) { re.Add(new AutoHintItem { Word = $"{item.t}".Replace("<br>", "").Replace("</br>", ""), Count = $"{item.c}" }); } return(re); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { if (AutoHintNet == null) { AutoHintNet = new NetOperator(Settings, this); AutoHintNet.SetReferer($"{HomeUrl}"); } var re = new AutoHintItems(); var pairs = new Pairs { { "tag", para.Keyword.Trim() } }; var content = new FormUrlEncodedContent(pairs); var url = $"{HomeUrl}/pictures/autocomplete_tag"; var response = await AutoHintNet.Client.PostAsync(url, content, token); if (!response.IsSuccessStatusCode) { return(new AutoHintItems()); } var txt = await response.Content.ReadAsStringAsync(token); dynamic json = JsonConvert.DeserializeObject(txt); var list = json?.tags_list; foreach (var item in Ex.GetList(list)) { var i = new AutoHintItem { Word = $"{item.t}".Delete("<b>", "</b>"), Count = $"{item.c}" }; re.Add(i); } return(re); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { if (AutoHintNet == null) { AutoHintNet = new NetOperator(Settings, HomeUrl); AutoHintNet.SetReferer(HomeUrl); } var items = new AutoHintItems(); if (para.SubMenuIndex != 0 && para.SubMenuIndex != 5) { return(items); } var url = $"{HomeUrl}/rpc/cps.php?keyword={para.Keyword}"; var jList = await AutoHintNet.GetJsonAsync(url, token); foreach (var obj in Extend.GetList(jList?.candidates)) { items.Add($"{obj.tag_name}"); } return(items); }
public async Task LoginAsync(CancellationToken token) { Net = new NetOperator(Settings, this); Net.SetTimeOut(20); var index = new Random().Next(0, _user.Length); var content = new FormUrlEncodedContent(new Dictionary <string, string> { { "login", _user[index] }, { "password", _pass[index] } }); var respose = await Net.Client.PostAsync($"{HomeUrl}/login/submit", content, token); // http://mjv-art.org/login/submit if (respose.IsSuccessStatusCode) { IsLogon = true; } else { Ex.Log("https://anime-pictures.net 网站登陆失败"); } }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { if (Net == null) { Net = new NetOperator(para.Site.Settings); } //type 1 tag 2 source 3 artist | chara no type var items = new AutoHintItems(); //chara without hint if (para.SubMenuIndex == 3) { return(items); } var pairs = new Pairs { { "mode", "tag_search" }, { "tags", para.Keyword }, { "type", $"{para.SubMenuIndex + 1}" } }; var url = $"{HomeUrl}/httpreq.php{pairs.ToPairsString()}"; var res = await Net.Client.GetAsync(url, token); var txt = await res.Content.ReadAsStringAsync(); var lines = txt.Split('\n'); for (var i = 0; i < lines.Length && i < 8; i++) { if (lines[i].Trim().Length > 0) { items.Add(new AutoHintItem { Word = lines[i].Trim().Delete("\"") }); } } return(items); }
public async Task Login(CancellationToken token) { Net = new NetOperator(Settings, this); Ex.ShowMessage("MiniTokyo 正在自动登录中……", null, Ex.MessagePos.Searching); var accIndex = new Random().Next(0, _user.Length); var content = new FormUrlEncodedContent(new Pairs { { "username", _user[accIndex] }, { "password", _pass[accIndex] } }); var p = await Net.Client.PostAsync("http://my.minitokyo.net/login", content, token); if (p.IsSuccessStatusCode) { IsUserLogin = true; } else { Net = null; IsUserLogin = false; Ex.ShowMessage("MiniTokyo 登录失败"); } }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { // if (para.MirrorSite != null) return null; var islogin = CheckIsLogin(); if (!islogin) { return(null); } if (AutoHintNet == null) { AutoHintNet = new NetOperator(Settings, this); AutoHintNet.SetCookie(SiteSettings.GetCookieContainer()); } var net = AutoHintNet.CloneWithCookie(); net.SetTimeOut(15); net.SetReferer(HomeUrl); var items = new AutoHintItems(); if (para.Lv2MenuIndex != 0 && para.Lv2MenuIndex != 5) { return(items); } var url = $"{HomeUrl}/rpc/cps.php?keyword={para.Keyword}"; var jList = await net.GetJsonAsync(url, token : token); foreach (var obj in Ex.GetList(jList?.candidates)) { items.Add($"{obj.tag_name}"); } return(items); }
public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token) { var net = new NetOperator(para.Site.Settings); var pairs = new Pairs { { "limit", "15" }, { "order", "count" }, { "name", para.Keyword } }; var query = $"{HomeUrl}/tag.json{pairs.ToPairsString()}"; var json = await net.GetJsonAsync(query, token); var items = new AutoHintItems(); foreach (var item in Extend.GetList(json)) { var hintItem = new AutoHintItem(); hintItem.Count = $"{item.count}"; hintItem.Word = $"{item.name}"; items.Add(hintItem); } return(items); }
public async Task SearchByRank(NetOperator net, SearchedPage imgs, SearchPara para, CancellationToken token) { var modesR18 = new[] { "daily", "weekly", "male", "female" }; var modes = new[] { "daily", "weekly", "monthly", "rookie,", "original", "male", "female" }; var mode = IsR18 ? modesR18[para.Lv3MenuIndex] : modes[para.Lv3MenuIndex]; if (IsR18) { mode += "_r18"; } var contents = new[] { "all", "illust", "manga", "ugoira" }; var content = contents[para.Lv4MenuIndex]; var referer = $"{HomeUrl}/ranking.php?mode={mode}&content={content}"; net.SetReferer(referer); var q = $"{HomeUrl}/ranking.php"; var pair = new Pairs { { "mode", mode }, { "content", content }, { "date", para.Date == null ? "" : $"{para.Date:yyyyMMdd}" }, { "p", $"{para.PageIndex}" }, { "format", "json" } }; var json = await net.GetJsonAsync(q, pair, token : token); foreach (var illus in Ex.GetList(json?.contents)) { var img = new MoeItem(this, para); img.Urls.Add(DownloadTypeEnum.Thumbnail, $"{illus.url}", referer); img.Id = $"{illus.illust_id}".ToInt(); img.Title = $"{illus.title}"; img.Uploader = $"{illus.user_name}"; img.UploaderId = $"{illus.user_id}"; img.Width = $"{illus.width}".ToInt(); img.Height = $"{illus.height}".ToInt(); img.DetailUrl = $"{HomeUrl}/artworks/{img.Id}"; img.ChildrenItemsCount = $"{illus.illust_page_count}".ToInt(); img.Score = $"{illus.rating_count}".ToInt(); img.Rank = $"{illus.rank}".ToInt(); if (img.Rank > 0) { var yes = $"{illus.yes_rank}".ToInt(); img.Tip = yes == 0 ? "首次登场" : $"之前#{yes}"; if (yes == 0) { img.TipHighLight = true; } } foreach (var tag in Ex.GetList(illus.tags)) { img.Tags.Add($"{tag}"); } img.Date = GetDateFromUrl($"{illus.url}"); if ($"{illus.illust_type}" == "2") { img.GetDetailTaskFunc = async t => await GetUgoiraDetailPageTask(img, t); } else { img.GetDetailTaskFunc = async t => await GetDetailPageTask(img, para, t); } img.OriginString = $"{illus}"; imgs.Add(img); } var count = $"{json?.rank_total}".ToInt(); Ex.ShowMessage($"共{count}张,当前日期:{json?.date}", null, Ex.MessagePos.InfoBar); }
public async Task SearchByAuthor(NetOperator net, SearchedPage imgs, string uid, SearchPara para, CancellationToken token) { var isIllust = para.Lv3MenuIndex == 0; var mi = isIllust ? "illustrations" : "manga"; var mi2 = isIllust ? "illusts" : "manga"; var mi3 = isIllust ? "插画" : "漫画"; net.SetReferer($"{HomeUrl}/users/{uid}/{mi}"); var allJson = await net.GetJsonAsync($"{HomeUrl}/ajax/user/{uid}/profile/all", token : token); if ($"{allJson?.error}".ToLower() == "true") { Ex.ShowMessage($"搜索失败,网站信息:“{$"{allJson?.message}".ToDecodedUrl()}”", null, Ex.MessagePos.Window); return; } var picIds = new List <string>(); var arts = isIllust ? allJson?.body?.illusts : allJson?.body?.manga; foreach (var ill in Ex.GetList(arts)) { picIds.Add((ill as JProperty)?.Name); } var picCurrentPage = picIds.OrderByDescending(i => i.ToInt()) .Skip(((para.PageIndex ?? 0) - 1) * para.CountLimit).Take(para.CountLimit).ToList(); if (!picCurrentPage.Any()) { return; } var pairs = new Pairs(); foreach (var pic in picCurrentPage) { pairs.Add("ids[]".ToEncodedUrl(), pic); } pairs.Add("work_category", mi2); pairs.Add("is_first_page", "1"); var picsJson = await net.GetJsonAsync($"{HomeUrl}/ajax/user/{uid}/profile/illusts", pairs, token : token); var works = picsJson?.body?.works; foreach (var item in Ex.GetList(works)) { dynamic illus = (item as JProperty)?.Value; if (illus == null) { continue; } var img = new MoeItem(this, para); img.Urls.Add(DownloadTypeEnum.Thumbnail, $"{illus.url}", $"{HomeUrl}/users/{uid}/{mi}"); img.Id = $"{illus.id}".ToInt(); img.Title = $"{illus.title}"; img.Uploader = $"{illus.userName}"; img.UploaderId = $"{illus.userId}"; img.UploaderHeadUrl = $"{illus.profileImageUrl}"; img.Width = $"{illus.width}".ToInt(); img.Height = $"{illus.height}".ToInt(); img.DetailUrl = $"{HomeUrl}/artworks/{img.Id}"; img.ChildrenItemsCount = $"{illus.pageCount}".ToInt(); foreach (var tag in Ex.GetList(illus.tags)) { img.Tags.Add($"{tag}"); } img.Date = GetDateFromUrl($"{illus.url}"); if ($"{illus.illustType}" == "2") { img.GetDetailTaskFunc = async t => await GetUgoiraDetailPageTask(img, t); } else { img.GetDetailTaskFunc = async t => await GetDetailPageTask(img, para, t); } img.OriginString = $"{item}"; imgs.Add(img); } Ex.ShowMessage($"该作者共有{mi3}{picIds.Count}张,当前第{para.CountLimit * (para.PageIndex - 1) + 1}张", null, Ex.MessagePos.InfoBar); }
public async Task SearchViaMirrorSite(NetOperator net, SearchedPage imgs, SearchPara para, CancellationToken token) { var referer = "https://pixiviz.pwp.app"; var homeurl = referer; var replaceTo = ""; net.SetReferer(referer); if (para.Keyword.IsEmpty()) { throw new Exception("镜像站点必须填入关键字"); } var api = $"https://pixiviz-api-us.pwp.link/v1/illust/search?word={para.Keyword.ToEncodedUrl()}&page={para.PageIndex}"; if (para.MirrorSite.Name == "pixiviz") { replaceTo = "https://pixiv-image-lv.pwp.link"; } var json = await net.GetJsonAsync(api, token : token); dynamic list = null; if (para.MirrorSite.Name == "pixiviz") { list = json?.illusts; } foreach (var illus in Ex.GetList(list)) { var img = new MoeItem(this, para); img.Id = $"{illus.id}".ToInt(); var imgurl = $"{illus.image_urls.medium}".Replace("https://i.pximg.net", replaceTo); var imgurlL = $"{illus.image_urls.large}".Replace("https://i.pximg.net", replaceTo); img.Urls.Add(new UrlInfo(DownloadTypeEnum.Large, imgurl, referer)); img.Urls.Add(new UrlInfo(DownloadTypeEnum.Thumbnail, imgurlL, referer)); img.Title = $"{illus.title}"; img.Uploader = $"{illus.user.account}"; img.UploaderId = $"{illus.user.id}"; img.Width = $"{illus.width}".ToInt(); img.Height = $"{illus.height}".ToInt(); img.ChildrenItemsCount = $"{illus.page_count}".ToInt(); foreach (var tag in Ex.GetList(illus.tags)) { img.Tags.Add($"{tag.name}"); } img.Date = $"{illus.create_date}".ToDateTime(); img.OriginString = $"{illus}"; img.Score = $"{illus.total_bookmarks}".ToInt(); if (illus.meta_pages != null) { foreach (var item in Ex.GetList(illus.meta_pages)) { if (item.image_urls?.original != null) { var child = new MoeItem(this, para); var imgUrlO = $"{item.image_urls?.original}".Replace("https://i.pximg.net", replaceTo); child.Urls.Add(new UrlInfo(DownloadTypeEnum.Origin, imgUrlO, homeurl)); img.ChildrenItems.Add(child); } } } if (illus.meta_single_page?.original_image_url != null) { var imgurlO = $"{illus.meta_single_page?.original_image_url}".Replace("https://i.pximg.net", replaceTo); img.Urls.Add(new UrlInfo(DownloadTypeEnum.Origin, imgurlO, homeurl)); } imgs.Add(img); } }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { if (Net == null) { Net = new NetOperator(Settings); Net.SetReferer(HomeUrl); await Net.Client.GetAsync(HomeUrl, token); } var size = ""; if (para.IsFilterResolution) { var s = para.MinWidth > para.MinHeight ? para.MinWidth : para.MinHeight; size = $"{s}"; } var orient = ""; switch (para.Orientation) { case ImageOrientation.Portrait: orient = "p"; break; case ImageOrientation.Landscape: orient = "l"; break; } var pair = new Pairs { { "tags", para.Keyword.ToEncodedUrl() }, { "size", size }, { "orient", orient }, { "page", $"{para.PageIndex}" } }; var imageItems = new MoeItems(); var json = await Net.GetJsonAsync($"{HomeUrl}/index.json", token, pair); if (json?.images == null) { return(imageItems); } foreach (var image in json.images) { var img = new MoeItem(this, para); var id = (int)image.id; img.Id = id; var sub = $"https://{id % 10}.s.kawaiinyan.com/i"; img.Uploader = $"{image.user_name}"; img.Source = $"{image.adv_link}"; img.Score = (int)image.yes; var tags = $"{image.tags}"; foreach (var s in tags.Split(',')) { if (s.IsEmpty()) { continue; } img.Tags.Add(s); } var small = $"{image.small}"; img.Urls.Add(1, $"{sub}{UrlInner($"{id}")}/small.{small}"); var orig = $"{image.orig}"; var big = $"{image.big}"; if (!orig.IsEmpty()) { img.Urls.Add(4, $"{sub}{UrlInner($"{id}")}/orig.{orig}"); } else if (!big.IsEmpty()) { img.Urls.Add(4, $"{sub}{UrlInner($"{id}")}/big.{big}"); } img.DetailUrl = $"{HomeUrl}/image?id={id}"; img.Site = this; img.OriginString = $"{image}"; imageItems.Add(img); } token.ThrowIfCancellationRequested(); return(imageItems); }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { var imgs = new MoeItems(); var url = $"{HomeUrl}/?page={para.PageIndex}"; if (Net == null) { Net = new NetOperator(Settings); } if (!para.Keyword.IsEmpty()) { url = $"{HomeUrl}/search/process/"; var i = para.SubMenuIndex; //var kw = $"{$"\"{para.Keyword.Delete("\"")}\"".ToEncodedUrl()}"; var kw = $"\"{para.Keyword}\""; //e-shuushuu需要将关键词转换为tag id,然后进行搜索 var mc = new FormUrlEncodedContent(new Pairs { { "tags", i == 0 ? kw : "" }, { "source", i == 1 ? kw : "" }, { "char", i == 3 ? kw : "" }, { "artist", i == 2 ? kw : "" }, { "postcontent", "" }, { "txtposter", "" } }); var net = Net.CloneWithOldCookie(); var r = await net.Client.GetAsync(HomeUrl, token); if (r.IsSuccessStatusCode == false) { return(imgs); } net = net.CloneWithOldCookie(); net.SetReferer($"{HomeUrl}/search"); net.HttpClientHandler.AllowAutoRedirect = false; //prevent 303 var res = await net.Client.PostAsync(url, mc, token); var loc303 = res.Headers.Location?.OriginalString; //todo 无法实现,需要大神 //http://e-shuushuu.net/search/results/?tags=2 if (!loc303.IsEmpty()) { url = $"{loc303}&page={para.PageIndex}"; } else { return new MoeItems { Message = "没有搜索到关键词相关的图片" } }; } // images var doc = await Net.GetHtmlAsync(url, token); if (doc == null) { return new MoeItems { Message = "获取HTML失败" } } ; var nodes = doc.DocumentNode.SelectNodes("//div[@class='image_thread display']"); if (nodes == null) { return(imgs); } foreach (var imgNode in nodes) { var img = new MoeItem(this, para); var id = imgNode.Attributes["id"]?.Value.Delete("i"); img.Id = $"{id}".ToInt(); var imgHref = imgNode.SelectSingleNode(".//a[@class='thumb_image']"); var fileUrl = imgHref.Attributes["href"].Value; if (fileUrl.StartsWith("/")) { fileUrl = $"{HomeUrl}{fileUrl}"; } var previewUrl = imgHref.SelectSingleNode("img").Attributes["src"].Value; if (previewUrl.StartsWith("/")) { previewUrl = $"{HomeUrl}{previewUrl}"; } img.Urls.Add(1, previewUrl, HomeUrl); var meta = imgNode.SelectSingleNode(".//div[@class='meta']"); img.Date = meta.SelectSingleNode(".//dd[2]").InnerText.ToDateTime(); var dimension = meta.SelectSingleNode(".//dd[4]").InnerText; foreach (var s in dimension.Split(' ')) { if (!s.Contains("x")) { continue; } var res = s.Split('x'); if (res.Length != 2) { continue; } img.Width = res[0].ToInt(); img.Height = res[1].ToInt(); break; } var tags = meta.SelectNodes(".//span[@class='tag']/a"); if (tags != null) { foreach (var tag in tags) { if (tag.InnerText.IsEmpty()) { continue; } img.Tags.Add(tag.InnerText); } img.Uploader = tags.LastOrDefault()?.InnerText; } var detail = $"{HomeUrl}/image/{id}"; img.DetailUrl = detail; img.Urls.Add(4, fileUrl, detail); img.OriginString = imgNode.OuterHtml; imgs.Add(img); } return(imgs); }
public async Task SearchByNewOrHot(SearchPara para, CancellationToken token, MoeItems imgs) { const string api = "https://api.vc.bilibili.com/link_draw/v2"; var type = para.Lv3MenuIndex == 0 ? "new" : "hot"; var count = para.Count > 20 ? 20 : para.Count; var api2 = ""; switch (para.SubMenuIndex) { case 0: api2 = $"{api}/Doc/list"; break; case 1: case 2: api2 = $"{api}/Photo/list"; break; } var net = new NetOperator(Settings); var json = await net.GetJsonAsync(api2, token, new Pairs { { "category", para.SubMenuIndex == 0 ? "all" : (para.SubMenuIndex == 1 ? "cos" : "sifu") }, { "type", type }, { "page_num", $"{para.PageIndex - 1}" }, { "page_size", $"{count}" } }); foreach (var item in Extend.GetList(json?.data?.items)) { var cat = para.SubMenuIndex == 0 ? "/d" : "/p"; var img = new MoeItem(this, para) { Uploader = $"{item.user?.name}", Id = $"{item.item?.doc_id}".ToInt(), }; img.DetailUrl = $"https://h.bilibili.com/{img.Id}"; var i0 = item.item?.pictures[0]; img.Width = $"{i0?.img_width}".ToInt(); img.Height = $"{i0?.img_height}".ToInt(); img.Date = $"{item.item?.upload_time}".ToDateTime(); img.Urls.Add(1, $"{i0?.img_src}@336w_336h_1e_1c.jpg", HomeUrl + cat); img.Urls.Add(2, $"{i0?.img_src}@1024w_768h.jpg"); img.Urls.Add(4, $"{i0?.img_src}"); img.Title = $"{item.item?.title}"; var list = item.item?.pictures as JArray; if (list?.Count > 1) { foreach (var pic in item.item.pictures) { var child = new MoeItem(this, para); child.Urls.Add(1, $"{pic.img_src}@336w_336h_1e_1c.jpg", HomeUrl + cat); child.Urls.Add(2, $"{pic.img_src}@1024w_768h.jpg", HomeUrl + cat); child.Urls.Add(4, $"{pic.img_src}"); child.Width = $"{pic.img_width}".ToInt(); child.Height = $"{pic.img_height}".ToInt(); img.ChildrenItems.Add(child); } } img.GetDetailTaskFunc = async() => await GetSearchByNewOrHotDetailTask(img, token, para); img.OriginString = $"{item}"; imgs.Add(img); } var c = $"{json?.data.total_count}".ToInt(); Extend.ShowMessage($"共搜索到{c}张,已加载至{para.PageIndex}页,共{c / para.Count}页", null, Extend.MessagePos.InfoBar); }
public async Task SearchByNewOrTag(NetOperator net, SearchedPage imgs, SearchPara para, CancellationToken token) { string referer, api; Pairs pairs; var isIllust = para.Lv3MenuIndex == 0; var homeurl = HomeUrl; //if (para.MirrorSite.Name == "pixiviz") //{ // homeurl = "https://pixiviz-api-us.pwp.link/v1"; //} if (para.Keyword.IsEmpty()) // new { api = $"{homeurl}/ajax/illust/new"; referer = isIllust ? $"{homeurl}/new_illust.php" : $"{homeurl}/new_illust.php?type=manga"; pairs = new Pairs { { "lastId", para.PageIndexCursor.IsEmpty() ? "" : $"{para.PageIndexCursor}" }, { "limit", $"{para.CountLimit}" }, { "type", isIllust ? "illust" : "manga" }, { "r18", R18Query } }; } else // tag { api = $"{homeurl}/ajax/search/{(isIllust ? "illustrations" : "manga")}/{para.Keyword.ToEncodedUrl()}"; referer = $"{homeurl}/tags/{para.Keyword.ToEncodedUrl()}/{(isIllust ? "illustrations" : "manga")}?mode={R18ModeQuery}&s_mode=s_tag"; pairs = new Pairs { { "word", para.Keyword.ToEncodedUrl() }, { "order", "date" }, { "mode", R18ModeQuery }, { "p", $"{para.PageIndex}" }, { "s_mode", "s_tag" }, { "type", isIllust ? "illust_and_ugoira" : "manga" } }; } net.SetReferer(referer); var json = await net.GetJsonAsync(api, pairs, token : token); var list = para.Keyword.IsEmpty() ? json?.body?.illusts : isIllust ? json?.body?.illust?.data : json?.body?.manga?.data; foreach (var illus in Ex.GetList(list)) { var img = new MoeItem(this, para); img.Id = $"{illus.id}".ToInt(); img.Urls.Add(new UrlInfo(DownloadTypeEnum.Thumbnail, $"{illus.url}", $"{homeurl}/new_illust.php")); img.Title = $"{illus.title}"; img.Uploader = $"{illus.userName}"; img.UploaderId = $"{illus.userId}"; img.Width = $"{illus.width}".ToInt(); img.Height = $"{illus.height}".ToInt(); img.DetailUrl = $"{homeurl}/artworks/{img.Id}"; img.ChildrenItemsCount = $"{illus.pageCount}".ToInt(); foreach (var tag in Ex.GetList(illus.tags)) { img.Tags.Add($"{tag}"); } img.Date = GetDateFromUrl($"{illus.url}"); if ($"{illus.illustType}" == "2") { img.GetDetailTaskFunc = async t => await GetUgoiraDetailPageTask(img, t); } else { img.GetDetailTaskFunc = async t => await GetDetailPageTask(img, para, t); } img.OriginString = $"{illus}"; imgs.Add(img); } var lastid = $"{json?.body?.lastId}"; if (!lastid.IsEmpty()) { imgs.NextPageIndexCursor = lastid; } if (!para.Keyword.IsEmpty() && json != null) { var count = $"{json?.body?.illust?.total}".ToInt(); Ex.ShowMessage($"共搜索到{count}张图片,当前已加载至第{para.PageIndex}页,共{count / 60}页", null, Ex.MessagePos.InfoBar); } }