示例#1
0
        public override List <BooruAPIPost> SearchPosts(string[] Tags)
        {
            List <BooruAPIPost> posts = new List <BooruAPIPost>();
            string tagstring          = string.Empty;

            if (Tags.Length > 0)
            {
                if (Tags.Length > MAX_TAGS)
                {
                    string[] tags_for_search = new string[MAX_TAGS];
                    Array.Copy(Tags, tags_for_search, MAX_TAGS);
                    tagstring = string.Join("+", tags_for_search);
                }
                else
                {
                    tagstring = string.Join("+", Tags);
                }
            }
            for (int i = 0; true; i++)
            {
                XmlDocument document = GetXmlDocument(CreateURI("limit", "100", "pid", i.ToString(), "tags", tagstring));
                XmlNodeList xmlposts = document["posts"].GetElementsByTagName("post");
                if (xmlposts.Count > 0)
                {
                    foreach (XmlNode xmlpost in xmlposts)
                    {
                        XmlAttributeCollection attribs = xmlpost.Attributes;
                        BooruAPIPost           post    = CreateAPIPost("Gelbooru");
                        post.SourceURL    = "http://gelbooru.com/index.php?page=post&s=view&id=" + Convert.ToString(attribs["id"].Value);
                        post.Source       = post.SourceURL;
                        post.Width        = Convert.ToUInt32(Convert.ToString(attribs["width"].Value));
                        post.Height       = Convert.ToUInt32(Convert.ToString(attribs["height"].Value));
                        post.ImageURL     = Convert.ToString(attribs["file_url"].Value);
                        post.SampleURL    = Convert.ToString(attribs["sample_url"].Value);
                        post.ThumbnailURL = Convert.ToString(attribs["preview_url"].Value);
                        post.Tags         = GetTagList(Convert.ToString(attribs["tags"].Value));
                        posts.Add(post);
                    }
                }
                else
                {
                    break;
                }
            }
            if (Tags.Length > MAX_TAGS)
            {
                string[] rest_tags = new string[Tags.Length - MAX_TAGS];
                Array.Copy(Tags, MAX_TAGS, rest_tags, 0, rest_tags.Length);
                CheckForTags(ref posts, rest_tags);
            }
            return(posts);
        }
示例#2
0
        public override List <BooruAPIPost> SearchPosts(string[] Tags)
        {
            List <BooruAPIPost> posts = new List <BooruAPIPost>();
            string tagstring          = string.Empty;

            if (Tags.Length > 0)
            {
                if (Tags.Length > MAX_TAGS)
                {
                    string[] tags_for_search = new string[MAX_TAGS];
                    Array.Copy(Tags, tags_for_search, MAX_TAGS);
                    tagstring = string.Join("+", tags_for_search);
                }
                else
                {
                    tagstring = string.Join("+", Tags);
                }
            }
            for (int i = 1; true; i++)
            {
                JsonData json = GetJSONData(CreateURI("limit", "100", "page", i.ToString(), "tags", tagstring));
                if (json.Count > 0)
                {
                    for (int p = 0; p < json.Count; p++)
                    {
                        JsonData     jpost = json[p];
                        BooruAPIPost post  = CreateAPIPost("Konachan");
                        post.SourceURL    = "http://konachan.com/post/show/" + Convert.ToString(jpost["id"]);
                        post.Source       = post.SourceURL;
                        post.Width        = Convert.ToUInt32(Convert.ToString(jpost["width"]));
                        post.Height       = Convert.ToUInt32(Convert.ToString(jpost["height"]));
                        post.ImageURL     = Convert.ToString(jpost["file_url"]);
                        post.SampleURL    = Convert.ToString(jpost["sample_url"]);
                        post.ThumbnailURL = Convert.ToString(jpost["preview_url"]);
                        post.Tags         = GetTagList(Convert.ToString(jpost["tags"]));
                        posts.Add(post);
                    }
                }
                else
                {
                    break;
                }
            }
            if (Tags.Length > MAX_TAGS)
            {
                string[] rest_tags = new string[Tags.Length - MAX_TAGS];
                Array.Copy(Tags, MAX_TAGS, rest_tags, 0, rest_tags.Length);
                CheckForTags(ref posts, rest_tags);
            }
            return(posts);
        }