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 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 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); } }
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); }