Exemple #1
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var          ahitems = new AutoHintItems();
            const string api     = "https://capi-v2.sankakucomplex.com";

            Net = Net == null ? new NetDocker(Settings, api) : Net.CloneWithOldCookie();
            var pairs = new Pairs
            {
                { "lang", "en" },
                { "tag", para.Keyword.ToEncodedUrl() },
                { "target", "post" },
                { "show_meta", "1" }
            };
            var json = await Net.GetJsonAsync($"{api}/tags/autosuggestCreating", token, pairs);

            foreach (var jitem in Extend.CheckListNull(json))
            {
                var ahitem = new AutoHintItem();
                ahitem.Word  = $"{jitem.name}";
                ahitem.Count = $"{jitem.count}";
                ahitems.Add(ahitem);
            }

            return(ahitems);
        }
Exemple #2
0
        public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token)
        {
            if (!_isIdolLogin)
            {
                await LoginAsync(token);
            }
            if (!_isIdolLogin)
            {
                return(new MoeItems());
            }
            var query = $"{_idolQuery}page={para.PageIndex}&limit={para.Count}&tags={para.Keyword.ToEncodedUrl()}";
            var list  = await Net.GetJsonAsync(query, token);

            if (list == null)
            {
                return new MoeItems {
                           Message = "获取Json失败"
                }
            }
            ;
            var          imgs  = new MoeItems();
            const string https = "https:";

            foreach (var item in list)
            {
                var img = new MoeItem(this, para);

                img.Width     = $"{item.width}".ToInt();
                img.Height    = $"{item.height}".ToInt();
                img.Id        = $"{item.id}".ToInt();
                img.Score     = $"{item.fav_count}".ToInt();
                img.Uploader  = $"{item.uploader_name}";
                img.DetailUrl = $"{HomeUrl}/post/show/{img.Id}";
                img.Date      = $"{item.created_at?.s}".ToDateTime();
                foreach (var tag in Extend.CheckListNull(item.tags))
                {
                    img.Tags.Add($"{tag.name}");
                }
                img.IsExplicit = $"{item.rating}" == "e";
                img.Net        = Net.CloneWithOldCookie();
                img.Urls.Add(1, $"{https}{item.preview_url}", img.DetailUrl);
                img.Urls.Add(2, $"{https}{item.sample_url}", img.DetailUrl);
                img.Urls.Add(4, $"{https}{item.file_url}", img.DetailUrl);
                img.OriginString = $"{item}";
                imgs.Add(img);
            }

            return(imgs);
        }
Exemple #3
0
        public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token)
        {
            var          imgs = new MoeItems();
            const string api  = "https://capi-v2.sankakucomplex.com";
            const string beta = "https://beta.sankakucomplex.com";

            Net = Net == null ? new NetDocker(Settings, api) : Net.CloneWithOldCookie();

            Net.SetReferer(beta);
            var pairs = new Pairs
            {
                { "lang", "en" },
                { "page", $"{para.PageIndex}" },
                { "limit", $"{para.Count}" },
                { "hide_posts_in_books", "in-larger-tags" },
                { "default_threshold", "1" },
                { "tags", para.Keyword.ToEncodedUrl() }
            };
            var json = await Net.GetJsonAsync($"{api}/posts", token, pairs);

            foreach (var jitem in Extend.CheckListNull(json))
            {
                var img = new MoeItem(this, para)
                {
                    Net    = Net.CloneWithOldCookie(),
                    Id     = $"{jitem.id}".ToInt(),
                    Width  = $"{jitem.width}".ToInt(),
                    Height = $"{jitem.height}".ToInt(),
                    Score  = $"{jitem.total_score}".ToInt()
                };
                img.Urls.Add(1, $"{jitem.preview_url}", beta);
                img.Urls.Add(2, $"{jitem.sample_url}", beta);
                img.Urls.Add(4, $"{jitem.file_url}", $"{beta}/post/show/{img.Id}");
                img.IsExplicit = $"{jitem.rating}" != "s";
                img.Date       = $"{jitem.created_at?.s}".ToDateTime();
                img.Uploader   = $"{jitem.author?.name}";
                img.DetailUrl  = $"{beta}/post/show/{img.Id}";
                foreach (var tag in Extend.CheckListNull(jitem.tags))
                {
                    img.Tags.Add($"{tag.name_en}");
                }

                img.OriginString = $"{jitem}";
                imgs.Add(img);
            }

            return(imgs);
        }
Exemple #4
0
        public async Task GetSearchByKeywordDetailTask(MoeItem img, CancellationToken token, SearchPara para)
        {
            var query = $"https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id={img.Id}";
            var json  = await new NetDocker(Settings).GetJsonAsync(query, token);
            var item  = json.data?.item;

            if (item == null)
            {
                return;
            }
            if ((item.pictures as JArray)?.Count > 1)
            {
                var i = 0;
                foreach (var pic in Extend.CheckListNull(item.pictures))
                {
                    var child = new MoeItem(this, para);
                    child.Urls.Add(1, $"{pic.img_src}@336w_336h_1e_1c.jpg");
                    child.Urls.Add(2, $"{pic.img_src}@1024w_768h.jpg");
                    child.Urls.Add(4, $"{pic.img_src}");
                    if (i == 0)
                    {
                        img.Width  = $"{pic.img_width}".ToInt();
                        img.Height = $"{pic.img_height}".ToInt();
                    }
                    img.ChildrenItems.Add(child);
                    i++;
                }
            }
            else if ((item.pictures as JArray)?.Count == 1)
            {
                var pic = json.data?.item?.pictures[0];
                img.Width  = $"{pic?.img_width}".ToInt();
                img.Height = $"{pic?.img_height}".ToInt();
                img.Urls.Add(4, $"{pic?.img_src}");
            }

            foreach (var tag in Extend.CheckListNull(item.tags))
            {
                img.Tags.Add($"{tag.name}");
            }

            img.Date = $"{json.data?.item?.upload_time}".ToDateTime();
            if (img.Date == null)
            {
                img.DateString = $"{item.upload_time}";
            }
        }
Exemple #5
0
        public async Task GetSearchByNewOrHotDetailTask(MoeItem img, CancellationToken token, SearchPara para)
        {
            var query = $"https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id={img.Id}";
            var json  = await new NetDocker(Settings).GetJsonAsync(query, token);
            var item  = json.data?.item;

            if (item == null)
            {
                return;
            }
            foreach (var tag in Extend.CheckListNull(item.tags))
            {
                img.Tags.Add($"{tag.name}");
            }

            img.Score = $"{item.vote_count}".ToInt();
        }
Exemple #6
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            var list = new AutoHintItems();
            var net  = new NetDocker(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.CheckListNull(json))
                {
                    list.Add(new AutoHintItem
                    {
                        Word  = $"{item.name}",
                        Count = $"{item.post_count}"
                    });
                }
                return(list);
            }

            return(list);
        }
Exemple #7
0
        public async Task GetDetailTask(MoeItem img, string id, CancellationToken token = new CancellationToken())
        {
            var api  = $"https://api.yuriimg.com/post/{id}";
            var json = await Net.GetJsonAsync(api, token);

            if (json == null)
            {
                return;
            }
            img.Score = $"{json.praise}".ToInt();
            img.Date  = $"{json.format_date}".ToDateTime();
            img.Urls.Add(4, $"https://i.yuriimg.com/{json.src}");
            img.Artist     = $"{json.artist?.name}";
            img.Uploader   = $"{json.user?.name}";
            img.UploaderId = $"{json.user?.id}";

            foreach (var tag in Extend.CheckListNull(json.tags.general))
            {
                img.Tags.Add($"{tag.tags?.jp}");
            }

            if ($"{json.page_count}".ToInt() > 1)
            {
                var q     = $"{api}/multi";
                var json2 = await Net.GetJsonAsync(q, token);

                var child1 = new MoeItem(this, img.Para);
                child1.Width  = img.Width;
                child1.Height = img.Height;
                foreach (var urlInfo in img.Urls)
                {
                    child1.Urls.Add(urlInfo);
                }
                img.ChildrenItems.Add(child1);

                foreach (var jitem in Extend.CheckListNull(json2))
                {
                    var childImg = new MoeItem(this, img.Para);
                    childImg.Width  = $"{jitem.width}".ToInt();
                    childImg.Height = $"{jitem.height}".ToInt();
                    childImg.Urls.Add(4, $"https://i.yuriimg.com/{jitem.src}");
                    img.ChildrenItems.Add(childImg);
                }
            }
        }
Exemple #8
0
        public async Task SearchByKeyword(SearchPara para, CancellationToken token, MoeItems imgs)
        {
            const string api              = "https://api.bilibili.com/x/web-interface/search/type";
            var          newOrHotOrder    = para.Lv3MenuIndex == 0? "pubdate" : "stow";
            var          drawOrPhotoCatId = para.SubMenuIndex == 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 NetDocker(Settings);
            var json = await net.GetJsonAsync(api, token, pairs);

            if (json == null)
            {
                return;
            }
            foreach (var item in Extend.CheckListNull(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() => await GetSearchByKeywordDetailTask(img, token, para);

                img.DetailUrl    = $"https://h.bilibili.com/{img.Id}";
                img.OriginString = $"{item}";
                imgs.Add(img);
            }

            var c = $"{json.data?.numResults}".ToInt();

            Extend.ShowMessage($"共搜索到{c}张,已加载至{para.PageIndex}页,共{c / para.Count}页", null, Extend.MessagePos.InfoBar);
        }
Exemple #9
0
        public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
        {
            if (AutoHintNet == null)
            {
                AutoHintNet = new NetDocker(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.CheckListNull(jList?.candidates))
            {
                items.Add($"{obj.tag_name}");
            }
            return(items);
        }
Exemple #10
0
        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 NetDocker(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.CheckListNull(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);
        }
Exemple #11
0
        public async Task SearchByRank(MoeItems 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, token, pair);

            foreach (var illus in Extend.CheckListNull(json?.contents))
            {
                var img = new MoeItem(this, para)
                {
                    Net = Net.CloneWithOldCookie(),
                    Id  = $"{illus.illust_id}".ToInt()
                };
                img.Urls.Add(1, $"{illus.url}", referer);
                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.ImagesCount = $"{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 Extend.CheckListNull(illus.tags))
                {
                    img.Tags.Add($"{tag}");
                }

                img.Date = GetDateFromUrl($"{illus.url}");
                if ($"{illus.illust_type}" == "2")
                {
                    img.GetDetailTaskFunc = async() => await GetUgoiraDetailPageTask(img);
                }
                else
                {
                    img.GetDetailTaskFunc = async() => await GetDetailPageTask(img, para);
                }

                img.OriginString = $"{illus}";
                imgs.Add(img);
            }

            var count = $"{json?.rank_total}".ToInt();

            Extend.ShowMessage($"共{count}张,当前日期:{json?.date}", null, Extend.MessagePos.InfoBar);
        }
Exemple #12
0
        public async Task SearchByAuthor(MoeItems imgs, string uid, SearchPara para, CancellationToken token)
        {
            var isIorM = para.Lv3MenuIndex == 0;
            var mi     = isIorM ? "illustrations" : "manga";
            var mi2    = isIorM ? "illusts" : "manga";
            var mi3    = isIorM ? "插画" : "漫画";

            Net.SetReferer($"{HomeUrl}/users/{uid}/{mi}");
            var allJson = await Net.GetJsonAsync($"{HomeUrl}/ajax/user/{uid}/profile/all", token);

            if ($"{allJson?.error}".ToLower() == "true")
            {
                Extend.ShowMessage($"搜索失败,网站信息:“{$"{allJson?.message}".ToDecodedUrl()}”", null, Extend.MessagePos.Window);
                return;
            }
            var picIds = new List <string>();
            var arts   = isIorM ? allJson?.body?.illusts : allJson?.body?.manga;

            foreach (var ill in Extend.CheckListNull(arts))
            {
                picIds.Add((ill as JProperty)?.Name);
            }
            var picCurrentPage = picIds.OrderByDescending(i => i.ToInt()).Skip((para.PageIndex - 1) * para.Count).Take(para.Count).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", token, pairs);

            var works = picsJson?.body?.works;

            foreach (var item in Extend.CheckListNull(works))
            {
                dynamic illus = (item as JProperty)?.Value;
                if (illus == null)
                {
                    continue;
                }
                var img = new MoeItem(this, para);
                img.Urls.Add(1, $"{illus.url}", $"{HomeUrl}/users/{uid}/{mi}");
                img.Id          = $"{illus.illustId}".ToInt();
                img.Net         = Net.CloneWithOldCookie();
                img.Title       = $"{illus.illustTitle}";
                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.ImagesCount = $"{illus.pageCount}".ToInt();
                foreach (var tag in Extend.CheckListNull(illus.tags))
                {
                    img.Tags.Add($"{tag}");
                }
                img.Date = GetDateFromUrl($"{illus.url}");
                if ($"{illus.illustType}" == "2")
                {
                    img.GetDetailTaskFunc = async() => await GetUgoiraDetailPageTask(img);
                }
                else
                {
                    img.GetDetailTaskFunc = async() => await GetDetailPageTask(img, para);
                }
                img.OriginString = $"{item}";
                imgs.Add(img);
            }
            Extend.ShowMessage($"该作者共有{mi3}{picIds.Count}张,当前第{para.Count * (para.PageIndex - 1) + 1}张", null, Extend.MessagePos.InfoBar);
        }
Exemple #13
0
        public async Task SearchByNewOrTag(MoeItems imgs, SearchPara para, CancellationToken token)
        {
            string referer, api; Pairs pairs;
            var    isIllust = para.Lv3MenuIndex == 0;

            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.LastId == 0 ? "" : $"{para.LastId}" },
                    { "limit", $"{para.Count}" },
                    { "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, token, pairs);

            var list = para.Keyword.IsEmpty()
                ? (json?.body?.illusts)
                : (isIllust ? (json?.body?.illust?.data) : (json?.body?.manga?.data));

            foreach (var illus in Extend.CheckListNull(list))
            {
                var img = new MoeItem(this, para)
                {
                    Site = this, Net = Net.CloneWithOldCookie(), Id = $"{illus.illustId}".ToInt()
                };
                img.Urls.Add(new UrlInfo(1, $"{illus.url}", $"{HomeUrl}/new_illust.php"));
                img.Title       = $"{illus.illustTitle}";
                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.ImagesCount = $"{illus.pageCount}".ToInt();
                foreach (var tag in Extend.CheckListNull(illus.tags))
                {
                    img.Tags.Add($"{tag}");
                }
                img.Date = GetDateFromUrl($"{illus.url}");
                if ($"{illus.illustType}" == "2")
                {
                    img.GetDetailTaskFunc = async() => await GetUgoiraDetailPageTask(img);
                }
                else
                {
                    img.GetDetailTaskFunc = async() => await GetDetailPageTask(img, para);
                }
                img.OriginString = $"{illus}";
                imgs.Add(img);
            }
            if (!para.Keyword.IsEmpty() && json != null)
            {
                var count = $"{json?.body?.illust?.total}".ToInt();
                Extend.ShowMessage($"共搜索到{count}张图片,当前已加载至第{para.PageIndex}页,共{count / 60}页", null, Extend.MessagePos.InfoBar);
            }
        }