narou 1.2.0 → 2.0.1
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 +73 -37
- package/dist/index.browser.cjs +90 -1360
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +14 -20
- package/dist/index.browser.d.mts +49 -0
- package/dist/index.browser.mjs +68 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.cjs +147 -1410
- package/dist/index.cjs.map +1 -1
- package/dist/index.common-8lS2K_1Y.mjs +1166 -0
- package/dist/index.common-8lS2K_1Y.mjs.map +1 -0
- package/dist/index.common-CYj0n0aU.cjs +1346 -0
- package/dist/index.common-CYj0n0aU.cjs.map +1 -0
- package/dist/index.d.cts +28 -21
- package/dist/index.d.mts +63 -0
- package/dist/index.mjs +128 -0
- package/dist/index.mjs.map +1 -0
- package/dist/user-search-BY6FdEe7.d.cts +1394 -0
- package/dist/user-search-Besgk-Hx.d.mts +1394 -0
- package/package.json +28 -37
- package/pnpm-lock.yaml +1325 -1100
- package/src/index.browser.ts +5 -1
- package/src/index.ts +5 -1
- package/src/narou-fetch.ts +4 -3
- package/src/narou-jsonp.ts +4 -2
- package/src/narou.ts +50 -13
- package/src/params.ts +1 -1
- package/src/ranking.ts +20 -11
- package/src/search-builder-r18.ts +6 -2
- package/src/search-builder.ts +7 -3
- package/src/user-search.ts +9 -2
- package/dist/chunk-3A5MHPWL.js +0 -37
- package/dist/chunk-3A5MHPWL.js.map +0 -1
- package/dist/chunk-4ZP5YNWI.js +0 -1
- package/dist/chunk-4ZP5YNWI.js.map +0 -1
- package/dist/chunk-5UDKQCPJ.js +0 -407
- package/dist/chunk-5UDKQCPJ.js.map +0 -1
- package/dist/chunk-6BZWV4ZC.js +0 -75
- package/dist/chunk-6BZWV4ZC.js.map +0 -1
- package/dist/chunk-BQLSW236.js +0 -117
- package/dist/chunk-BQLSW236.js.map +0 -1
- package/dist/chunk-DEQICAN3.js +0 -94
- package/dist/chunk-DEQICAN3.js.map +0 -1
- package/dist/chunk-E2H3AJSQ.js +0 -57
- package/dist/chunk-E2H3AJSQ.js.map +0 -1
- package/dist/chunk-HOBLKBZ6.js +0 -452
- package/dist/chunk-HOBLKBZ6.js.map +0 -1
- package/dist/chunk-IPDEGCWU.js +0 -39
- package/dist/chunk-IPDEGCWU.js.map +0 -1
- package/dist/chunk-LQLNWSWV.js +0 -26
- package/dist/chunk-LQLNWSWV.js.map +0 -1
- package/dist/chunk-PLEM2AOH.js +0 -44
- package/dist/chunk-PLEM2AOH.js.map +0 -1
- package/dist/chunk-RNHRR56W.js +0 -25
- package/dist/chunk-RNHRR56W.js.map +0 -1
- package/dist/chunk-VUZIISP2.js +0 -23
- package/dist/chunk-VUZIISP2.js.map +0 -1
- package/dist/chunk-VZVUANDN.js +0 -17
- package/dist/chunk-VZVUANDN.js.map +0 -1
- package/dist/index.browser.d.ts +0 -55
- package/dist/index.browser.js +0 -126
- package/dist/index.browser.js.map +0 -1
- package/dist/index.common.cjs +0 -1187
- package/dist/index.common.cjs.map +0 -1
- package/dist/index.common.d.cts +0 -6
- package/dist/index.common.d.ts +0 -6
- package/dist/index.common.js +0 -76
- package/dist/index.common.js.map +0 -1
- package/dist/index.d.ts +0 -56
- package/dist/index.js +0 -131
- package/dist/index.js.map +0 -1
- package/dist/narou-DBa12V_l.d.ts +0 -404
- package/dist/narou-DCp4aGfA.d.cts +0 -404
- package/dist/narou-fetch.cjs +0 -164
- package/dist/narou-fetch.cjs.map +0 -1
- package/dist/narou-fetch.d.cts +0 -20
- package/dist/narou-fetch.d.ts +0 -20
- package/dist/narou-fetch.js +0 -10
- package/dist/narou-fetch.js.map +0 -1
- package/dist/narou-jsonp.cjs +0 -162
- package/dist/narou-jsonp.cjs.map +0 -1
- package/dist/narou-jsonp.d.cts +0 -13
- package/dist/narou-jsonp.d.ts +0 -13
- package/dist/narou-jsonp.js +0 -10
- package/dist/narou-jsonp.js.map +0 -1
- package/dist/narou-ranking-results.cjs +0 -19
- package/dist/narou-ranking-results.cjs.map +0 -1
- package/dist/narou-ranking-results.d.cts +0 -4
- package/dist/narou-ranking-results.d.ts +0 -4
- package/dist/narou-ranking-results.js +0 -1
- package/dist/narou-ranking-results.js.map +0 -1
- package/dist/narou-search-results-C21hWrnL.d.cts +0 -727
- package/dist/narou-search-results-DT0YdaBn.d.ts +0 -727
- package/dist/narou-search-results.cjs +0 -62
- package/dist/narou-search-results.cjs.map +0 -1
- package/dist/narou-search-results.d.cts +0 -2
- package/dist/narou-search-results.d.ts +0 -2
- package/dist/narou-search-results.js +0 -11
- package/dist/narou-search-results.js.map +0 -1
- package/dist/narou.cjs +0 -112
- package/dist/narou.cjs.map +0 -1
- package/dist/narou.d.cts +0 -4
- package/dist/narou.d.ts +0 -4
- package/dist/narou.js +0 -8
- package/dist/narou.js.map +0 -1
- package/dist/params.cjs +0 -448
- package/dist/params.cjs.map +0 -1
- package/dist/params.d.cts +0 -2
- package/dist/params.d.ts +0 -2
- package/dist/params.js +0 -41
- package/dist/params.js.map +0 -1
- package/dist/ranking-history.cjs +0 -47
- package/dist/ranking-history.cjs.map +0 -1
- package/dist/ranking-history.d.cts +0 -28
- package/dist/ranking-history.d.ts +0 -28
- package/dist/ranking-history.js +0 -8
- package/dist/ranking-history.js.map +0 -1
- package/dist/ranking.cjs +0 -783
- package/dist/ranking.cjs.map +0 -1
- package/dist/ranking.d.cts +0 -108
- package/dist/ranking.d.ts +0 -108
- package/dist/ranking.js +0 -10
- package/dist/ranking.js.map +0 -1
- package/dist/search-builder-r18.cjs +0 -547
- package/dist/search-builder-r18.cjs.map +0 -1
- package/dist/search-builder-r18.d.cts +0 -45
- package/dist/search-builder-r18.d.ts +0 -45
- package/dist/search-builder-r18.js +0 -9
- package/dist/search-builder-r18.js.map +0 -1
- package/dist/search-builder.cjs +0 -591
- package/dist/search-builder.cjs.map +0 -1
- package/dist/search-builder.d.cts +0 -4
- package/dist/search-builder.d.ts +0 -4
- package/dist/search-builder.js +0 -12
- package/dist/search-builder.js.map +0 -1
- package/dist/user-search.cjs +0 -325
- package/dist/user-search.cjs.map +0 -1
- package/dist/user-search.d.cts +0 -66
- package/dist/user-search.d.ts +0 -66
- package/dist/user-search.js +0 -9
- package/dist/user-search.js.map +0 -1
- package/dist/util/date.cjs +0 -51
- package/dist/util/date.cjs.map +0 -1
- package/dist/util/date.d.cts +0 -21
- package/dist/util/date.d.ts +0 -21
- package/dist/util/date.js +0 -11
- package/dist/util/date.js.map +0 -1
- package/dist/util/jsonp.cjs +0 -63
- package/dist/util/jsonp.cjs.map +0 -1
- package/dist/util/jsonp.d.cts +0 -49
- package/dist/util/jsonp.d.ts +0 -49
- package/dist/util/jsonp.js +0 -7
- package/dist/util/jsonp.js.map +0 -1
- package/dist/util/type.cjs +0 -19
- package/dist/util/type.cjs.map +0 -1
- package/dist/util/type.d.cts +0 -27
- package/dist/util/type.d.ts +0 -27
- package/dist/util/type.js +0 -1
- package/dist/util/type.js.map +0 -1
- package/dist/util/unzipp.cjs +0 -47
- package/dist/util/unzipp.cjs.map +0 -1
- package/dist/util/unzipp.d.cts +0 -12
- package/dist/util/unzipp.d.ts +0 -12
- package/dist/util/unzipp.js +0 -7
- package/dist/util/unzipp.js.map +0 -1
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
//#region src/narou-search-results.ts
|
|
2
|
+
/**
|
|
3
|
+
* なろう小説API検索結果
|
|
4
|
+
*/
|
|
5
|
+
var NarouSearchResults = class {
|
|
6
|
+
/**
|
|
7
|
+
* @constractor
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
constructor([header, ...result], params) {
|
|
11
|
+
const count$1 = header.allcount;
|
|
12
|
+
const limit = params.lim ?? 20;
|
|
13
|
+
const start = params.st ?? 0;
|
|
14
|
+
this.allcount = count$1;
|
|
15
|
+
this.limit = limit;
|
|
16
|
+
this.start = start;
|
|
17
|
+
this.page = start / limit;
|
|
18
|
+
this.length = result.length;
|
|
19
|
+
this.values = result;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* noveltype/novel_typeの値ヘルパー
|
|
24
|
+
*/
|
|
25
|
+
const NovelType = {
|
|
26
|
+
Rensai: 1,
|
|
27
|
+
Tanpen: 2
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* endの値ヘルパー
|
|
31
|
+
*/
|
|
32
|
+
const End = {
|
|
33
|
+
KanketsuOrTanpen: 0,
|
|
34
|
+
Rensai: 1
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/narou.ts
|
|
39
|
+
/**
|
|
40
|
+
* なろう小説APIへのリクエストを実行する
|
|
41
|
+
* @class NarouNovel
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
var NarouNovel = class {
|
|
45
|
+
/**
|
|
46
|
+
* APIへの検索リクエストを実行する
|
|
47
|
+
* @param params クエリパラメータ
|
|
48
|
+
* @param endpoint APIエンドポイント
|
|
49
|
+
* @returns 検索結果
|
|
50
|
+
*/
|
|
51
|
+
async executeSearch(params, endpoint = "https://api.syosetu.com/novelapi/api/", options) {
|
|
52
|
+
return new NarouSearchResults(await this.execute(params, endpoint, options), params);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 小説APIへの検索リクエストを実行する
|
|
56
|
+
* @param params クエリパラメータ
|
|
57
|
+
* @returns 検索結果
|
|
58
|
+
* @see https://dev.syosetu.com/man/api/
|
|
59
|
+
*/
|
|
60
|
+
async executeNovel(params, options) {
|
|
61
|
+
return await this.executeSearch(params, "https://api.syosetu.com/novelapi/api/", options);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* R18小説APIへの検索リクエストを実行する
|
|
65
|
+
* @param params クエリパラメータ
|
|
66
|
+
* @returns 検索結果
|
|
67
|
+
* @see https://dev.syosetu.com/xman/api/
|
|
68
|
+
*/
|
|
69
|
+
async executeNovel18(params, options) {
|
|
70
|
+
return await this.executeSearch(params, "https://api.syosetu.com/novel18api/api/", options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* ランキングAPIへのリクエストを実行する
|
|
74
|
+
* @param params クエリパラメータ
|
|
75
|
+
* @returns ランキング結果
|
|
76
|
+
* @see https://dev.syosetu.com/man/rankapi/
|
|
77
|
+
*/
|
|
78
|
+
async executeRanking(params, options) {
|
|
79
|
+
return await this.execute(params, "https://api.syosetu.com/rank/rankget/", options);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 殿堂入りAPiへのリクエストを実行する
|
|
83
|
+
* @param params クエリパラメータ
|
|
84
|
+
* @param options 実行オプション
|
|
85
|
+
* @returns ランキング履歴結果
|
|
86
|
+
* @see https://dev.syosetu.com/man/rankinapi/
|
|
87
|
+
*/
|
|
88
|
+
async executeRankingHistory(params, options) {
|
|
89
|
+
return await this.execute(params, "https://api.syosetu.com/rank/rankin/", options);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* ユーザー検索APIへのリクエストを実行する
|
|
93
|
+
* @param params クエリパラメータ
|
|
94
|
+
* @returns 検索結果
|
|
95
|
+
* @see https://dev.syosetu.com/man/userapi/
|
|
96
|
+
*/
|
|
97
|
+
async executeUserSearch(params, options) {
|
|
98
|
+
return new NarouSearchResults(await this.execute(params, "https://api.syosetu.com/userapi/api/", options), params);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/util/jsonp.ts
|
|
104
|
+
/**
|
|
105
|
+
* MIT license
|
|
106
|
+
*/
|
|
107
|
+
let count = 0;
|
|
108
|
+
const noop = function() {};
|
|
109
|
+
/**
|
|
110
|
+
* JSONPリクエストを実行してデータを取得します。
|
|
111
|
+
*
|
|
112
|
+
* @param url - リクエスト先のURL
|
|
113
|
+
* @param options - JSONP呼び出しのオプション設定
|
|
114
|
+
* @returns JSONPリクエストの結果をPromiseで返します
|
|
115
|
+
* @throws {Error} タイムアウトが発生した場合、"Timeout"メッセージのエラーをスローします
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // 基本的な使用方法
|
|
120
|
+
* const data = await jsonp<ResponseType>('https://example.com/api');
|
|
121
|
+
*
|
|
122
|
+
* // オプション指定
|
|
123
|
+
* const data = await jsonp<ResponseType>('https://example.com/api', {
|
|
124
|
+
* prefix: 'customPrefix',
|
|
125
|
+
* param: 'callbackParam',
|
|
126
|
+
* timeout: 10000
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
function jsonp(url, { prefix = "__jp", param = "callback", timeout = 15e3 } = {}) {
|
|
131
|
+
return new Promise(function(resolve, reject) {
|
|
132
|
+
const targetChild = document.getElementsByTagName("script").item(0);
|
|
133
|
+
const target = targetChild?.parentNode ?? document.head;
|
|
134
|
+
const id = `${prefix}${count++}`;
|
|
135
|
+
const cleanup = function() {
|
|
136
|
+
if (script && script.parentNode) script.parentNode.removeChild(script);
|
|
137
|
+
window[id] = noop;
|
|
138
|
+
if (timer) clearTimeout(timer);
|
|
139
|
+
};
|
|
140
|
+
const timer = timeout > 0 ? setTimeout(() => {
|
|
141
|
+
cleanup();
|
|
142
|
+
reject(/* @__PURE__ */ new Error("Timeout"));
|
|
143
|
+
}, timeout) : void 0;
|
|
144
|
+
const callback = (data) => {
|
|
145
|
+
cleanup();
|
|
146
|
+
resolve(data);
|
|
147
|
+
};
|
|
148
|
+
window[id] = callback;
|
|
149
|
+
const script = document.createElement("script");
|
|
150
|
+
const urlObj = new URL(url);
|
|
151
|
+
urlObj.searchParams.set(param, id);
|
|
152
|
+
script.setAttribute("src", urlObj.toString());
|
|
153
|
+
target.insertBefore(script, targetChild);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/narou-jsonp.ts
|
|
159
|
+
/**
|
|
160
|
+
* なろう小説APIへのリクエストを実行する
|
|
161
|
+
*/
|
|
162
|
+
var NarouNovelJsonp = class extends NarouNovel {
|
|
163
|
+
async execute(params, endpoint, _options) {
|
|
164
|
+
const query = {
|
|
165
|
+
...params,
|
|
166
|
+
out: "jsonp"
|
|
167
|
+
};
|
|
168
|
+
query.gzip = 0;
|
|
169
|
+
const url = new URL(endpoint);
|
|
170
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
171
|
+
if (value !== void 0) url.searchParams.append(key, value.toString());
|
|
172
|
+
});
|
|
173
|
+
return await jsonp(url.toString());
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/params.ts
|
|
179
|
+
const RankingType = {
|
|
180
|
+
Daily: "d",
|
|
181
|
+
Weekly: "w",
|
|
182
|
+
Monthly: "m",
|
|
183
|
+
Quarterly: "q"
|
|
184
|
+
};
|
|
185
|
+
const BooleanNumber = {
|
|
186
|
+
True: 1,
|
|
187
|
+
False: 0
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* なろう小説APIのofパラメータに指定できる出力する項目
|
|
191
|
+
* @see https://dev.syosetu.com/man/api/#output
|
|
192
|
+
*/
|
|
193
|
+
const Fields = {
|
|
194
|
+
title: "t",
|
|
195
|
+
ncode: "n",
|
|
196
|
+
userid: "u",
|
|
197
|
+
writer: "w",
|
|
198
|
+
story: "s",
|
|
199
|
+
biggenre: "bg",
|
|
200
|
+
genre: "g",
|
|
201
|
+
keyword: "k",
|
|
202
|
+
general_firstup: "gf",
|
|
203
|
+
general_lastup: "gl",
|
|
204
|
+
noveltype: "nt",
|
|
205
|
+
end: "e",
|
|
206
|
+
general_all_no: "ga",
|
|
207
|
+
length: "l",
|
|
208
|
+
time: "ti",
|
|
209
|
+
isstop: "i",
|
|
210
|
+
isr15: "isr",
|
|
211
|
+
isbl: "ibl",
|
|
212
|
+
isgl: "igl",
|
|
213
|
+
iszankoku: "izk",
|
|
214
|
+
istensei: "its",
|
|
215
|
+
istenni: "iti",
|
|
216
|
+
global_point: "gp",
|
|
217
|
+
daily_point: "dp",
|
|
218
|
+
weekly_point: "wp",
|
|
219
|
+
monthly_point: "mp",
|
|
220
|
+
quarter_point: "qp",
|
|
221
|
+
yearly_point: "yp",
|
|
222
|
+
fav_novel_cnt: "f",
|
|
223
|
+
impression_cnt: "imp",
|
|
224
|
+
review_cnt: "r",
|
|
225
|
+
all_point: "a",
|
|
226
|
+
all_hyoka_cnt: "ah",
|
|
227
|
+
sasie_cnt: "sa",
|
|
228
|
+
kaiwaritu: "ka",
|
|
229
|
+
novelupdated_at: "nu",
|
|
230
|
+
updated_at: "ua"
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* なろうR18小説APIのofパラメータに指定できる出力する項目
|
|
234
|
+
* @see https://dev.syosetu.com/xman/api/#output
|
|
235
|
+
*/
|
|
236
|
+
const R18Fields = {
|
|
237
|
+
title: "t",
|
|
238
|
+
ncode: "n",
|
|
239
|
+
userid: "u",
|
|
240
|
+
writer: "w",
|
|
241
|
+
story: "s",
|
|
242
|
+
nocgenre: "ng",
|
|
243
|
+
keyword: "k",
|
|
244
|
+
general_firstup: "gf",
|
|
245
|
+
general_lastup: "gl",
|
|
246
|
+
noveltype: "nt",
|
|
247
|
+
end: "e",
|
|
248
|
+
general_all_no: "ga",
|
|
249
|
+
length: "l",
|
|
250
|
+
time: "ti",
|
|
251
|
+
isstop: "i",
|
|
252
|
+
isbl: "ibl",
|
|
253
|
+
isgl: "igl",
|
|
254
|
+
iszankoku: "izk",
|
|
255
|
+
istensei: "its",
|
|
256
|
+
istenni: "iti",
|
|
257
|
+
global_point: "gp",
|
|
258
|
+
daily_point: "dp",
|
|
259
|
+
weekly_point: "wp",
|
|
260
|
+
monthly_point: "mp",
|
|
261
|
+
quarter_point: "qp",
|
|
262
|
+
yearly_point: "yp",
|
|
263
|
+
fav_novel_cnt: "f",
|
|
264
|
+
impression_cnt: "imp",
|
|
265
|
+
review_cnt: "r",
|
|
266
|
+
all_point: "a",
|
|
267
|
+
all_hyoka_cnt: "ah",
|
|
268
|
+
sasie_cnt: "sa",
|
|
269
|
+
kaiwaritu: "ka",
|
|
270
|
+
novelupdated_at: "nu",
|
|
271
|
+
updated_at: "ua"
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* オプション項目
|
|
275
|
+
*/
|
|
276
|
+
const OptionalFields = { weekly_unique: "weekly" };
|
|
277
|
+
/**
|
|
278
|
+
* ユーザ検索APIのofパラメータに指定できる出力する項目
|
|
279
|
+
* @see https://dev.syosetu.com/man/userapi/#output
|
|
280
|
+
*/
|
|
281
|
+
const UserFields = {
|
|
282
|
+
userid: "u",
|
|
283
|
+
name: "n",
|
|
284
|
+
yomikata: "y",
|
|
285
|
+
name1st: "1",
|
|
286
|
+
novel_cnt: "nc",
|
|
287
|
+
review_cnt: "rc",
|
|
288
|
+
novel_length: "nl",
|
|
289
|
+
sum_global_point: "sg"
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* 出力順序
|
|
293
|
+
*/
|
|
294
|
+
const Order = {
|
|
295
|
+
FavoriteNovelCount: "favnovelcnt",
|
|
296
|
+
ReviewCount: "reviewcnt",
|
|
297
|
+
HyokaDesc: "hyoka",
|
|
298
|
+
HyokaAsc: "hyokaasc",
|
|
299
|
+
ImpressionCount: "impressioncnt",
|
|
300
|
+
HyokaCountDesc: "hyokacnt",
|
|
301
|
+
HyokaCountAsc: "hyokacntasc",
|
|
302
|
+
Weekly: "weekly",
|
|
303
|
+
LengthDesc: "lengthdesc",
|
|
304
|
+
LengthAsc: "lengthasc",
|
|
305
|
+
NCodeDesc: "ncodedesc",
|
|
306
|
+
New: "new",
|
|
307
|
+
Old: "old",
|
|
308
|
+
DailyPoint: "dailypoint",
|
|
309
|
+
WeeklyPoint: "weeklypoint",
|
|
310
|
+
MonthlyPoint: "monthlypoint",
|
|
311
|
+
QuarterPoint: "quarterpoint",
|
|
312
|
+
YearlyPoint: "yearlypoint",
|
|
313
|
+
GeneralFirstUp: "generalfirstup"
|
|
314
|
+
};
|
|
315
|
+
/** R18掲載サイト */
|
|
316
|
+
const R18Site = {
|
|
317
|
+
Nocturne: 1,
|
|
318
|
+
MoonLight: 2,
|
|
319
|
+
MoonLightBL: 3,
|
|
320
|
+
Midnight: 4
|
|
321
|
+
};
|
|
322
|
+
/** R18掲載サイト表記ヘルパー */
|
|
323
|
+
const R18SiteNotation = {
|
|
324
|
+
[R18Site.Nocturne]: "ノクターンノベルズ(男性向け)",
|
|
325
|
+
[R18Site.MoonLight]: "ムーンライトノベルズ(女性向け)",
|
|
326
|
+
[R18Site.MoonLightBL]: "ムーンライトノベルズ(BL)",
|
|
327
|
+
[R18Site.Midnight]: "ミッドナイトノベルズ(大人向け)"
|
|
328
|
+
};
|
|
329
|
+
/** 大ジャンル */
|
|
330
|
+
const BigGenre = {
|
|
331
|
+
Renai: 1,
|
|
332
|
+
Fantasy: 2,
|
|
333
|
+
Bungei: 3,
|
|
334
|
+
Sf: 4,
|
|
335
|
+
Sonota: 99,
|
|
336
|
+
NonGenre: 98
|
|
337
|
+
};
|
|
338
|
+
/** 大ジャンル表記ヘルパー */
|
|
339
|
+
const BigGenreNotation = {
|
|
340
|
+
[BigGenre.Renai]: "恋愛",
|
|
341
|
+
[BigGenre.Fantasy]: "ファンタジー",
|
|
342
|
+
[BigGenre.Bungei]: "文芸",
|
|
343
|
+
[BigGenre.Sf]: "SF",
|
|
344
|
+
[BigGenre.Sonota]: "その他",
|
|
345
|
+
[BigGenre.NonGenre]: "ノンジャンル"
|
|
346
|
+
};
|
|
347
|
+
/** ジャンル */
|
|
348
|
+
const Genre = {
|
|
349
|
+
RenaiIsekai: 101,
|
|
350
|
+
RenaiGenjitsusekai: 102,
|
|
351
|
+
FantasyHigh: 201,
|
|
352
|
+
FantasyLow: 202,
|
|
353
|
+
BungeiJyunbungei: 301,
|
|
354
|
+
BungeiHumanDrama: 302,
|
|
355
|
+
BungeiHistory: 303,
|
|
356
|
+
BungeiSuiri: 304,
|
|
357
|
+
BungeiHorror: 305,
|
|
358
|
+
BungeiAction: 306,
|
|
359
|
+
BungeiComedy: 307,
|
|
360
|
+
SfVrgame: 401,
|
|
361
|
+
SfSpace: 402,
|
|
362
|
+
SfKuusoukagaku: 403,
|
|
363
|
+
SfPanic: 404,
|
|
364
|
+
SonotaDouwa: 9901,
|
|
365
|
+
SonotaShi: 9902,
|
|
366
|
+
SonotaEssei: 9903,
|
|
367
|
+
SonotaReplay: 9904,
|
|
368
|
+
SonotaSonota: 9999,
|
|
369
|
+
NonGenre: 9801
|
|
370
|
+
};
|
|
371
|
+
/** ジャンル表記ヘルパー */
|
|
372
|
+
const GenreNotation = {
|
|
373
|
+
[Genre.RenaiIsekai]: "異世界〔恋愛〕",
|
|
374
|
+
[Genre.RenaiGenjitsusekai]: "現実世界〔恋愛〕",
|
|
375
|
+
[Genre.FantasyHigh]: "ハイファンタジー〔ファンタジー〕",
|
|
376
|
+
[Genre.FantasyLow]: "ローファンタジー〔ファンタジー〕",
|
|
377
|
+
[Genre.BungeiJyunbungei]: "純文学〔文芸〕",
|
|
378
|
+
[Genre.BungeiHumanDrama]: "ヒューマンドラマ〔文芸〕",
|
|
379
|
+
[Genre.BungeiHistory]: "歴史〔文芸〕",
|
|
380
|
+
[Genre.BungeiSuiri]: "推理〔文芸〕",
|
|
381
|
+
[Genre.BungeiHorror]: "ホラー〔文芸〕",
|
|
382
|
+
[Genre.BungeiAction]: "アクション〔文芸〕",
|
|
383
|
+
[Genre.BungeiComedy]: "コメディー〔文芸〕",
|
|
384
|
+
[Genre.SfVrgame]: "VRゲーム〔SF〕",
|
|
385
|
+
[Genre.SfSpace]: "宇宙〔SF〕",
|
|
386
|
+
[Genre.SfKuusoukagaku]: "空想科学〔SF〕",
|
|
387
|
+
[Genre.SfPanic]: "パニック〔SF〕",
|
|
388
|
+
[Genre.SonotaDouwa]: "童話〔その他〕",
|
|
389
|
+
[Genre.SonotaShi]: "詩〔その他〕",
|
|
390
|
+
[Genre.SonotaEssei]: "エッセイ〔その他〕",
|
|
391
|
+
[Genre.SonotaReplay]: "リプレイ〔その他〕",
|
|
392
|
+
[Genre.SonotaSonota]: "その他〔その他〕",
|
|
393
|
+
[Genre.NonGenre]: "ノンジャンル〔ノンジャンル〕"
|
|
394
|
+
};
|
|
395
|
+
/** 文体指定 */
|
|
396
|
+
const BuntaiParam = {
|
|
397
|
+
NoJisageKaigyouOoi: 1,
|
|
398
|
+
NoJisageKaigyoHutsuu: 2,
|
|
399
|
+
JisageKaigyoOoi: 4,
|
|
400
|
+
JisageKaigyoHutsuu: 6
|
|
401
|
+
};
|
|
402
|
+
/** 連載停止中指定 */
|
|
403
|
+
const StopParam = {
|
|
404
|
+
NoStopping: 1,
|
|
405
|
+
Stopping: 2
|
|
406
|
+
};
|
|
407
|
+
/** 小説タイプ指定 */
|
|
408
|
+
const NovelTypeParam = {
|
|
409
|
+
Short: "t",
|
|
410
|
+
RensaiNow: "r",
|
|
411
|
+
RensaiEnd: "er",
|
|
412
|
+
Rensai: "re",
|
|
413
|
+
ShortAndRensai: "ter"
|
|
414
|
+
};
|
|
415
|
+
/** 日付指定パラメータ */
|
|
416
|
+
const DateParam = {
|
|
417
|
+
ThisWeek: "thisweek",
|
|
418
|
+
LastWeek: "lastweek",
|
|
419
|
+
SevenDays: "sevenday",
|
|
420
|
+
ThisMonth: "thismonth",
|
|
421
|
+
LastMonth: "lastmonth"
|
|
422
|
+
};
|
|
423
|
+
const UserOrder = {
|
|
424
|
+
New: "new",
|
|
425
|
+
NovelCount: "novelcnt",
|
|
426
|
+
ReviewCount: "reviewcnt",
|
|
427
|
+
NovelLength: "novellength",
|
|
428
|
+
SumGlobalPoint: "sumglobalpoint",
|
|
429
|
+
Old: "old"
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/search-builder.ts
|
|
434
|
+
var SearchBuilderBase = class {
|
|
435
|
+
/**
|
|
436
|
+
* constructor
|
|
437
|
+
* @private
|
|
438
|
+
* @param params クエリパラメータ
|
|
439
|
+
* @param api NarouNovel インスタンス
|
|
440
|
+
*/
|
|
441
|
+
constructor(params = {}, api) {
|
|
442
|
+
this.params = params;
|
|
443
|
+
this.api = api;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* 配列から重複を除去する
|
|
447
|
+
* @protected
|
|
448
|
+
* @static
|
|
449
|
+
* @param array 配列
|
|
450
|
+
* @returns 重複を除去した配列
|
|
451
|
+
*/
|
|
452
|
+
static distinct(array) {
|
|
453
|
+
return Array.from(new Set(array));
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 配列をハイフン区切りの文字列に変換する
|
|
457
|
+
* @protected
|
|
458
|
+
* @static
|
|
459
|
+
* @param n 文字列または数値の配列、あるいは単一の文字列または数値
|
|
460
|
+
* @returns ハイフン区切りの文字列
|
|
461
|
+
*/
|
|
462
|
+
static array2string(n) {
|
|
463
|
+
if (Array.isArray(n)) return this.distinct(n).join("-");
|
|
464
|
+
else return n.toString();
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* 取得件数を指定する (lim)
|
|
468
|
+
* @param num 取得件数 (1-500)
|
|
469
|
+
* @return {this}
|
|
470
|
+
*/
|
|
471
|
+
limit(num) {
|
|
472
|
+
this.set({ lim: num });
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* 取得開始位置を指定する (st)
|
|
477
|
+
* @param num 取得開始位置 (1-)
|
|
478
|
+
* @return {this}
|
|
479
|
+
*/
|
|
480
|
+
start(num) {
|
|
481
|
+
this.set({ st: num });
|
|
482
|
+
return this;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* ページ番号と1ページあたりの件数で取得範囲を指定する
|
|
486
|
+
* @param no ページ番号 (0-)
|
|
487
|
+
* @param count 1ページあたりの件数 (デフォルト: 20)
|
|
488
|
+
* @return {this}
|
|
489
|
+
*/
|
|
490
|
+
page(no, count$1 = 20) {
|
|
491
|
+
return this.limit(count$1).start(no * count$1);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* 出力順序を指定する (order)
|
|
495
|
+
* 指定しない場合は新着順となります。
|
|
496
|
+
* @param {TOrder} order 出力順序
|
|
497
|
+
* @return {this}
|
|
498
|
+
*/
|
|
499
|
+
order(order) {
|
|
500
|
+
this.set({ order });
|
|
501
|
+
return this;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* gzip圧縮レベルを指定する (gzip)
|
|
505
|
+
*
|
|
506
|
+
* 転送量上限を減らすためにも推奨
|
|
507
|
+
* @param {GzipLevel} level gzip圧縮レベル(1~5)
|
|
508
|
+
* @return {this}
|
|
509
|
+
*/
|
|
510
|
+
gzip(level) {
|
|
511
|
+
this.set({ gzip: level });
|
|
512
|
+
return this;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* クエリパラメータをセットする
|
|
516
|
+
* @protected
|
|
517
|
+
* @param obj セットするパラメータ
|
|
518
|
+
* @return {this}
|
|
519
|
+
*/
|
|
520
|
+
set(obj) {
|
|
521
|
+
this.params = {
|
|
522
|
+
...this.params,
|
|
523
|
+
...obj
|
|
524
|
+
};
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* クエリパラメータを削除する
|
|
529
|
+
* @protected
|
|
530
|
+
* @param key 削除するパラメータのキー
|
|
531
|
+
* @returns {this}
|
|
532
|
+
*/
|
|
533
|
+
unset(key) {
|
|
534
|
+
delete this.params[key];
|
|
535
|
+
return this;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
var NovelSearchBuilderBase = class NovelSearchBuilderBase extends SearchBuilderBase {
|
|
539
|
+
/**
|
|
540
|
+
* 検索語を指定します (word)。
|
|
541
|
+
* 半角または全角スペースで区切るとAND抽出になります。部分一致でHITします。
|
|
542
|
+
* @param word 検索語
|
|
543
|
+
* @return {this}
|
|
544
|
+
*/
|
|
545
|
+
word(word) {
|
|
546
|
+
this.set({ word });
|
|
547
|
+
return this;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* 除外したい単語を指定します (notword)。
|
|
551
|
+
* スペースで区切ることにより除外する単語を増やせます。部分一致で除外されます。
|
|
552
|
+
* @param word 除外語
|
|
553
|
+
* @return {this}
|
|
554
|
+
*/
|
|
555
|
+
notWord(word) {
|
|
556
|
+
this.set({ notword: word });
|
|
557
|
+
return this;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* 検索対象を作品名に限定するかどうかを指定します (title)。
|
|
561
|
+
* @param bool trueの場合、作品名を検索対象とする (デフォルト: true)
|
|
562
|
+
* @return {this}
|
|
563
|
+
*/
|
|
564
|
+
byTitle(bool = true) {
|
|
565
|
+
this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* 検索対象をあらすじに限定するかどうかを指定します (ex)。
|
|
570
|
+
* @param bool trueの場合、あらすじを検索対象とする (デフォルト: true)
|
|
571
|
+
* @return {this}
|
|
572
|
+
*/
|
|
573
|
+
byOutline(bool = true) {
|
|
574
|
+
this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
575
|
+
return this;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* 検索対象をキーワードに限定するかどうかを指定します (keyword)。
|
|
579
|
+
* @param bool trueの場合、キーワードを検索対象とする (デフォルト: true)
|
|
580
|
+
* @return {this}
|
|
581
|
+
*/
|
|
582
|
+
byKeyword(bool = true) {
|
|
583
|
+
this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
584
|
+
return this;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* 検索対象を作者名に限定するかどうかを指定します (wname)。
|
|
588
|
+
* @param bool trueの場合、作者名を検索対象とする (デフォルト: true)
|
|
589
|
+
* @return {this}
|
|
590
|
+
*/
|
|
591
|
+
byAuthor(bool = true) {
|
|
592
|
+
this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* ボーイズラブ作品を抽出または除外します (isbl/notbl)。
|
|
597
|
+
* @param bool trueの場合、ボーイズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
598
|
+
* @return {this}
|
|
599
|
+
*/
|
|
600
|
+
isBL(bool = true) {
|
|
601
|
+
if (bool) this.set({ isbl: BooleanNumber.True });
|
|
602
|
+
else this.set({ notbl: BooleanNumber.True });
|
|
603
|
+
return this;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* ガールズラブ作品を抽出または除外します (isgl/notgl)。
|
|
607
|
+
* @param bool trueの場合、ガールズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
608
|
+
* @return {this}
|
|
609
|
+
*/
|
|
610
|
+
isGL(bool = true) {
|
|
611
|
+
if (bool) this.set({ isgl: BooleanNumber.True });
|
|
612
|
+
else this.set({ notgl: BooleanNumber.True });
|
|
613
|
+
return this;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* 残酷な描写あり作品を抽出または除外します (iszankoku/notzankoku)。
|
|
617
|
+
* @param bool trueの場合、残酷な描写あり作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
618
|
+
* @return {this}
|
|
619
|
+
*/
|
|
620
|
+
isZankoku(bool = true) {
|
|
621
|
+
if (bool) this.set({ iszankoku: BooleanNumber.True });
|
|
622
|
+
else this.set({ notzankoku: BooleanNumber.True });
|
|
623
|
+
return this;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* 異世界転生作品を抽出または除外します (istensei/nottensei)。
|
|
627
|
+
* @param bool trueの場合、異世界転生作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
628
|
+
* @return {this}
|
|
629
|
+
*/
|
|
630
|
+
isTensei(bool = true) {
|
|
631
|
+
if (bool) this.set({ istensei: BooleanNumber.True });
|
|
632
|
+
else this.set({ nottensei: BooleanNumber.True });
|
|
633
|
+
return this;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* 異世界転移作品を抽出または除外します (istenni/nottenni)。
|
|
637
|
+
* @param bool trueの場合、異世界転移作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
638
|
+
* @return {this}
|
|
639
|
+
*/
|
|
640
|
+
isTenni(bool = true) {
|
|
641
|
+
if (bool) this.set({ istenni: BooleanNumber.True });
|
|
642
|
+
else this.set({ nottenni: BooleanNumber.True });
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* 異世界転生または異世界転移作品を抽出します (istt)。
|
|
647
|
+
* @return {this}
|
|
648
|
+
*/
|
|
649
|
+
isTT() {
|
|
650
|
+
this.set({ istt: BooleanNumber.True });
|
|
651
|
+
return this;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* 抽出する作品の文字数を指定します (length)。
|
|
655
|
+
* 範囲指定する場合は、最小文字数と最大文字数をハイフン(-)記号で区切ってください。
|
|
656
|
+
* @param length 文字数、または[最小文字数, 最大文字数]
|
|
657
|
+
* @return {this}
|
|
658
|
+
*/
|
|
659
|
+
length(length) {
|
|
660
|
+
this.set({ length: NovelSearchBuilderBase.array2string(length) });
|
|
661
|
+
return this;
|
|
662
|
+
}
|
|
663
|
+
kaiwaritu(min, max) {
|
|
664
|
+
let n;
|
|
665
|
+
if (max != null) n = `${min}-${max}`;
|
|
666
|
+
else n = min;
|
|
667
|
+
this.set({ kaiwaritu: n });
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* 抽出する作品の挿絵数を指定します (sasie)。
|
|
672
|
+
* @param num 挿絵数、または[最小挿絵数, 最大挿絵数]
|
|
673
|
+
* @return {this}
|
|
674
|
+
*/
|
|
675
|
+
sasie(num) {
|
|
676
|
+
this.set({ sasie: NovelSearchBuilderBase.array2string(num) });
|
|
677
|
+
return this;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* 抽出する作品の予想読了時間を分単位で指定します (time)。
|
|
681
|
+
* @param num 読了時間(分)、または[最小読了時間, 最大読了時間]
|
|
682
|
+
* @return {this}
|
|
683
|
+
*/
|
|
684
|
+
time(num) {
|
|
685
|
+
this.set({ time: NovelSearchBuilderBase.array2string(num) });
|
|
686
|
+
return this;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Nコードを指定して取得します (ncode)。
|
|
690
|
+
* @param ncodes Nコード、またはNコードの配列
|
|
691
|
+
* @return {this}
|
|
692
|
+
*/
|
|
693
|
+
ncode(ncodes) {
|
|
694
|
+
this.set({ ncode: NovelSearchBuilderBase.array2string(ncodes) });
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 抽出する小説タイプを指定します (type)。
|
|
699
|
+
* @param type 小説タイプ (t: 短編, r: 連載中, er: 完結済連載小説, ter: 短編と完結済連載小説, re: 連載中と完結済連載小説)
|
|
700
|
+
* @return {this}
|
|
701
|
+
*/
|
|
702
|
+
type(type) {
|
|
703
|
+
this.set({ type });
|
|
704
|
+
return this;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* 抽出する作品の文体を指定します (buntai)。
|
|
708
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
709
|
+
* @param buntai 文体コード、または文体コードの配列
|
|
710
|
+
* @return {this}
|
|
711
|
+
*/
|
|
712
|
+
buntai(buntai) {
|
|
713
|
+
this.set({ buntai: NovelSearchBuilderBase.array2string(buntai) });
|
|
714
|
+
return this;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* 連載停止中作品に関する指定をします (stop)。
|
|
718
|
+
* @param bool trueの場合、長期連載停止中のみ取得する (デフォルト: true)。falseの場合、長期連載停止中を除外する。
|
|
719
|
+
* @return {this}
|
|
720
|
+
*/
|
|
721
|
+
isStop(bool = true) {
|
|
722
|
+
this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
|
|
723
|
+
return this;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* ピックアップ作品のみを取得します (ispickup)。
|
|
727
|
+
* @return {this}
|
|
728
|
+
*/
|
|
729
|
+
isPickup() {
|
|
730
|
+
this.set({ ispickup: BooleanNumber.True });
|
|
731
|
+
return this;
|
|
732
|
+
}
|
|
733
|
+
lastUpdate(x, y) {
|
|
734
|
+
let date;
|
|
735
|
+
if (typeof x == "string") date = x;
|
|
736
|
+
else if (x instanceof Date && y instanceof Date) date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(y.getTime() / 1e3)}`;
|
|
737
|
+
else date = `${x}-${y}`;
|
|
738
|
+
this.set({ lastup: date });
|
|
739
|
+
return this;
|
|
740
|
+
}
|
|
741
|
+
lastNovelUpdate(x, y) {
|
|
742
|
+
let date;
|
|
743
|
+
if (typeof x == "string") date = x;
|
|
744
|
+
else if (x instanceof Date && y instanceof Date) date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(y.getTime() / 1e3)}`;
|
|
745
|
+
else date = `${x}-${y}`;
|
|
746
|
+
this.set({ lastupdate: date });
|
|
747
|
+
return this;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* なろう小説APIへの検索リクエストを実行する
|
|
751
|
+
* @param options 実行オプション
|
|
752
|
+
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
753
|
+
*/
|
|
754
|
+
execute(options) {
|
|
755
|
+
return this.api.executeNovel(this.params, options);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* 検索ヘルパー
|
|
760
|
+
* @class SearchBuilder
|
|
761
|
+
*/
|
|
762
|
+
var SearchBuilder = class SearchBuilder extends NovelSearchBuilderBase {
|
|
763
|
+
/**
|
|
764
|
+
* 大ジャンルを指定して取得します (biggenre)。
|
|
765
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
766
|
+
* @param genre 大ジャンルコード、または大ジャンルコードの配列
|
|
767
|
+
* @return {this}
|
|
768
|
+
*/
|
|
769
|
+
bigGenre(genre) {
|
|
770
|
+
this.set({ biggenre: SearchBuilder.array2string(genre) });
|
|
771
|
+
return this;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* 除外したい大ジャンルを指定します (notbiggenre)。
|
|
775
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
776
|
+
* @param genre 除外する大ジャンルコード、または大ジャンルコードの配列
|
|
777
|
+
* @return {this}
|
|
778
|
+
*/
|
|
779
|
+
notBigGenre(genre) {
|
|
780
|
+
this.set({ notbiggenre: SearchBuilder.array2string(genre) });
|
|
781
|
+
return this;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* ジャンルを指定して取得します (genre)。
|
|
785
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
786
|
+
* @param genre ジャンルコード、またはジャンルコードの配列
|
|
787
|
+
* @return {this}
|
|
788
|
+
*/
|
|
789
|
+
genre(genre) {
|
|
790
|
+
this.set({ genre: SearchBuilder.array2string(genre) });
|
|
791
|
+
return this;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* 除外したいジャンルを指定します (notgenre)。
|
|
795
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
796
|
+
* @param genre 除外するジャンルコード、またはジャンルコードの配列
|
|
797
|
+
* @return {this}
|
|
798
|
+
*/
|
|
799
|
+
notGenre(genre) {
|
|
800
|
+
this.set({ notgenre: SearchBuilder.array2string(genre) });
|
|
801
|
+
return this;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* ユーザIDを指定して取得します (userid)。
|
|
805
|
+
* 複数指定する場合はハイフン(-)で区切ってください。
|
|
806
|
+
* @param ids ユーザID、またはユーザIDの配列
|
|
807
|
+
* @return {this}
|
|
808
|
+
*/
|
|
809
|
+
userId(ids) {
|
|
810
|
+
this.set({ userid: SearchBuilder.array2string(ids) });
|
|
811
|
+
return this;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* R15作品を抽出または除外します (isr15/notr15)。
|
|
815
|
+
* @param bool trueの場合、R15作品を抽出する (デフォルト: true)。falseの場合、除外する。
|
|
816
|
+
* @return {this}
|
|
817
|
+
*/
|
|
818
|
+
isR15(bool = true) {
|
|
819
|
+
if (bool) this.set({ isr15: 1 });
|
|
820
|
+
else this.set({ notr15: 1 });
|
|
821
|
+
return this;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* 出力する項目を個別に指定します (of)。
|
|
825
|
+
* 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
|
|
826
|
+
* 複数項目を出力する場合はハイフン(-)記号で区切ってください。
|
|
827
|
+
* @param fields 出力するフィールド名、またはフィールド名の配列
|
|
828
|
+
* @return {SearchBuilder<SearchResultFields<TFields>, TOpt>} 型が更新されたビルダー
|
|
829
|
+
*/
|
|
830
|
+
fields(fields) {
|
|
831
|
+
this.set({ of: SearchBuilder.array2string(fields) });
|
|
832
|
+
return this;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* 出力オプション項目を指定します (opt)。
|
|
836
|
+
* 複数項目を出力する場合はハイフン(-)記号で区切ってください。
|
|
837
|
+
* @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
|
|
838
|
+
* @return {SearchBuilder<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
|
|
839
|
+
*/
|
|
840
|
+
opt(option) {
|
|
841
|
+
this.set({ opt: SearchBuilder.array2string(option) });
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region src/util/date.ts
|
|
848
|
+
/**
|
|
849
|
+
* 文字列の日付(yyyyMMdd形式)をDateオブジェクトに変換する
|
|
850
|
+
* @param dateStr yyyyMMdd形式の日付文字列
|
|
851
|
+
* @returns Dateオブジェクト
|
|
852
|
+
*/
|
|
853
|
+
function parseDate(dateStr) {
|
|
854
|
+
const year = parseInt(dateStr.substring(0, 4), 10);
|
|
855
|
+
const month = parseInt(dateStr.substring(4, 6), 10) - 1;
|
|
856
|
+
const day = parseInt(dateStr.substring(6, 8), 10);
|
|
857
|
+
return new Date(year, month, day, 0, 0, 0, 0);
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* 日付をyyyyMMdd形式の文字列に変換する
|
|
861
|
+
* @param date 日付
|
|
862
|
+
* @returns yyyyMMdd形式の文字列
|
|
863
|
+
*/
|
|
864
|
+
function formatDate(date) {
|
|
865
|
+
return `${date.getFullYear()}${String(date.getMonth() + 1).padStart(2, "0")}${String(date.getDate()).padStart(2, "0")}`;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* 指定された日数を加算した新しい日付を返す
|
|
869
|
+
* @param date 元の日付
|
|
870
|
+
* @param days 加算する日数
|
|
871
|
+
* @returns 新しい日付
|
|
872
|
+
*/
|
|
873
|
+
function addDays(date, days) {
|
|
874
|
+
const result = new Date(date);
|
|
875
|
+
result.setDate(result.getDate() + days);
|
|
876
|
+
return result;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/ranking.ts
|
|
881
|
+
/**
|
|
882
|
+
* なろう小説ランキングAPIのヘルパークラス。
|
|
883
|
+
*
|
|
884
|
+
* ランキング種別や日付を指定してランキングデータを取得します。
|
|
885
|
+
* また、取得したランキングデータに含まれるNコードを元に、
|
|
886
|
+
* なろう小説APIを利用して詳細な小説情報を取得することも可能です。
|
|
887
|
+
*
|
|
888
|
+
* @class RankingBuilder
|
|
889
|
+
* @see https://dev.syosetu.com/man/rankapi/ なろう小説ランキングAPI仕様
|
|
890
|
+
*/
|
|
891
|
+
var RankingBuilder = class {
|
|
892
|
+
/**
|
|
893
|
+
* constructor
|
|
894
|
+
* @param params - 初期クエリパラメータ
|
|
895
|
+
* @param api - API実行クラスのインスタンス
|
|
896
|
+
* @private
|
|
897
|
+
*/
|
|
898
|
+
constructor(params = {}, api) {
|
|
899
|
+
this.params = params;
|
|
900
|
+
this.api = api;
|
|
901
|
+
/**
|
|
902
|
+
* クエリパラメータ
|
|
903
|
+
* @protected
|
|
904
|
+
*/
|
|
905
|
+
this.date$ = addDays(/* @__PURE__ */ new Date(), -1);
|
|
906
|
+
this.type$ = RankingType.Daily;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* ランキング集計対象の日付を指定します。
|
|
910
|
+
*
|
|
911
|
+
* - 日間: 任意の日付
|
|
912
|
+
* - 週間: 火曜日の日付
|
|
913
|
+
* - 月間・四半期: 1日の日付
|
|
914
|
+
*
|
|
915
|
+
* @param date 集計対象の日付
|
|
916
|
+
* @returns {RankingBuilder} this
|
|
917
|
+
* @see https://dev.syosetu.com/man/rankapi/
|
|
918
|
+
*/
|
|
919
|
+
date(date) {
|
|
920
|
+
this.date$ = date;
|
|
921
|
+
return this;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* ランキング種別を指定します。
|
|
925
|
+
* @param type ランキング種別
|
|
926
|
+
* @returns {RankingBuilder} this
|
|
927
|
+
* @see https://dev.syosetu.com/man/rankapi/
|
|
928
|
+
*/
|
|
929
|
+
type(type) {
|
|
930
|
+
this.type$ = type;
|
|
931
|
+
return this;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* gzip圧縮する。
|
|
935
|
+
*
|
|
936
|
+
* 転送量上限を減らすためにも推奨
|
|
937
|
+
* @param {GzipLevel} level gzip圧縮レベル(1~5)
|
|
938
|
+
* @return {RankingBuilder} this
|
|
939
|
+
*/
|
|
940
|
+
gzip(level) {
|
|
941
|
+
this.set({ gzip: level });
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* クエリパラメータを内部的にセットします。
|
|
946
|
+
* @param obj - セットするパラメータオブジェクト
|
|
947
|
+
* @returns {RankingBuilder} this
|
|
948
|
+
* @private
|
|
949
|
+
*/
|
|
950
|
+
set(obj) {
|
|
951
|
+
Object.assign(this.params, obj);
|
|
952
|
+
return this;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* 設定されたパラメータに基づき、なろう小説ランキングAPIへのリクエストを実行します。
|
|
956
|
+
*
|
|
957
|
+
* 返される結果には、Nコード、ポイント、順位が含まれます。
|
|
958
|
+
* @param options 実行オプション
|
|
959
|
+
* @returns {Promise<NarouRankingResult[]>} ランキング結果の配列
|
|
960
|
+
* @see https://dev.syosetu.com/man/rankapi/#output
|
|
961
|
+
*/
|
|
962
|
+
execute(options) {
|
|
963
|
+
const date = formatDate(this.date$);
|
|
964
|
+
this.set({ rtype: `${date}-${this.type$}` });
|
|
965
|
+
return this.api.executeRanking(this.params, options);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* ランキングAPIを実行し、取得したNコードを元になろう小説APIで詳細情報を取得して結合します。
|
|
969
|
+
*
|
|
970
|
+
* @template TFields - 取得する小説情報のフィールド型
|
|
971
|
+
* @template TOpt - オプショナルな取得フィールドの型
|
|
972
|
+
* @param fields - 取得するフィールドの配列 (省略時はデフォルトフィールド)
|
|
973
|
+
* @param opt - オプショナルな取得フィールド (`weekly` など)
|
|
974
|
+
* @returns {Promise<RankingResult<SearchResultFields<TFields>>[]>} 詳細情報を含むランキング結果の配列
|
|
975
|
+
*/
|
|
976
|
+
async executeWithFields(fields = [], opt, options) {
|
|
977
|
+
const ranking = await this.execute(options);
|
|
978
|
+
const fields$ = Array.isArray(fields) ? fields.length == 0 ? [] : [...fields, Fields.ncode] : [fields, Fields.ncode];
|
|
979
|
+
const rankingNcodes = ranking.map(({ ncode }) => ncode);
|
|
980
|
+
const builder = new SearchBuilder({}, this.api);
|
|
981
|
+
builder.fields(fields$);
|
|
982
|
+
if (opt) builder.opt(opt);
|
|
983
|
+
builder.ncode(rankingNcodes);
|
|
984
|
+
builder.limit(ranking.length);
|
|
985
|
+
const result = await builder.execute(options);
|
|
986
|
+
return ranking.map((r) => ({
|
|
987
|
+
...r,
|
|
988
|
+
...result.values.find((novel) => novel.ncode == r.ncode)
|
|
989
|
+
}));
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/ranking-history.ts
|
|
995
|
+
/**
|
|
996
|
+
* 生のランキング履歴エントリを構造化された形式にフォーマットします。
|
|
997
|
+
*
|
|
998
|
+
* @param rankin - フォーマットする生のランキング履歴データ
|
|
999
|
+
* @returns 日付とタイプが解析されたフォーマット済みランキング履歴
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* const rawData = { rtype: "20230101-daily", pt: 500, rank: 10 };
|
|
1003
|
+
* const formattedData = formatRankingHistory(rawData);
|
|
1004
|
+
* // 返り値: { type: "daily", date: [Dateオブジェクト], pt: 500, rank: 10 }
|
|
1005
|
+
*/
|
|
1006
|
+
function formatRankingHistory(rankin) {
|
|
1007
|
+
const { rtype, pt, rank } = rankin;
|
|
1008
|
+
const [_date, _type] = rtype.split("-");
|
|
1009
|
+
return {
|
|
1010
|
+
type: _type,
|
|
1011
|
+
date: parseDate(_date),
|
|
1012
|
+
pt,
|
|
1013
|
+
rank
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
//#endregion
|
|
1018
|
+
//#region src/search-builder-r18.ts
|
|
1019
|
+
/**
|
|
1020
|
+
* 18禁API検索ヘルパー
|
|
1021
|
+
* @class SearchBuilderR18
|
|
1022
|
+
*/
|
|
1023
|
+
var SearchBuilderR18 = class extends NovelSearchBuilderBase {
|
|
1024
|
+
/**
|
|
1025
|
+
* なろう小説APIへの検索リクエストを実行する
|
|
1026
|
+
* @override
|
|
1027
|
+
* @param options 実行オプション
|
|
1028
|
+
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
1029
|
+
*/
|
|
1030
|
+
execute(options) {
|
|
1031
|
+
return this.api.executeNovel18(this.params, options);
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* 抽出するR18サイトを指定します (nocgenre)。
|
|
1035
|
+
* @param sites R18サイトコード、またはR18サイトコードの配列 (1: ノクターンノベルズ, 2: ムーンライトノベルズ(男性向け), 3: ムーンライトノベルズ(BL), 4: ミッドナイトノベルズ)
|
|
1036
|
+
* @return {this}
|
|
1037
|
+
*/
|
|
1038
|
+
r18Site(sites) {
|
|
1039
|
+
this.set({ nocgenre: NovelSearchBuilderBase.array2string(sites) });
|
|
1040
|
+
return this;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* X-IDを指定して取得します (xid)。
|
|
1044
|
+
* @param ids X-ID、またはX-IDの配列
|
|
1045
|
+
* @return {this}
|
|
1046
|
+
*/
|
|
1047
|
+
xid(ids) {
|
|
1048
|
+
this.set({ xid: NovelSearchBuilderBase.array2string(ids) });
|
|
1049
|
+
return this;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* 出力する項目を個別に指定します (of)。
|
|
1053
|
+
* 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
|
|
1054
|
+
* @param fields 出力するR18フィールド名、またはR18フィールド名の配列
|
|
1055
|
+
* @return {SearchBuilderR18<SearchResultR18Fields<R18Fields>>} 型が更新されたビルダー
|
|
1056
|
+
*/
|
|
1057
|
+
fields(fields) {
|
|
1058
|
+
this.set({ of: NovelSearchBuilderBase.array2string(fields) });
|
|
1059
|
+
return this;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* 出力オプション項目を指定します (opt)。
|
|
1063
|
+
* @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
|
|
1064
|
+
* @return {SearchBuilderR18<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
|
|
1065
|
+
*/
|
|
1066
|
+
opt(option) {
|
|
1067
|
+
this.set({ opt: NovelSearchBuilderBase.array2string(option) });
|
|
1068
|
+
return this;
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/user-search.ts
|
|
1074
|
+
/**
|
|
1075
|
+
* なろうユーザ検索API
|
|
1076
|
+
* @class UserSearch
|
|
1077
|
+
*/
|
|
1078
|
+
var UserSearchBuilder = class UserSearchBuilder extends SearchBuilderBase {
|
|
1079
|
+
/**
|
|
1080
|
+
* 単語を指定できます。
|
|
1081
|
+
* 半角または全角スペースで区切るとAND抽出になります。
|
|
1082
|
+
* 部分一致でHITします。検索の対象はユーザ名とユーザ名のフリガナです。
|
|
1083
|
+
*/
|
|
1084
|
+
word(word) {
|
|
1085
|
+
this.set({ word });
|
|
1086
|
+
return this;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* 含みたくない単語を指定できます。
|
|
1090
|
+
* スペースで区切ることにより含ませない単語を増やせます。部分一致で除外されます。
|
|
1091
|
+
* 除外の対象はユーザ名とユーザ名のフリガナです。
|
|
1092
|
+
*/
|
|
1093
|
+
notWord(notword) {
|
|
1094
|
+
this.set({ notword });
|
|
1095
|
+
return this;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* ユーザIDで抽出可能。
|
|
1099
|
+
*/
|
|
1100
|
+
userId(userid) {
|
|
1101
|
+
this.set({ userid });
|
|
1102
|
+
return this;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* 抽出するユーザのユーザ名のフリガナの頭文字を指定できます。
|
|
1106
|
+
* 頭文字はユーザ名のフリガナをひらがなに変換し、最初の1文字が「ぁ」~「ん」の場合に対象となります。
|
|
1107
|
+
* 「ぱ」や「ば」等の半濁音や濁音は清音として扱われます。
|
|
1108
|
+
* 漢字や英数字が頭文字のユーザは対象外です。
|
|
1109
|
+
*/
|
|
1110
|
+
name1st(name1st) {
|
|
1111
|
+
this.set({ name1st });
|
|
1112
|
+
return this;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* 抽出するユーザの小説投稿数の下限を指定できます。
|
|
1116
|
+
* 小説投稿件数が指定された数値以上のユーザを抽出します。
|
|
1117
|
+
*/
|
|
1118
|
+
minNovel(minnovel) {
|
|
1119
|
+
this.set({ minnovel });
|
|
1120
|
+
return this;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* 抽出するユーザの小説投稿数の上限を指定できます。
|
|
1124
|
+
* 小説投稿件数が指定された数値以下のユーザを抽出します。
|
|
1125
|
+
*/
|
|
1126
|
+
maxNovel(maxnovel) {
|
|
1127
|
+
this.set({ maxnovel });
|
|
1128
|
+
return this;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* 抽出するユーザのレビュー投稿数の下限を指定できます。
|
|
1132
|
+
* レビュー投稿件数が指定された数値以上のユーザを抽出します。
|
|
1133
|
+
*/
|
|
1134
|
+
minReview(minreview) {
|
|
1135
|
+
this.set({ minreview });
|
|
1136
|
+
return this;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* 抽出するユーザのレビュー投稿数の上限を指定できます。
|
|
1140
|
+
* レビュー投稿件数が指定された数値以下のユーザを抽出します。
|
|
1141
|
+
*/
|
|
1142
|
+
maxReview(maxreview) {
|
|
1143
|
+
this.set({ maxreview });
|
|
1144
|
+
return this;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* 出力する項目を個別に指定できます。未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
|
|
1148
|
+
* @return {SearchBuilder} this
|
|
1149
|
+
*/
|
|
1150
|
+
fields(fields) {
|
|
1151
|
+
this.set({ of: UserSearchBuilder.array2string(fields) });
|
|
1152
|
+
return this;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* なろう小説APIへのリクエストを実行する
|
|
1156
|
+
* @param options 実行オプション
|
|
1157
|
+
* @returns ランキング
|
|
1158
|
+
*/
|
|
1159
|
+
execute(options) {
|
|
1160
|
+
return this.api.executeUserSearch(this.params, options);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
//#endregion
|
|
1165
|
+
export { NovelType as A, StopParam as C, NarouNovel as D, NarouNovelJsonp as E, End as O, RankingType as S, UserOrder as T, OptionalFields as _, NovelSearchBuilderBase as a, R18Site as b, BigGenre as c, BuntaiParam as d, DateParam as f, NovelTypeParam as g, GenreNotation as h, RankingBuilder as i, NarouSearchResults as k, BigGenreNotation as l, Genre as m, SearchBuilderR18 as n, SearchBuilder as o, Fields as p, formatRankingHistory as r, SearchBuilderBase as s, UserSearchBuilder as t, BooleanNumber as u, Order as v, UserFields as w, R18SiteNotation as x, R18Fields as y };
|
|
1166
|
+
//# sourceMappingURL=index.common-8lS2K_1Y.mjs.map
|