novel-api 0.19.1

Novel APIs from various sources
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
use chrono::NaiveDateTime;
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use url::Url;
use zeroize::ZeroizeOnDrop;

#[must_use]
#[derive(Serialize)]
pub(crate) struct EmptyRequest {}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct GenericResponse {
    pub code: String,
    pub tip: Option<String>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct UserInfoResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<UserInfoData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct UserInfoData {
    pub reader_info: ReaderInfo,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReaderInfo {
    pub account: String,
    pub reader_id: String,
    pub reader_name: String,
    // 当头像不存在时,是空字符串
    #[serde(deserialize_with = "parse_url")]
    pub avatar_url: Option<Url>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct PropInfoResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<PropInfoData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct PropInfoData {
    pub prop_info: PropInfo,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct PropInfo {
    // 猫饼干 + 代币
    pub rest_hlb: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct SignRequest {
    pub task_type: u8,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct BookshelfRequest {
    pub shelf_id: u32,
    pub count: u16,
    pub page: u16,
    pub order: &'static str,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct BookshelfResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<BookshelfData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct BookshelfData {
    pub book_list: Vec<BookshelfInfo>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct BookshelfInfo {
    pub book_info: BookshelfNovelInfo,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct BookshelfNovelInfo {
    pub book_id: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct NovelInfoRequest {
    pub book_id: u32,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct NovelInfoResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<NovelInfoData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct NovelInfoData {
    pub book_info: BookInfo,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct BookInfo {
    pub book_name: String,
    pub author_name: String,
    // 有一些小说 cover 为空
    #[serde(deserialize_with = "parse_url")]
    pub cover: Option<Url>,
    pub description: String,
    pub total_word_count: String,
    #[serde(deserialize_with = "parse_bool")]
    pub is_paid: bool,
    #[serde(deserialize_with = "parse_bool")]
    pub up_status: bool,
    // 有一些小说 newtime 为空
    #[serde(deserialize_with = "crate::common::date_format_option")]
    pub newtime: Option<NaiveDateTime>,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub uptime: NaiveDateTime,
    pub category_index: String,
    pub tag_list: Vec<NovelInfoTag>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct NovelInfoTag {
    pub tag_name: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct ReviewRequest {
    pub book_id: u32,
    pub r#type: u8,
    pub page: u16,
    pub count: u16,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ReviewData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewData {
    pub review_list: Vec<ReviewList>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewList {
    pub review_id: String,
    // 无标题时为空字符串
    pub title: String,
    pub review_content: String,
    pub like_amount: String,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub ctime: NaiveDateTime,
    pub reader_info: ReaderInfo,
    pub comment_amount: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct ReviewCommentRequest {
    pub review_id: u32,
    pub page: u16,
    pub count: u16,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ReviewCommentData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentData {
    pub review_comment_list: Vec<ReviewCommentList>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentList {
    pub comment_id: String,
    pub comment_content: String,
    pub reader_info: ReaderInfo,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub ctime: NaiveDateTime,
    // 不是完整的列表
    pub review_comment_reply_list: Vec<ReviewCommentReplyList>,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct ReviewCommentReplyRequest {
    pub comment_id: u32,
    pub page: u16,
    pub count: u16,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentReplyResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ReviewCommentReplyData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentReplyData {
    pub review_comment_reply_list: Vec<ReviewCommentReplyList>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ReviewCommentReplyList {
    pub reply_id: String,
    pub reply_content: String,
    pub reader_info: ReaderInfo,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub ctime: NaiveDateTime,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct VolumesRequest {
    pub book_id: u32,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct VolumesResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<VolumesData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct VolumesData {
    pub chapter_list: Vec<VolumeInfo>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct VolumeInfo {
    pub division_id: String,
    pub division_name: String,
    pub chapter_list: Vec<ChapterInfo>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapterInfo {
    pub chapter_id: String,
    pub chapter_title: String,
    pub word_count: String,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub mtime: NaiveDateTime,
    #[serde(deserialize_with = "parse_bool")]
    pub is_valid: bool,
    #[serde(deserialize_with = "parse_bool")]
    pub is_paid: bool,
    #[serde(deserialize_with = "parse_bool")]
    pub auth_access: bool,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct OrderChapterRequest {
    pub chapter_id: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct OrderNovelRequest {
    pub chapter_id_list: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct ChapsRequest {
    pub chapter_id: String,
    pub chapter_command: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapsResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ChapsData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapsData {
    pub chapter_infos: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapsInfo {
    pub txt_content: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct CategoryResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<CategoryData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct CategoryData {
    pub category_list: Vec<Category>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct Category {
    pub category_detail: Vec<CategoryDetail>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct CategoryDetail {
    pub category_index: String,
    pub category_name: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct TagResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<TagData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct TagData {
    pub official_tag_list: Vec<Tag>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct Tag {
    pub tag_name: String,
}

#[must_use]
#[skip_serializing_none]
#[derive(Serialize)]
pub(crate) struct SearchRequest {
    pub count: u16,
    pub page: u16,
    pub order: Option<&'static str>,
    pub category_index: u16,
    pub tags: String,
    pub key: Option<String>,
    pub is_paid: Option<u8>,
    pub up_status: Option<u8>,
    pub filter_uptime: Option<u8>,
    pub filter_word: Option<u8>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct SearchResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<SearchData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct SearchData {
    pub book_list: Vec<SearchInfo>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct SearchInfo {
    pub book_id: String,
    pub total_word_count: String,
    #[serde(deserialize_with = "crate::common::date_format")]
    pub uptime: NaiveDateTime,
    pub tag_list: Vec<NovelInfoTag>,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct UseGeetestRequest {
    pub login_name: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct UseGeetestResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<UseGeetestData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct UseGeetestData {
    pub need_use_geetest: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct GeetestInfoRequest {
    pub t: u128,
    pub user_id: String,
}

#[must_use]
#[derive(Deserialize, Clone)]
pub(crate) struct GeetestInfoResponse {
    pub success: u8,
    pub new_captcha: bool,
    pub gt: String,
    pub challenge: String,
}

#[must_use]
#[derive(Serialize, ZeroizeOnDrop)]
pub(crate) struct SendVerifyCodeRequest {
    pub login_name: String,
    pub timestamp: u128,
    pub verify_type: u8,
    pub hashvalue: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct SendVerifyCodeResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<SendVerifyCodeData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct SendVerifyCodeData {
    pub to_code: String,
}

#[must_use]
#[derive(Serialize, ZeroizeOnDrop)]
pub(crate) struct LoginRequest {
    pub login_name: String,
    pub passwd: String,
    pub sign: String,
}

#[must_use]
#[derive(Serialize, ZeroizeOnDrop)]
pub(crate) struct LoginCaptchaRequest {
    pub login_name: String,
    pub passwd: String,
    pub sign: String,
    pub geetest_seccode: String,
    pub geetest_validate: String,
    pub geetest_challenge: String,
}

#[must_use]
#[derive(Serialize, ZeroizeOnDrop)]
pub(crate) struct LoginSMSRequest {
    pub login_name: String,
    pub passwd: String,
    pub sign: String,
    pub to_code: String,
    pub ver_code: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct LoginResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<LoginData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct LoginData {
    pub login_token: String,
    pub reader_info: ReaderInfo,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ShelfListResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ShelfListData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ShelfListData {
    pub shelf_list: Vec<Shelf>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct Shelf {
    pub shelf_id: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct PriceRequest {
    pub book_id: u32,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct PriceResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<PriceData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct PriceData {
    pub chapter_permission_list: Vec<ChapterPermission>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapterPermission {
    pub chapter_id: String,
    pub unit_hlb: String,
}

#[must_use]
#[derive(Serialize)]
pub(crate) struct ChapterCmdRequest {
    pub chapter_id: String,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapterCmdResponse {
    pub code: String,
    pub tip: Option<String>,
    pub data: Option<ChapterCmdData>,
}

#[must_use]
#[derive(Deserialize)]
pub(crate) struct ChapterCmdData {
    pub command: String,
}

pub(crate) fn parse_bool<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
    D: Deserializer<'de>,
{
    let s = String::deserialize(deserializer)?;

    assert!(!s.is_empty());

    if s == "1" { Ok(true) } else { Ok(false) }
}

pub(crate) fn parse_url<'de, D>(deserializer: D) -> Result<Option<Url>, D::Error>
where
    D: Deserializer<'de>,
{
    let s = String::deserialize(deserializer)?;

    match Url::parse(&s) {
        Ok(url) => Ok(Some(url)),
        Err(_) => Ok(None),
    }
}