booru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,101 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Booru
3
+ module API
4
+ module Pool
5
+
6
+ # List pools: This action searches and retrieves a list of pools. If you
7
+ # don't specify any parameters you'll get a list of all pools.
8
+ #
9
+ # options - The Hash used to refine the selection (default: {}):
10
+ # :query - The title (optional).
11
+ # :page - The page (optional).
12
+ def list_pools(options = {})
13
+ base_url = '/pool/index'
14
+ query = query_string(base_url, options)
15
+ parse(get(query))
16
+ end
17
+
18
+ # List Posts: This action retrieves a list of posts in a specified
19
+ # pool. If you don't specify any parameters you'll get a list of all
20
+ # pools.
21
+ #
22
+ # options - The Hash used to refine the selection (default: {}):
23
+ # :id - The pool id number (optional).
24
+ # :page - The page (optional).
25
+ def list_pool_posts(options = {})
26
+ base_url = '/pool/show'
27
+ query = query_string(base_url, options)
28
+ parse(get(query))
29
+ end
30
+
31
+ # Update: This action modifies a pool's attributes
32
+ #
33
+ # options - The Hash used to refine the selection (default: {}):
34
+ # :id - The pool id number.
35
+ # :pool[name] - The name.
36
+ # :pool[is_public] - 1 or 0, whether or not the pool is
37
+ # public.
38
+ # :pool[description] - A description of the pool.
39
+ def update_pool(options = {})
40
+ base_url = '/pool/update'
41
+ query = query_string(base_url, options)
42
+ parse(post(query))
43
+ end
44
+
45
+ # Create: This action creates a pool with the specified attributes
46
+ #
47
+ # options - The Hash used to refine the selection (default: {}):
48
+ # :pool[name] - The name.
49
+ # :pool[is_public] - 1 or 0, whether or not the pool is
50
+ # public.
51
+ # :pool[description] - A description of the pool.
52
+ def create_pool(options = {})
53
+ base_url = '/pool/create'
54
+ query = query_string(base_url, options)
55
+ parse(post(query))
56
+ end
57
+
58
+ # Destroy: This action deletes a pool
59
+ #
60
+ # options - The Hash used to refine the selection (default: {}):
61
+ # :id - The pool id number.
62
+ def destroy_pool(options = {})
63
+ base_url = '/pool/destroy'
64
+ query = query_string(base_url, options)
65
+ parse(post(query))
66
+ end
67
+
68
+ alias_method :delete_pool, :destroy_pool
69
+
70
+ # Add Post: This action adds a post to the specified pool
71
+ #
72
+ # options - The Hash used to refine the selection (default: {}):
73
+ # :pool_id - The pool to add the post to.
74
+ # :post_id - The post to add.
75
+ #
76
+ # Potential error reasons: "Post already exists", "access denied"
77
+ def add_pool_post(options = {})
78
+ base_url = '/pool/add_post'
79
+ query = query_string(base_url, options)
80
+ parse(post(query))
81
+ end
82
+
83
+ alias_method :add_post_to_pool, :add_pool_post
84
+
85
+ # Remove Post: This action remove a post from the specified pool
86
+ #
87
+ # options - The Hash used to refine the selection (default: {}):
88
+ # :pool_id - The pool to remove the post from.
89
+ # :post_id - The post to remove.
90
+ #
91
+ # Potential error reasons: "access denied"
92
+ def remove_pool_post(options = {})
93
+ base_url = '/pool/remove_post'
94
+ query = query_string(base_url, options)
95
+ parse(post(query))
96
+ end
97
+
98
+ alias_method :remove_post_from_pool, :remove_pool_post
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,153 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Booru
3
+ module API
4
+ module Post
5
+
6
+ # List: This action retrieves a list of posts
7
+ #
8
+ # options - The Hash used to refine the selection (default: {}):
9
+ # :limit - How many posts you want to retrieve. There is a
10
+ # hard limit of 100 posts per request
11
+ # (default: 100).
12
+ # :page - The page number (default: 1).
13
+ # :tags - The tags to search for. Any tag combination that
14
+ # works on the web site will work here. This
15
+ # includes all the meta-tags.
16
+ def list_posts(options = {})
17
+ base_url = '/post/index'
18
+ defaults = {:limit => 100, :page => 1}
19
+ options = defaults.merge(options)
20
+
21
+ query = query_string(base_url, options)
22
+ parse(get(query))
23
+ end
24
+
25
+ # Create: This action creates a post
26
+ #
27
+ # There are only two mandatory fields: you need to supply the tags,
28
+ # and you need to supply the file, either through a multipart form
29
+ # or through a source URL.
30
+ #
31
+ # options - The Hash used to refine the selection (default: {}):
32
+ # :post[tags] - A space delimited list of tags
33
+ # (optional).
34
+ # :post[file] - The file data encoded as a
35
+ # multipart form (optional).
36
+ # :post[rating] - The rating for the post
37
+ # (optional).
38
+ # Can be: safe, questionable, or
39
+ # explicit.
40
+ # :post[source] - If this is a URL, Danbooru will
41
+ # download the file (optional).
42
+ # :post[is_rating_locked] - Set to true to prevent others
43
+ # from changing the rating
44
+ # (optional).
45
+ # :post[is_note_locked] - Set to true to prevent others
46
+ # from adding notes (optional).
47
+ # :post[parent_id] - The ID of the parent post
48
+ # (optional).
49
+ # :md5 - Supply an MD5 if you want
50
+ # Danbooru to verify the file
51
+ # after uploading it. If the MD5
52
+ # doesn't match, the post is
53
+ # destroyed (optional).
54
+ #
55
+ # If the call fails, the following response reasons are possible:
56
+ # MD5 mismatch: This means you supplied an MD5 parameter and what
57
+ # Danbooru got doesn't match. Try uploading the file
58
+ # again.
59
+ # duplicate: This post already exists in Danbooru (based on the
60
+ # MD5 hash). An additional attribute called location
61
+ # will be set, pointing to the (relative) URL of the
62
+ # original post.
63
+ # other: Any other error will print its error message.
64
+ #
65
+ # If the post upload succeeded, you'll get an attribute called
66
+ # location in the response pointing to the relative URL of your
67
+ # newly uploaded post.
68
+ def create_post(options = {})
69
+ base_url = '/post/create'
70
+ query = query_string(base_url, options)
71
+ parse(post(query))
72
+ end
73
+
74
+ # Update: This action updates a post's attributes
75
+ #
76
+ # Only the id parameter is required. Leave the other parameters blank
77
+ # if you don't want to change them.
78
+ #
79
+ # options - The Hash used to refine the selection (default: {}):
80
+ # :id - The id number of the post to
81
+ # update.
82
+ # :post[tags] - A space delimited list of tags
83
+ # (optional).
84
+ # :post[file] - The file data encoded as a
85
+ # multipart form (optional).
86
+ # :post[rating] - The rating for the post
87
+ # (optional).
88
+ # Can be: safe, questionable, or
89
+ # explicit.
90
+ # :post[source] - If this is a URL, Danbooru will
91
+ # download the file (optional).
92
+ # :post[is_rating_locked] - Set to true to prevent others
93
+ # from changing the rating
94
+ # (optional).
95
+ # :post[is_note_locked] - Set to true to prevent others
96
+ # from adding notes (optional).
97
+ # :post[parent_id] - The ID of the parent post
98
+ # (optional).
99
+ def update_post(options = {})
100
+ base_url = '/post/update'
101
+ query = query_string(base_url, options)
102
+ parse(post(query))
103
+ end
104
+
105
+ # Destroy: This action lets you delete a post.
106
+ #
107
+ # options - The Hash used to refine the selection (default: {}):
108
+ # :id - The id number of the post to delete.
109
+ #
110
+ # You must be logged in to use this action. You must also be the
111
+ # user who uploaded the post (or you must be a moderator).
112
+ def destroy_post(options = {})
113
+ base_url = '/post/destroy'
114
+ query = query_string(base_url, options)
115
+ parse(post(query))
116
+ end
117
+
118
+ alias_method :delete_post, :destroy_post
119
+
120
+ # Revert Tags: This action reverts a post to a previous set of tags.
121
+ #
122
+ # options - The Hash used to refine the selection (default: {}):
123
+ # :id - The post id number to update.
124
+ # :history_id - The id number of the tag history.
125
+ def revert_post_tags(options = {})
126
+ base_url = '/post/revert_tags'
127
+ query = query_string(base_url, options)
128
+ parse(post(query))
129
+ end
130
+
131
+ alias_method :revert_post, :revert_post_tags
132
+
133
+ # Vote: This action lets you vote for a post. You can only vote
134
+ # once per post per IP address.
135
+ #
136
+ # options - The Hash used to refine the selection (default: {}):
137
+ # :id - The post id number to update.
138
+ # :score - Set to 1 to vote up and -1 to vote down. All
139
+ # other values will be ignored.
140
+ #
141
+ # If the call did not succeed, the following reasons are possible:
142
+ # Already voted: You have already voted for this post.
143
+ # Invalid score: You have supplied an invalid score.
144
+ def post_vote(options = {})
145
+ base_url = '/post/vote'
146
+ query = query_string(base_url, options)
147
+ parse(post(query))
148
+ end
149
+
150
+ alias_method :vote_on_post, :post_vote
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,57 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Booru
3
+ module API
4
+ module Tag
5
+
6
+ # List: This action retrieves a list of tags
7
+ # TODO optional/required args
8
+ #
9
+ # options - The Hash used to refine the selection (default: {}):
10
+ # :limit - How many tags to retrieve. Setting this
11
+ # to 0 will return every tag.
12
+ # :page - The page number.
13
+ # :order - Can be date, count, or name.
14
+ # :id - The id number of the tag.
15
+ # :after_id - Return all tags that have an id number
16
+ # greater than this.
17
+ # :name - The exact name of the tag.
18
+ # :name_pattern - Search for any tag that has this
19
+ # parameter in its name.
20
+ def list_tags(options = {})
21
+ base_url = '/tag/index'
22
+ query = query_string(base_url, options)
23
+ parse(get(query))
24
+ end
25
+
26
+ # Update: This action modifies a specified tag
27
+ # TODO optional/required args
28
+ #
29
+ # options - The Hash used to refine the selection (default: {}):
30
+ # :name - The name of the tag to update.
31
+ # :tag[tag_type] - The tag type. General: 0, artist: 1,
32
+ # copyright: 3, character: 4.
33
+ # :tag[is_ambiguous] - Whether or not this tag is
34
+ # ambiguous. Use 1 for true.
35
+ def update_tag(options = {})
36
+ base_url = '/tag/update'
37
+ query = query_string(base_url, options)
38
+ parse(post(query))
39
+ end
40
+
41
+ # Related: This action retrieves a list of related tags
42
+ # TODO optional/required args
43
+ #
44
+ # options - The Hash used to refine the selection (default: {}):
45
+ # :tags - The tag names to query.
46
+ # :type - Restrict results to this tag type (can be
47
+ # general, artist, copyright, or character).
48
+ def list_related_tags(options = {})
49
+ base_url = 'tag/related'
50
+ query = query_string(base_url, options)
51
+ parse(get(query))
52
+ end
53
+
54
+ alias_method :related_tags, :list_related_tags
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Booru
3
+ module API
4
+ module User
5
+
6
+ # Search: This action retrieves a user
7
+ #
8
+ # If you don't specify any parameters you'll get a listing of all
9
+ # users.
10
+ #
11
+ # options - The Hash used to refine the selection (default: {}):
12
+ # :id - The id number of the user (optional).
13
+ # :name - The name of the user (optional).
14
+ def search_users(options = {})
15
+ base_url = '/user/index'
16
+ query = query_string(base_url, options)
17
+ parse(get(query))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,136 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Booru
3
+ module API
4
+ module Wiki
5
+
6
+ # List: This action retrieves a list of wiki pages.
7
+ #
8
+ # options - The Hash used to refine the selection (default: {}):
9
+ # :order - How you want the pages ordered. Can be: title,
10
+ # date.
11
+ # :limit - The number of pages to retrieve.
12
+ # :page - The page number.
13
+ # :query - A word or phrase to search for.
14
+ def list_wiki_pages(options = {})
15
+ base_url = '/wiki/index'
16
+ query = query_string(base_url, options)
17
+ parse(get(query))
18
+ end
19
+
20
+ # Create: This action creates a wiki page
21
+ #
22
+ # options - The Hash used to refine the selection (default: {}):
23
+ # :wiki_page[title] - The title of the wiki page.
24
+ # :wiki_page[body] - The body of the wiki page.
25
+ #
26
+ # Title must be exact (but case and whitespace don't matter).
27
+ def create_wiki_page(options = {})
28
+ base_url = '/wiki/create'
29
+ query = query_string(base_url, options)
30
+ parse(post(query))
31
+ end
32
+
33
+ # Update: This action updates a wiki page
34
+ #
35
+ # Title must be exact (but case and whitespace don't matter).
36
+ #
37
+ # options - The Hash used to refine the selection (default: {}):
38
+ # :title - The title of the wiki page to update.
39
+ # :wiki_page[title] - The new title of the wiki page.
40
+ # :wiki_page[body] - The new body of the wiki page.
41
+ #
42
+ # Potential error reasons: "Page is locked"
43
+ def update_wiki_page(options = {})
44
+ base_url = '/wiki/update'
45
+ query = query_string(base_url, options)
46
+ parse(post(query))
47
+ end
48
+
49
+ # Show: This action retrieves a wiki page
50
+ #
51
+ # Title must be exact (but case and whitespace don't matter).
52
+ #
53
+ # options - The Hash used to refine the selection (default: {}):
54
+ # :title - The title of the wiki page to retrieve.
55
+ # :version - The version of the page to retrieve.
56
+ #
57
+ # Potential error reasons: "artist type"
58
+ def show_wiki_page(options = {})
59
+ base_url = '/wiki/show'
60
+ query = query_string(base_url, options)
61
+ parse(get(query))
62
+ end
63
+
64
+ # Destroy: This action deletes a wiki page
65
+ #
66
+ # Title must be exact (but case and whitespace don't matter).
67
+ #
68
+ # options - The Hash used to refine the selection (default: {}):
69
+ # :title - The title of the page to delete.
70
+ #
71
+ # You must be logged in as a moderator to use this action.
72
+ def destroy_wiki_page(options = {})
73
+ base_url = '/wiki/destroy'
74
+ query = query_string(base_url, options)
75
+ parse(post(query))
76
+ end
77
+
78
+ alias_method :delete_wiki_page, :destroy_wiki_page
79
+
80
+ # Lock: This action locks a wiki page from being updated
81
+ #
82
+ # Title must be exact (but case and whitespace don't matter).
83
+ #
84
+ # options - The Hash used to refine the selection (default: {}):
85
+ # :title - The title of the page to lock.
86
+ #
87
+ # You must be logged in as a moderator to use this action.
88
+ def lock_wiki_page(options = {})
89
+ base_url = '/wiki/lock'
90
+ query = query_string(base_url, options)
91
+ parse(post(query))
92
+ end
93
+
94
+ # Unlock: This action unlocks a wiki page for updating
95
+ #
96
+ # Title must be exact (but case and whitespace don't matter).
97
+ #
98
+ # options - The Hash used to refine the selection (default: {}):
99
+ # :title - The title of the page to unlock.
100
+ #
101
+ # You must be logged in as a moderator to use this action.
102
+ def unlock_wiki_page(options = {})
103
+ base_url = '/wiki/unlock'
104
+ query = query_string(base_url, options)
105
+ parse(post(query))
106
+ end
107
+
108
+ # Revert: This action reverts a wiki page to a previous version
109
+ #
110
+ # Title must be exact (but case and whitespace don't matter).
111
+ #
112
+ # options - The Hash used to refine the selection (default: {}):
113
+ # :title - The title of the wiki page to update.
114
+ # :version - The version to revert to.
115
+ #
116
+ # Potential error reasons: "Page is locked"
117
+ def revert_wiki_page(options = {})
118
+ base_url = '/wiki/revert'
119
+ query = query_string(base_url, options)
120
+ parse(post(query))
121
+ end
122
+
123
+ # History: This action retrieves versions of the specified wiki page
124
+ #
125
+ # Title must be exact (but case and whitespace don't matter).
126
+ #
127
+ # options - The Hash used to refine the selection (default: {}):
128
+ # :title - The title of the wiki page to retrieve history.
129
+ def wiki_page_history(options = {})
130
+ base_url = '/wiki/history'
131
+ query = query_string(base_url, options)
132
+ parse(get(query))
133
+ end
134
+ end
135
+ end
136
+ end