Exemplo n.º 1
0
    public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
    {
        if (Net == null)
        {
            Login();
        }
        var net  = Net.CloneWithCookie();
        var list = new AutoHintItems();

        switch (SiteType)
        {
        case SiteTypeEnum.Xml:
            var xml = await net.GetXmlAsync(GetHintQuery(para), token : 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 : token);

            foreach (var item in Ex.GetList(json))
            {
                list.Add(new AutoHintItem
                {
                    Word  = $"{item.name}",
                    Count = $"{item.post_count}"
                });
            }
            return(list);
        }

        return(list);
    }
Exemplo n.º 2
0
    public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
    {
        var ahis     = new AutoHintItems();
        var jsonlist = await new NetOperator(Settings, this).GetJsonAsync(GetHintQuery(para), token: token);

        foreach (var item in Ex.GetList(jsonlist))
        {
            ahis.Add(new AutoHintItem
            {
                Word  = $"{item.value}",
                Count = $"{item.post_count}"
            });
        }
        return(ahis);
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    public override async Task <AutoHintItems> GetAutoHintItemsAsync(SearchPara para, CancellationToken token)
    {
        Net ??= new NetOperator(Settings, this);
        //type 1 tag 2 source 3 artist | chara no type
        var items = new AutoHintItems();

        //chara without hint
        if (para.Lv2MenuIndex == 3)
        {
            return(items);
        }
        var pairs = new Pairs
        {
            { "mode", "tag_search" },
            { "tags", para.Keyword },
            { "type", $"{para.Lv2MenuIndex + 1}" }
        };
        var url = $"{HomeUrl}/httpreq.php{pairs.ToPairsString()}";
        var net = Net.CloneWithCookie();
        var res = await net.Client.GetAsync(url, token);

        var txt = await res.Content.ReadAsStringAsync(token);

        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);
    }
Exemplo n.º 5
0
    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);
    }