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