@vince-gamer/sumire 0.1.0
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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/index.d.mts +90 -0
- package/dist/index.mjs +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-PRESENT Vincent-the-gamer <https://github.com/Vincent-the-gamer>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src=".github/sumire.png" style="height: 105px;" />
|
|
3
|
+
<h1>Sumire 堇</h1>
|
|
4
|
+
<p>Picture sources collection.</p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
8
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
9
|
+
[![bundle][bundle-src]][bundle-href]
|
|
10
|
+
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
11
|
+
[![License][license-src]][license-href]
|
|
12
|
+
|
|
13
|
+
## Supported Websites
|
|
14
|
+
|
|
15
|
+
- [yande.re](https://yande.re)
|
|
16
|
+
- [pixiv.net](https://www.pixiv.net/)
|
|
17
|
+
|
|
18
|
+
and more soon.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
```shell
|
|
22
|
+
npm i @vince-gamer/sumire
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Here are some of examples:
|
|
28
|
+
|
|
29
|
+
### Examples
|
|
30
|
+
|
|
31
|
+
Every main function like `yandere()`, `pixivIllust()` uses sumire config.
|
|
32
|
+
|
|
33
|
+
Sumire universal config type:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
export interface SumireConfig {
|
|
37
|
+
proxy?: {
|
|
38
|
+
protocol: string
|
|
39
|
+
host: string
|
|
40
|
+
port: number
|
|
41
|
+
}
|
|
42
|
+
yandere?: {
|
|
43
|
+
auth?: {
|
|
44
|
+
username?: string
|
|
45
|
+
password?: string
|
|
46
|
+
}
|
|
47
|
+
r18?: boolean
|
|
48
|
+
}
|
|
49
|
+
pixiv?: {
|
|
50
|
+
mode?: 'r18' | 'safe' | 'all'
|
|
51
|
+
phpSessId?: string
|
|
52
|
+
mirror?: string // mirror of i.pximg.net, which will be blocked by referer policy.
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### yande.re
|
|
58
|
+
|
|
59
|
+
**Types**:
|
|
60
|
+
```ts
|
|
61
|
+
export interface Params {
|
|
62
|
+
tags?: string // search keywords
|
|
63
|
+
limit?: number // number of pictures per search
|
|
64
|
+
login?: string // don't pass this value, it will be auto filled if config.auth exists.
|
|
65
|
+
password_hash?: string // don't pass this value, it will be auto filled if config.auth exists.
|
|
66
|
+
api_version?: number // api_version, default 2
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Function:**
|
|
71
|
+
```ts
|
|
72
|
+
import { yandere } from '@vince-gamer/sumire'
|
|
73
|
+
|
|
74
|
+
const a = await yandere(
|
|
75
|
+
{
|
|
76
|
+
tags: 'persona'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
proxy: {
|
|
80
|
+
protocol: 'http',
|
|
81
|
+
host: '127.0.0.1',
|
|
82
|
+
port: 7890
|
|
83
|
+
},
|
|
84
|
+
yandere: {
|
|
85
|
+
r18: true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
console.log(a)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Pixiv
|
|
94
|
+
|
|
95
|
+
> [!IMPORTANT]
|
|
96
|
+
> If you get 404 on request, please login your pixiv account, then add phpSessId config in `config.pixiv`
|
|
97
|
+
|
|
98
|
+
**Types**:
|
|
99
|
+
```ts
|
|
100
|
+
export interface Params {
|
|
101
|
+
tags?: string // search keywords
|
|
102
|
+
limit?: number // number of pictures per search
|
|
103
|
+
login?: string // don't pass this value, it will be auto filled if config.auth exists.
|
|
104
|
+
password_hash?: string // don't pass this value, it will be auto filled if config.auth exists.
|
|
105
|
+
api_version?: number // api_version, default 2
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Function:**
|
|
110
|
+
```ts
|
|
111
|
+
import { pixivDiscovery, pixivIllust } from '@vince-gamer/sumire'
|
|
112
|
+
|
|
113
|
+
// Search illusts with tags and mode
|
|
114
|
+
const a = await pixivDiscovery(
|
|
115
|
+
{
|
|
116
|
+
tags: 'persona',
|
|
117
|
+
limit: 5,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
proxy: {
|
|
121
|
+
protocol: 'http',
|
|
122
|
+
host: '127.0.0.1',
|
|
123
|
+
port: 7890
|
|
124
|
+
},
|
|
125
|
+
pixiv: {
|
|
126
|
+
mode: 'r18',
|
|
127
|
+
phpSessId: 'xxxx' // pass your phpSessId in cookie if you encounter authorization issue.
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
// get the original picture(full resolution) with illust id
|
|
133
|
+
const b = await pixivIllust('129887775', {
|
|
134
|
+
proxy: {
|
|
135
|
+
protocol: 'http',
|
|
136
|
+
host: '127.0.0.1',
|
|
137
|
+
port: 7890
|
|
138
|
+
},
|
|
139
|
+
pixiv: {
|
|
140
|
+
phpSessId: 'xxxx' // pass your phpSessId in cookie if you encounter authorization issue.
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
console.log(b)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
[MIT](./LICENSE) License © 2025-PRESENT [Vincent-the-gamer](https://github.com/Vincent-the-gamer)
|
|
150
|
+
|
|
151
|
+
<!-- Badges -->
|
|
152
|
+
|
|
153
|
+
[npm-version-src]: https://img.shields.io/npm/v/@vince-gamer/sumire?style=flat&colorA=080f12&colorB=1fa669
|
|
154
|
+
[npm-version-href]: https://npmjs.com/package/@vince-gamer/sumire
|
|
155
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@vince-gamer/sumire?style=flat&colorA=080f12&colorB=1fa669
|
|
156
|
+
[npm-downloads-href]: https://npmjs.com/package/@vince-gamer/sumire
|
|
157
|
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@vince-gamer/sumire?style=flat&colorA=080f12&colorB=1fa669&label=minzip
|
|
158
|
+
[bundle-href]: https://bundlephobia.com/result?p=@vince-gamer/sumire
|
|
159
|
+
[license-src]: https://img.shields.io/github/license/Vincent-the-gamer/@vince-gamer/sumire.svg?style=flat&colorA=080f12&colorB=1fa669
|
|
160
|
+
[license-href]: https://github.com/Vincent-the-gamer/@vince-gamer/sumire/blob/main/LICENSE
|
|
161
|
+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
162
|
+
[jsdocs-href]: https://www.jsdocs.io/package/@vince-gamer/sumire
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//#region src/types/pixivTypes.d.ts
|
|
2
|
+
interface PixivIllustResponse {
|
|
3
|
+
error: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
body: {
|
|
6
|
+
urls: {
|
|
7
|
+
thumb_mini: string;
|
|
8
|
+
small: string;
|
|
9
|
+
regular: string;
|
|
10
|
+
original: string;
|
|
11
|
+
};
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
interface PixivFollowingResponse {
|
|
17
|
+
error: boolean;
|
|
18
|
+
body: {
|
|
19
|
+
users: {
|
|
20
|
+
userId: string;
|
|
21
|
+
userName: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface PixivUserProfileResponse {
|
|
26
|
+
error: boolean;
|
|
27
|
+
body: {
|
|
28
|
+
illusts: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface PixivResponse {
|
|
34
|
+
error: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
body: {
|
|
37
|
+
illusts: {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
url: string;
|
|
41
|
+
tags: string[];
|
|
42
|
+
userId: string;
|
|
43
|
+
userName: string;
|
|
44
|
+
xRestrict: number;
|
|
45
|
+
createDate: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/types/index.d.ts
|
|
51
|
+
interface SumireConfig {
|
|
52
|
+
proxy?: {
|
|
53
|
+
protocol: string;
|
|
54
|
+
host: string;
|
|
55
|
+
port: number;
|
|
56
|
+
};
|
|
57
|
+
yandere?: {
|
|
58
|
+
auth?: {
|
|
59
|
+
username?: string;
|
|
60
|
+
password?: string;
|
|
61
|
+
};
|
|
62
|
+
r18?: boolean;
|
|
63
|
+
};
|
|
64
|
+
pixiv?: {
|
|
65
|
+
mode?: 'r18' | 'safe' | 'all';
|
|
66
|
+
phpSessId?: string;
|
|
67
|
+
mirror?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/core/pixiv.d.ts
|
|
72
|
+
interface Params$1 {
|
|
73
|
+
tags?: string;
|
|
74
|
+
mode?: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
}
|
|
77
|
+
declare function pixivDiscovery(params: Params$1, config?: SumireConfig): Promise<PixivResponse | null>;
|
|
78
|
+
declare function pixivIllust(artworkId: string, config?: SumireConfig): Promise<Record<string, any> | null>;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/core/yandere.d.ts
|
|
81
|
+
interface Params {
|
|
82
|
+
tags?: string;
|
|
83
|
+
limit?: number;
|
|
84
|
+
login?: string;
|
|
85
|
+
password_hash?: string;
|
|
86
|
+
api_version?: number;
|
|
87
|
+
}
|
|
88
|
+
declare function yandere(params: Partial<Params>, config?: SumireConfig): Promise<Record<string, any>>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { Params, PixivFollowingResponse, PixivIllustResponse, PixivResponse, PixivUserProfileResponse, SumireConfig, pixivDiscovery, pixivIllust, yandere };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"axios";import{consola as t}from"consola";import{createHash as n}from"node:crypto";const r=t.withTag(`fast-dirpy`);function i(e){return e[Math.floor(Math.random()*e.length)]}const a=[`Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10`,`Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1`,`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36`,`Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36`,`Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36`];function o(){return i(a)}async function s(t,n){let i=t.tags||``;i&&(t.tags=i),n?.pixiv?.mode&&(t.mode=n.pixiv.mode);try{let{data:r}=await e({url:`https://www.pixiv.net/ajax/illust/discovery`,method:`get`,params:t,proxy:n?.proxy,headers:{"User-Agent":o(),Referer:`https://www.pixiv.net/`,Cookie:n?.pixiv?.phpSessId?`PHPSESSID=${n.pixiv.phpSessId}`:void 0}});return r}catch(e){return r.error(`Fetch Pixiv Discovery metadata failed!${e}`),null}}async function c(t,n){let i=`https://www.pixiv.net/ajax/illust/${t}/pages`;try{let{data:t}=await e({url:i,method:`get`,params:{},proxy:n?.proxy,headers:{"User-Agent":o(),Referer:`https://www.pixiv.net/`,Cookie:n?.pixiv?.phpSessId?`PHPSESSID=${n.pixiv.phpSessId}`:void 0}}),r=t,a=r.body[0].urls;if(n?.pixiv?.mirror)for(let[e,t]of Object.entries(a))a[e]=t.replace(`i.pximg.net`,n.pixiv.mirror);return r.body[0].urls=a,r}catch(e){return r.error(`Connot fetch original picture link: ${e}`),null}}function l(e){let t=`choujin-steiner--${e}--`,r=n(`sha1`);return r.update(t),r.digest(`hex`)}async function u(t,n){if(t.api_version||=2,n?.yandere){let{auth:e,r18:r}=n.yandere;e&&(t.login=e.username,t.password_hash=l(e.password));let i=t.tags;r?t.tags=`rating:explicit ${i}`:t.tags=`rating:safe ${i}`}let{data:r}=await e({method:`get`,url:`https://yande.re/post.json`,params:t,proxy:n?.proxy});return r}export{s as pixivDiscovery,c as pixivIllust,u as yandere};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vince-gamer/sumire",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Picture sources collection.",
|
|
6
|
+
"author": "Vincent-the-gamer",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/Vincent-the-gamer/sumire#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Vincent-the-gamer/sumire.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Vincent-the-gamer/sumire/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"registry": "https://registry.npmjs.com",
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.cjs",
|
|
29
|
+
"module": "dist/index.mjs",
|
|
30
|
+
"types": "dist/index.d.mts",
|
|
31
|
+
"typesVersions": {
|
|
32
|
+
"*": {
|
|
33
|
+
".": [
|
|
34
|
+
"./dist/index.d.mts"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"*.d.ts",
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^1.13.2",
|
|
44
|
+
"consola": "^3.4.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@antfu/eslint-config": "^6.2.0",
|
|
48
|
+
"@types/node": "^24.10.1",
|
|
49
|
+
"eslint": "^9.39.1",
|
|
50
|
+
"taze": "^19.9.0",
|
|
51
|
+
"tsdown": "^0.16.6",
|
|
52
|
+
"tsx": "^4.20.6",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"vitest": "^4.0.13"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"dev": "tsx",
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"test": "vitest",
|
|
60
|
+
"dep": "taze major -I",
|
|
61
|
+
"lint:fix": "eslint . --fix"
|
|
62
|
+
}
|
|
63
|
+
}
|