Пример #1
0
        public async Task GetDetailPageTask(MoeItem img, SearchPara para)
        {
            var net  = Net.CloneWithOldCookie();
            var json = await net.GetJsonAsync($"{HomeUrl}/ajax/illust/{img.Id}/pages");

            var img1  = json?.body?[0];
            var refer = $"{HomeUrl}/artworks/{img.Id}";

            if (img1 != null)
            {
                //img.Urls.Add(2, $"{img1.urls.small}", refer);
                img.Urls.Add(3, $"{img1.urls.regular}", refer);
                img.Urls.Add(4, $"{img1.urls.original}", refer);
            }
            var list = (JArray)json?.body;

            if (list?.Count > 1)
            {
                foreach (var item in json.body)
                {
                    var imgItem = new MoeItem(this, para);
                    //imgItem.Urls.Add(2, $"{img1?.urls.small}", refer);
                    imgItem.Urls.Add(3, $"{img1?.urls.regular}", refer);
                    imgItem.Urls.Add(4, $"{item?.urls?.original}", refer);
                    img.ChildrenItems.Add(imgItem);
                }
            }
        }
Пример #2
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);
        }
Пример #3
0
        public async Task GetUgoiraDetailPageTask(MoeItem img)
        {
            if (img.Tip.IsEmpty())
            {
                img.Tip = "动图";
            }
            var net     = Net.CloneWithOldCookie();
            var api     = $"{HomeUrl}/ajax/illust/{img.Id}/ugoira_meta";
            var jsonRes = await net.Client.GetAsync(api);

            var jsonStr = await jsonRes.Content.ReadAsStringAsync();

            dynamic json  = JsonConvert.DeserializeObject(jsonStr);
            var     img1  = json?.body;
            var     refer = $"{HomeUrl}/artworks/{img.Id}";

            if (img1 != null)
            {
                //img.Urls.Add(2, $"{img1.src}", refer, UgoiraAfterEffects);
                img.Urls.Add(3, $"{img1.src}", refer, UgoiraAfterEffects);
                img.Urls.Add(4, $"{img1.originalSrc}", refer, UgoiraAfterEffects);
                img.ExtraFile = new TextFileInfo {
                    FileExt = "json", Content = jsonStr
                };
            }
        }
Пример #4
0
        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);
        }
Пример #5
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.GetList(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);
        }
Пример #6
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);
        }
Пример #7
0
        public async Task GetDetailTask(MoeItem img)
        {
            var detialurl = img.DetailUrl;
            var net       = Net.CloneWithOldCookie();

            net.SetTimeOut(30);
            try
            {
                var subdoc = await net.GetHtmlAsync(detialurl);

                var docnodes = subdoc.DocumentNode;
                if (docnodes == null)
                {
                    return;
                }
                var downnode = docnodes.SelectSingleNode("//*[@id='rating']/a[@class='download_icon']");
                var fileurl  = downnode?.GetAttributeValue("href", "");
                if (!fileurl.IsEmpty())
                {
                    img.Urls.Add(4, $"{HomeUrl}{fileurl}", detialurl);
                }
                var tagnodes = docnodes.SelectNodes("*//div[@id='post_tags']//a");
                if (tagnodes != null)
                {
                    foreach (var tagnode in tagnodes)
                    {
                        if (!tagnode.InnerText.IsEmpty())
                        {
                            img.Tags.Add(tagnode.InnerText);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Extend.Log(e, e.StackTrace);
            }
        }
Пример #8
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.GetList(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.GetList(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);
        }
Пример #9
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.GetList(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.GetList(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.id}".ToInt();
                img.Net             = Net.CloneWithOldCookie();
                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.ImagesCount     = $"{illus.pageCount}".ToInt();
                foreach (var tag in Extend.GetList(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);
        }
Пример #10
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.GetList(list))
            {
                var img = new MoeItem(this, para);
                img.Site = this;
                img.Net  = Net.CloneWithOldCookie();
                img.Id   = $"{illus.id}".ToInt();
                img.Urls.Add(new UrlInfo(1, $"{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.ImagesCount = $"{illus.pageCount}".ToInt();
                foreach (var tag in Extend.GetList(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);
            }
        }
Пример #11
0
        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 NetDocker(Settings);
            }
            if (!para.Keyword.IsEmpty())
            {
                url = $"{HomeUrl}/search/process/";
                var i  = para.SubMenuIndex;
                var kw = $"{$"\"{para.Keyword.Delete("\"")}\"".ToEncodedUrl()}+";
                //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);
        }
Пример #12
0
        public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token)
        {
            Net = Net == null ? new NetOperator(Settings, HomeUrl) : Net.CloneWithOldCookie();

            if (!IsLogin)
            {
                Extend.ShowMessage("MiniTokyo 正在自动登录中……", null, Extend.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)
                {
                    IsLogin = true;
                }
            }

            var    imgs = new MoeItems();
            string query;

            if (para.Keyword.IsEmpty()) // by new
            {
                // recent:
                // wall http://gallery.minitokyo.net/wallpapers?display=thumbnails&order=id&page=2
                // mobile http://gallery.minitokyo.net/mobile?order=id&display=thumbnails&page=2
                // indy http://gallery.minitokyo.net/indy-art?order=id&display=thumbnails&page=2
                // scan  http://gallery.minitokyo.net/scans?order=id&display=thumbnails&page=2

                // popular
                // wall http://gallery.minitokyo.net/wallpapers?order=favorites&display=thumbnails&page=2
                // scan http://gallery.minitokyo.net/scans?display=thumbnails&order=favorites&page=2
                query = $"{HomeGalleryUrl}/{GetSort(para)}?order={GetOrder(para)}&display=thumbnails&page={para.PageIndex}";
            }
            else
            {
                var q   = $"{HomeUrl}/search?q={para.Keyword}";
                var net = Net.CloneWithOldCookie();
                net.SetReferer(HomeUrl);
                net.HttpClientHandler.AllowAutoRedirect = false;
                var res = await net.Client.GetAsync(q, token);

                var loc303 = res.Headers.Location.OriginalString;
                var net2   = Net.CloneWithOldCookie();
                var doc1   = await net2.GetHtmlAsync($"{HomeUrl}{loc303}", token);

                var tabnodes = doc1.DocumentNode.SelectNodes("*//ul[@id='tabs']//a");
                var url      = tabnodes[1].Attributes["href"]?.Value;
                var reg      = new Regex(@"(?:^|\?|&)tid=(\d*)(?:&|$)");
                var tid      = reg.Match(url ?? "").Groups[0].Value;
                var indexs   = new [] { 1, 3, 1, 2 };
                query = $"{HomeBrowseUrl}/gallery{tid}index={indexs[para.SubMenuIndex]}&order={GetOrder(para)}&display=thumbnails";
            }

            var doc = await Net.GetHtmlAsync(query, token);

            var docnode = doc.DocumentNode;
            var empty   = docnode.SelectSingleNode("*//p[@class='empty']")?.InnerText.ToLower().Trim();

            if (empty == "no items to display")
            {
                return(imgs);
            }
            var wallNode = docnode.SelectSingleNode("*//ul[@class='scans']");
            var imgNodes = wallNode.SelectNodes(".//li");

            if (imgNodes == null)
            {
                return(imgs);
            }

            foreach (var node in imgNodes)
            {
                var img       = new MoeItem(this, para);
                var detailUrl = node.SelectSingleNode("a").Attributes["href"].Value;
                img.DetailUrl = detailUrl;
                img.Id        = detailUrl.Substring(detailUrl.LastIndexOf('/') + 1).ToInt();
                var imgHref   = node.SelectSingleNode(".//img");
                var sampleUrl = imgHref.Attributes["src"].Value;
                img.Urls.Add(1, sampleUrl, HomeUrl);
                //http://static2.minitokyo.net/thumbs/24/25/583774.jpg preview
                //http://static2.minitokyo.net/view/24/25/583774.jpg   sample
                //http://static.minitokyo.net/downloads/24/25/583774.jpg   full
                const string api2       = "http://static2.minitokyo.net";
                const string api        = "http://static.minitokyo.net";
                var          previewUrl = $"{api2}/view{sampleUrl.Substring(sampleUrl.IndexOf('/', sampleUrl.IndexOf(".net/", StringComparison.Ordinal) + 5))}";
                var          fileUrl    = $"{api}/downloads{previewUrl.Substring(previewUrl.IndexOf('/', previewUrl.IndexOf(".net/", StringComparison.Ordinal) + 5))}";
                img.Urls.Add(4, fileUrl, HomeUrl);
                img.Title    = node.SelectSingleNode("./p/a").InnerText.Trim();
                img.Uploader = node.SelectSingleNode("./p").InnerText.Delete("by ").Trim();
                var res  = node.SelectSingleNode("./a/img").Attributes["title"].Value;
                var resi = res?.Split('x');
                if (resi?.Length == 2)
                {
                    img.Width  = resi[0].ToInt();
                    img.Height = resi[1].ToInt();
                }
                img.OriginString = node.OuterHtml;
                imgs.Add(img);
            }
            token.ThrowIfCancellationRequested();
            return(imgs);
        }
Пример #13
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";

            if (Net == null)
            {
                Net = new NetOperator(Settings, api);
                var cc = GetCookies();

                if (cc != null)
                {
                    Net.SetCookie(cc);
                }
            }
            else
            {
                Net.CloneWithOldCookie();
            }

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

            para.NextPagePara = $"{json.meta.next}";
            foreach (var jitem in Extend.GetList(json.data))
            {
                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}";
                if ($"{jitem.redirect_to_signup}".ToLower() == "true")
                {
                    img.Tip = "此图片需要登录查看";
                }
                foreach (var tag in Extend.GetList(jitem.tags))
                {
                    img.Tags.Add($"{tag.name_en}");
                }

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

            return(imgs);
        }