e621 1.0.9 → 2.0.0-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.node-version +1 -0
- package/README.md +116 -187
- package/build/package.json +14 -11
- package/build/src/index.d.ts +28 -295
- package/build/src/index.js +83 -442
- package/build/src/modules/Pools.d.ts +120 -0
- package/build/src/modules/Pools.js +247 -0
- package/build/src/modules/PostSets.d.ts +88 -0
- package/build/src/modules/PostSets.js +182 -0
- package/build/src/modules/Posts.d.ts +124 -0
- package/build/src/modules/Posts.js +323 -0
- package/build/src/modules/UserFeedback.d.ts +66 -0
- package/build/src/modules/UserFeedback.js +134 -0
- package/build/src/modules/Users.d.ts +110 -0
- package/build/src/modules/Users.js +248 -0
- package/build/src/modules/WikiPages.d.ts +99 -0
- package/build/src/modules/WikiPages.js +208 -0
- package/build/src/structures/AuthenticatedUser.d.ts +109 -0
- package/build/src/structures/AuthenticatedUser.js +128 -0
- package/build/src/structures/Pool.d.ts +85 -0
- package/build/src/structures/Pool.js +110 -0
- package/build/src/structures/PoolHistory.d.ts +42 -0
- package/build/src/structures/PoolHistory.js +53 -0
- package/build/src/structures/Post.d.ts +147 -0
- package/build/src/structures/Post.js +155 -0
- package/build/src/structures/PostHistory.d.ts +52 -0
- package/build/src/structures/PostHistory.js +93 -0
- package/build/src/structures/PostSet.d.ts +71 -0
- package/build/src/structures/PostSet.js +91 -0
- package/build/src/structures/User.d.ts +62 -0
- package/build/src/structures/User.js +80 -0
- package/build/src/structures/WikiPage.d.ts +16 -0
- package/build/src/structures/WikiPage.js +26 -0
- package/build/src/structures/WikiPageHistory.d.ts +37 -0
- package/build/src/structures/WikiPageHistory.js +49 -0
- package/build/src/types/index.d.ts +92 -0
- package/build/src/types/pools.d.ts +60 -0
- package/build/src/types/post_sets.d.ts +33 -0
- package/build/src/types/posts.d.ts +165 -0
- package/build/src/types/user_feedback.d.ts +27 -0
- package/build/src/types/users.d.ts +277 -0
- package/build/src/types/wiki_pages.d.ts +65 -0
- package/build/src/util/FormHelper.d.ts +9 -0
- package/build/src/util/FormHelper.js +15 -0
- package/build/src/util/MultipartData.d.ts +7 -0
- package/build/src/util/MultipartData.js +39 -0
- package/build/src/util/RequestHandler.d.ts +37 -0
- package/build/src/util/RequestHandler.js +311 -0
- package/package.json +14 -11
- package/LICENSE +0 -21
package/.node-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16.13.0
|
package/README.md
CHANGED
|
@@ -1,195 +1,124 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# E621
|
|
2
|
+
|
|
3
|
+
The most comprehensive wrapper for e621 you'll ever find.
|
|
4
|
+
|
|
5
|
+
We support almost anything normal users can do, with plans to bring everything else in, and more later in development.
|
|
6
|
+
|
|
7
|
+
### Features:
|
|
8
|
+
- [x] Creating Posts (Buffer & URL)
|
|
9
|
+
- [x] Listing/Creating/Editing/Voting On/Favoriting Posts
|
|
10
|
+
- [x] Listing/Creating/Editing/Deleting/Modifying/Adding To/Removing From Post Sets
|
|
11
|
+
- [x] Listing/Creating/Editing/Deleting/Modifying/Adding To/Removing From Pools
|
|
12
|
+
- [x] Listing/Creating/Deleting/Editing User Feedback
|
|
13
|
+
- [x] Reverting Pool Changes
|
|
14
|
+
- [x] Listing Post History
|
|
15
|
+
- [x] Editing The Authenticated User (all properties minus password and email)
|
|
16
|
+
- [ ] Deleting/Approving/Unapproving/Destroying Posts
|
|
17
|
+
- [ ] Creating/Solving/Deleting Post Flags
|
|
18
|
+
- [ ] Listing/Creating/Editing/Deleting/Modifying Wiki Pages
|
|
19
|
+
- [ ] Listing/Creating/Editing/Deleting/Modifying Artists
|
|
20
|
+
- [ ] Listing/Editing/Deleting/Modifying Tags
|
|
21
|
+
- [ ] General Janitorial/Moderative/Admninistrative Actions
|
|
22
|
+
- [ ] More Planned!
|
|
23
|
+
|
|
24
|
+
### Not Planned:
|
|
25
|
+
- Dmails (routes do not support json, and I'm not scraping html)
|
|
3
26
|
|
|
4
|
-
[](https://npm.im/e621)
|
|
5
27
|
<hr>
|
|
6
28
|
|
|
7
|
-
|
|
8
|
-
|
|
29
|
+
This module is structures with submodules corresponding to separate areas of the site. All of these modules are on the primary class, which can be constructed like so:
|
|
30
|
+
```typescript
|
|
31
|
+
import E621 from "e621"; // or const E621 = require("e621");
|
|
9
32
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// For regular javascript usage, switch out this for `const E621 = require("e621");
|
|
13
|
-
import E621 from "e621";
|
|
14
|
-
/**
|
|
15
|
-
* Construct an instance of E621
|
|
16
|
-
*
|
|
17
|
-
* @param {string} [username] - your e621 username to use for requests
|
|
18
|
-
* @param {string} [apiKey] - an api key to use for requests
|
|
19
|
-
* @param {string[]} [blacklist=[]] - a list of tags to use to filter out posts
|
|
20
|
-
* @param {string }[userAgent] - A user agent to use for requests
|
|
21
|
-
* @param {boolean} [fixNullURLs=true] - If null urls should be converted to proper urls
|
|
22
|
-
* @param {string} [baseDomain=this.baseDomain] - The domain to use for api requests
|
|
23
|
-
* @param {boolean} [setHost=false] - If we should set the Host header on requests to e621.net (useful for proxies).
|
|
24
|
-
* @example new E621();
|
|
25
|
-
* @example new E621("YourUsername", "YourAPIKey");
|
|
26
|
-
* @example new E621("YourUsername", "YourAPIKey", ["male/male"]);
|
|
27
|
-
* @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0");
|
|
28
|
-
* @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false);
|
|
29
|
-
* @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false, "mye621.local");
|
|
30
|
-
* @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false, "mye621.local", false);
|
|
31
|
-
*/
|
|
32
|
-
const e = new E621();
|
|
33
|
+
// no options are required, see below for the options
|
|
34
|
+
const e621 = new E621();
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @returns {Promise<(Post | NullableURLPost)[]>}
|
|
40
|
-
* @example getPosts()
|
|
41
|
-
* @example getPosts("male bulge");
|
|
42
|
-
* @example getPosts(["male", "bulge"]);
|
|
43
|
-
* @example getPosts(["male", "bulge"], 5);
|
|
44
|
-
* @example getPosts(["male", "bulge"], 5, 1);
|
|
45
|
-
*/
|
|
46
|
-
e.getPosts(["male/male"]).then(console.log) // array of posts, see Post Structure
|
|
36
|
+
// the options are all an object in the first parameter, e.g.
|
|
37
|
+
const e621 = new E621({
|
|
38
|
+
authUser: "",
|
|
39
|
+
authKey: ""
|
|
40
|
+
});
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @param {number} id - The id of the post to get
|
|
51
|
-
* @returns {Promise<(Post | NullableURLPost)>}
|
|
52
|
-
* @example getPostById(1391357)
|
|
53
|
-
*/
|
|
54
|
-
e.getPostById(1391357).then(console.log) // single post, see Post Structure
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get a specifc post from e621, by id
|
|
58
|
-
* @param {number} id - The id of the post to get
|
|
59
|
-
* @returns {Promise<(Post | NullableURLPost)>}
|
|
60
|
-
* @example getPostById(1391357)
|
|
61
|
-
*/
|
|
62
|
-
e.getPostByMD5("6fd0b0f2237543bfeee5ca9318a97b46").then(console.log) // single post, see Post Structure
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Edit Post
|
|
66
|
-
This is mostly untested, but should work
|
|
67
|
-
```ts
|
|
68
|
-
import E621 from "e621";
|
|
69
|
-
// both username & apikey are required for edits!
|
|
70
|
-
const e = new E621("YourUsername", "YourAPIKey");
|
|
71
|
-
|
|
72
|
-
// they all return a post, see Post Structure
|
|
73
|
-
// if no reason is provided, "Edit via https://npm.im/e621" will be used.
|
|
74
|
-
|
|
75
|
-
// add tag
|
|
76
|
-
e.editPost(1022094, "Some Reason Here", "added_tag");
|
|
77
|
-
|
|
78
|
-
// remove tag (notice the minus)
|
|
79
|
-
e.editPost(1022094, "Some Reason Here", "-remove_tag");
|
|
80
|
-
|
|
81
|
-
// the undefined parts are REQUIRED if you are not using the previous parameters
|
|
82
|
-
|
|
83
|
-
// add source
|
|
84
|
-
e.editPost(1022094, "Some Reason Here", undefined, "https://some.added/source");
|
|
85
|
-
|
|
86
|
-
// remove source (notice the minus)
|
|
87
|
-
e.editPost(1022094, "Some Reason Here", undefined, "-https://some.removed/source");
|
|
88
|
-
|
|
89
|
-
// update parent id
|
|
90
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, 1097929);
|
|
91
|
-
|
|
92
|
-
// set description
|
|
93
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, undefined, "My Amazing Post Description");
|
|
94
|
-
|
|
95
|
-
// set rating - s: safe, q: questionable, e: explicit
|
|
96
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, undefined, undefined, "e");
|
|
97
|
-
|
|
98
|
-
// set rating locked
|
|
99
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, undefined, undefined, undefined, true);
|
|
100
|
-
|
|
101
|
-
// set note locked
|
|
102
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, undefined, undefined, undefined, undefined, false);
|
|
103
|
-
|
|
104
|
-
// set has embedded notes
|
|
105
|
-
e.editPost(1022094, "Some Reason Here", undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);
|
|
42
|
+
// all of the available modules stem from this main class,
|
|
43
|
+
// e.g. use e621.posts.METHOD(), e621.users.METHOD()
|
|
106
44
|
```
|
|
107
45
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
approver_id: number | null;
|
|
188
|
-
uploader_id: number | null;
|
|
189
|
-
description: string;
|
|
190
|
-
comment_count: number;
|
|
191
|
-
is_favorited: boolean;
|
|
192
|
-
has_notes: boolean;
|
|
193
|
-
duration: number | null;
|
|
194
|
-
}
|
|
195
|
-
```
|
|
46
|
+
#### Options
|
|
47
|
+
Most of these options shouldn't be used unless you know what you're doing (you probably only need `authUser` and `authKey`, and you can set `userAgent`)
|
|
48
|
+
| Option | Type | Default | Description |
|
|
49
|
+
|:---:|:---:|:---:|:---:|
|
|
50
|
+
| `authUser` | String | None | User for authentication |
|
|
51
|
+
| `authKey` | String | None | Token for authentication |
|
|
52
|
+
| `userAgent` | String | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L57-L59) | UserAgent for requests |
|
|
53
|
+
| `reconstructStaticURL` | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/util/RequestHandler.ts#L254-L256) | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L63-L65) | Override default url reconstruction |
|
|
54
|
+
| `imageReconstructionType` | "e621" \| "yiffy" \| "local" \| null | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L39) | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L41) |
|
|
55
|
+
| `instanceSSL` | Boolean | true | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L03) |
|
|
56
|
+
| `instancePort` | Number | 443 | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L9) |
|
|
57
|
+
| `instanceHost` | String | e621.net | [See Code](https://github.com/DonovanDMC/E621/blob/89d662f19dc76c77e28f40b18a96f9043c4e2a3a/src/types/index.d.ts#L15) |
|
|
58
|
+
|
|
59
|
+
A map of features we support to their methods is listed below.
|
|
60
|
+
|
|
61
|
+
## Methods
|
|
62
|
+
The legend for the symbols can be found after the table.
|
|
63
|
+
| Section | Description | Location |
|
|
64
|
+
|:---:|:---:|:---:|
|
|
65
|
+
| Pools | Get Pool | `pools.get` |
|
|
66
|
+
| Pools | Get Pool By Name | `pools.getByName` |
|
|
67
|
+
| Pools | Search Pools | `pools.search` |
|
|
68
|
+
| Pools | Create Pool* | `pools.create` |
|
|
69
|
+
| Pools | Modify Pool* | `pools.modify` |
|
|
70
|
+
| Pools | Delete Pool^ | `pools.delete` |
|
|
71
|
+
| Pools | Revert Pool* | `pools.revert` |
|
|
72
|
+
| Pools | Search Pool History | `pools.searchHistory` |
|
|
73
|
+
| Pools | Add Post To Pool | `pools.addPost` |
|
|
74
|
+
| Pools | Remove Post From Pool | `pools.removePost` |
|
|
75
|
+
| Type | Description | Location |
|
|
76
|
+
| Posts | Get Post By ID | `posts.get` |
|
|
77
|
+
| Posts | Get Post By MD5 | `posts.getByMD5` |
|
|
78
|
+
| Posts | Search Posts | `posts.search` |
|
|
79
|
+
| Posts | Create Post* | `posts.create` |
|
|
80
|
+
| Posts | Modify Post* | `posts.modify` |
|
|
81
|
+
| Posts | Vote On Post* | `posts.vote` |
|
|
82
|
+
| Posts | Revert Post* | `posts.revert` |
|
|
83
|
+
| Posts | Search Post History | `posts.searchHistory` |
|
|
84
|
+
| Type | Description | Location |
|
|
85
|
+
| Post Sets | Get Post Set | `postSets.get` |
|
|
86
|
+
| Post Sets | Search Sets | `postSets.search` |
|
|
87
|
+
| Post Sets | Create Post Set* | `postSets.create` |
|
|
88
|
+
| Post Sets | Modify Post Set* | `postSets.modify` |
|
|
89
|
+
| Post Sets | Delete Post Set* | `postSets.delete` |
|
|
90
|
+
| Post Sets | Add Post To Set* | `postSets.addPost` |
|
|
91
|
+
| Post Sets | Remove Post From Set* | `postSets.removePost` |
|
|
92
|
+
| Type | Description | Location |
|
|
93
|
+
| User Feedback | Get Feedback | `userFeedback.get` |
|
|
94
|
+
| User Feedback | Search Feedback | `userFeedback.search` |
|
|
95
|
+
| User Feedback | Create Feedback# | `userFeedback.create` |
|
|
96
|
+
| User Feedback | Modify Feedback# | `userFeedback.modify` |
|
|
97
|
+
| User Feedback | Delete Feedback# | `userFeedback.delete` |
|
|
98
|
+
| Type | Description | Location |
|
|
99
|
+
| Users | Get User (ID/Name) | `users.get` |
|
|
100
|
+
| Users | Search Users | `users.search` |
|
|
101
|
+
| Users | Get Authenticated User* | `users.getSelf` |
|
|
102
|
+
| Users | Edit Authenticated User* | `users.editSelf` |
|
|
103
|
+
| Users | Get Upload Limit* | `users.getUploadLimit` |
|
|
104
|
+
| Users | Get Favorites | `users.getFavorites` |
|
|
105
|
+
| Users | Add Favorite* | `users.addFavorite` |
|
|
106
|
+
| Users | Remove Favorite* | `users.removeFavorite` |
|
|
107
|
+
| Type | Description | Location |
|
|
108
|
+
| Wiki Page | Get Wiki Page | `wikiPages.get` |
|
|
109
|
+
| Wiki Page | Get Wiki Page (By Name) | `wikiPages.getByName` |
|
|
110
|
+
| Wiki Page | Search Wiki Pages | `wikiPages.search` |
|
|
111
|
+
| Wiki Page | Create Wiki Page* | `wikiPages.create` |
|
|
112
|
+
| Wiki Page | Modify Wiki Page* | `wikiPages.modify` |
|
|
113
|
+
| Wiki Page | Delete Wiki Page^ | `wikiPages.delete` |
|
|
114
|
+
| Wiki Page | Revert Wiki Page* | `wikiPages.revert` |
|
|
115
|
+
| Wiki Page | Search Wiki Page History | `wikiPages.searchHistory` |
|
|
116
|
+
|
|
117
|
+
#### Method Symbol Legend
|
|
118
|
+
| Symbol | Meaning |
|
|
119
|
+
|:------:|:-----------------------:|
|
|
120
|
+
| * | Requires Authentication |
|
|
121
|
+
| $ | Requires Privileged |
|
|
122
|
+
| ^ | Requires Janitor |
|
|
123
|
+
| # | Requires Moderator |
|
|
124
|
+
| & | Requires Admin |
|
package/build/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "e621",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A module for
|
|
3
|
+
"version": "2.0.0-dev.11",
|
|
4
|
+
"description": "A module for interfacing with e621.",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
|
-
"types": "build/src/index.d.ts",
|
|
7
6
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"build": "rm -rf build && tsc -p tsc.json && sed -i '/__exportStar(require(\".\\/types\"), exports);/d' build/src/index.js && cp -r src/types build/src",
|
|
8
|
+
"prepublishOnly": "npm run build",
|
|
9
|
+
"dev": "npm publish --tag dev"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -14,20 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"e621",
|
|
17
|
-
"api",
|
|
18
17
|
"e621-api",
|
|
18
|
+
"api",
|
|
19
19
|
"e926",
|
|
20
|
-
"e926-api"
|
|
20
|
+
"e926-api",
|
|
21
|
+
"e6",
|
|
22
|
+
"e9"
|
|
21
23
|
],
|
|
22
|
-
"author": "
|
|
24
|
+
"author": "Donovan Daniels <hewwo@yiff.rocks>",
|
|
23
25
|
"license": "MIT",
|
|
24
26
|
"bugs": {
|
|
25
27
|
"url": "https://github.com/DonovanDMC/E621/issues"
|
|
26
28
|
},
|
|
27
29
|
"homepage": "https://github.com/DonovanDMC/E621#readme",
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@uwu-codes/
|
|
31
|
-
"
|
|
31
|
+
"@uwu-codes/eslint-config": "^1.0.25",
|
|
32
|
+
"@uwu-codes/tsconfig": "^1.0.1",
|
|
33
|
+
"ts-node": "^10.3.0",
|
|
34
|
+
"typescript": "^4.4.4"
|
|
32
35
|
}
|
|
33
36
|
}
|