@ikenxuan/amagi 4.4.4 → 4.4.6
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/dist/default/cjs/index.cjs +122 -118
- package/dist/default/esm/index.mjs +121 -117
- package/dist/default/index.d.ts +22 -10
- package/package.json +5 -5
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var express = require('express');
|
|
6
5
|
var axios = require('axios');
|
|
7
6
|
var crypto = require('crypto');
|
|
7
|
+
var express = require('express');
|
|
8
8
|
var chalk = require('chalk');
|
|
9
9
|
var log4js = require('log4js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
|
-
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
14
13
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
15
14
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
15
|
+
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
16
16
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
17
17
|
var log4js__default = /*#__PURE__*/_interopDefault(log4js);
|
|
18
18
|
|
|
@@ -428,6 +428,113 @@ async function qtparam(BASEURL, cookie) {
|
|
|
428
428
|
return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
|
|
429
429
|
} else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
|
|
430
430
|
}
|
|
431
|
+
var mixinKeyEncTab = [
|
|
432
|
+
46,
|
|
433
|
+
47,
|
|
434
|
+
18,
|
|
435
|
+
2,
|
|
436
|
+
53,
|
|
437
|
+
8,
|
|
438
|
+
23,
|
|
439
|
+
32,
|
|
440
|
+
15,
|
|
441
|
+
50,
|
|
442
|
+
10,
|
|
443
|
+
31,
|
|
444
|
+
58,
|
|
445
|
+
3,
|
|
446
|
+
45,
|
|
447
|
+
35,
|
|
448
|
+
27,
|
|
449
|
+
43,
|
|
450
|
+
5,
|
|
451
|
+
49,
|
|
452
|
+
33,
|
|
453
|
+
9,
|
|
454
|
+
42,
|
|
455
|
+
19,
|
|
456
|
+
29,
|
|
457
|
+
28,
|
|
458
|
+
14,
|
|
459
|
+
39,
|
|
460
|
+
12,
|
|
461
|
+
38,
|
|
462
|
+
41,
|
|
463
|
+
13,
|
|
464
|
+
37,
|
|
465
|
+
48,
|
|
466
|
+
7,
|
|
467
|
+
16,
|
|
468
|
+
24,
|
|
469
|
+
55,
|
|
470
|
+
40,
|
|
471
|
+
61,
|
|
472
|
+
26,
|
|
473
|
+
17,
|
|
474
|
+
0,
|
|
475
|
+
1,
|
|
476
|
+
60,
|
|
477
|
+
51,
|
|
478
|
+
30,
|
|
479
|
+
4,
|
|
480
|
+
22,
|
|
481
|
+
25,
|
|
482
|
+
54,
|
|
483
|
+
21,
|
|
484
|
+
56,
|
|
485
|
+
59,
|
|
486
|
+
6,
|
|
487
|
+
63,
|
|
488
|
+
57,
|
|
489
|
+
62,
|
|
490
|
+
11,
|
|
491
|
+
36,
|
|
492
|
+
20,
|
|
493
|
+
34,
|
|
494
|
+
44,
|
|
495
|
+
52
|
|
496
|
+
];
|
|
497
|
+
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
498
|
+
function encWbi(params, img_key, sub_key) {
|
|
499
|
+
const mixin_key = getMixinKey(img_key + sub_key);
|
|
500
|
+
const curr_time = Math.round(Date.now() / 1e3);
|
|
501
|
+
const chr_filter = /[!'()*]/g;
|
|
502
|
+
Object.assign(params, { wts: curr_time });
|
|
503
|
+
const query = Object.keys(params).sort().map((key) => {
|
|
504
|
+
const value = params[key].toString().replace(chr_filter, "");
|
|
505
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
506
|
+
}).join("&");
|
|
507
|
+
const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
|
|
508
|
+
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
509
|
+
}
|
|
510
|
+
async function getWbiKeys(cookie) {
|
|
511
|
+
const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
|
|
512
|
+
headers: {
|
|
513
|
+
Cookie: cookie
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
const responseJson = res.data;
|
|
517
|
+
const response = responseJson;
|
|
518
|
+
const {
|
|
519
|
+
data: {
|
|
520
|
+
wbi_img: { img_url, sub_url }
|
|
521
|
+
}
|
|
522
|
+
} = response;
|
|
523
|
+
return {
|
|
524
|
+
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
525
|
+
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
async function wbi_sign(BASEURL, cookie) {
|
|
529
|
+
const web_keys = await getWbiKeys(cookie);
|
|
530
|
+
const url = new URL(BASEURL);
|
|
531
|
+
const params = {};
|
|
532
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
533
|
+
params[key] = value;
|
|
534
|
+
}
|
|
535
|
+
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
536
|
+
return query;
|
|
537
|
+
}
|
|
431
538
|
var registerBilibiliRoutes = (cookie) => {
|
|
432
539
|
const router = express__default.default.Router();
|
|
433
540
|
router.get("/new_login_qrcode", async (req, res) => {
|
|
@@ -459,8 +566,8 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
459
566
|
router.get("/fetch_video_playurl", async (req, res) => {
|
|
460
567
|
const data2 = await BilibiliData({
|
|
461
568
|
methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
462
|
-
avid: req.query.avid,
|
|
463
|
-
cid: req.query.cid
|
|
569
|
+
avid: parseInt(req.query.avid),
|
|
570
|
+
cid: parseInt(req.query.cid)
|
|
464
571
|
}, req.headers.cookie || cookie);
|
|
465
572
|
res.json(data2);
|
|
466
573
|
});
|
|
@@ -489,7 +596,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
489
596
|
router.get("/fetch_bangumi_video_playurl", async (req, res) => {
|
|
490
597
|
const data2 = await BilibiliData({
|
|
491
598
|
methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
492
|
-
cid: req.query.cid,
|
|
599
|
+
cid: parseInt(req.query.cid),
|
|
493
600
|
ep_id: req.query.ep_id
|
|
494
601
|
}, req.headers.cookie || cookie);
|
|
495
602
|
res.json(data2);
|
|
@@ -497,7 +604,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
497
604
|
router.get("/fetch_user_dynamic", async (req, res) => {
|
|
498
605
|
const data2 = await BilibiliData({
|
|
499
606
|
methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
|
|
500
|
-
host_mid: req.query.host_mid
|
|
607
|
+
host_mid: parseInt(req.query.host_mid)
|
|
501
608
|
}, req.headers.cookie || cookie);
|
|
502
609
|
res.json(data2);
|
|
503
610
|
});
|
|
@@ -518,7 +625,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
518
625
|
router.get("/fetch_user_profile", async (req, res) => {
|
|
519
626
|
const data2 = await BilibiliData({
|
|
520
627
|
methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
|
|
521
|
-
host_mid: req.query.host_mid
|
|
628
|
+
host_mid: parseInt(req.query.host_mid)
|
|
522
629
|
}, req.headers.cookie || cookie);
|
|
523
630
|
res.json(data2);
|
|
524
631
|
});
|
|
@@ -546,126 +653,19 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
546
653
|
router.get("/av_to_bv", async (req, res) => {
|
|
547
654
|
const data2 = await BilibiliData({
|
|
548
655
|
methodType: "AV\u8F6CBV",
|
|
549
|
-
avid: req.query.avid
|
|
656
|
+
avid: parseInt(req.query.avid)
|
|
550
657
|
}, req.headers.cookie || cookie);
|
|
551
658
|
res.json(data2);
|
|
552
659
|
});
|
|
553
660
|
router.get("/fetch_user_full_view", async (req, res) => {
|
|
554
661
|
const data2 = await BilibiliData({
|
|
555
662
|
methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
|
|
556
|
-
host_mid: req.query.host_mid
|
|
663
|
+
host_mid: parseInt(req.query.host_mid)
|
|
557
664
|
}, req.headers.cookie || cookie);
|
|
558
665
|
res.json(data2);
|
|
559
666
|
});
|
|
560
667
|
return router;
|
|
561
668
|
};
|
|
562
|
-
var mixinKeyEncTab = [
|
|
563
|
-
46,
|
|
564
|
-
47,
|
|
565
|
-
18,
|
|
566
|
-
2,
|
|
567
|
-
53,
|
|
568
|
-
8,
|
|
569
|
-
23,
|
|
570
|
-
32,
|
|
571
|
-
15,
|
|
572
|
-
50,
|
|
573
|
-
10,
|
|
574
|
-
31,
|
|
575
|
-
58,
|
|
576
|
-
3,
|
|
577
|
-
45,
|
|
578
|
-
35,
|
|
579
|
-
27,
|
|
580
|
-
43,
|
|
581
|
-
5,
|
|
582
|
-
49,
|
|
583
|
-
33,
|
|
584
|
-
9,
|
|
585
|
-
42,
|
|
586
|
-
19,
|
|
587
|
-
29,
|
|
588
|
-
28,
|
|
589
|
-
14,
|
|
590
|
-
39,
|
|
591
|
-
12,
|
|
592
|
-
38,
|
|
593
|
-
41,
|
|
594
|
-
13,
|
|
595
|
-
37,
|
|
596
|
-
48,
|
|
597
|
-
7,
|
|
598
|
-
16,
|
|
599
|
-
24,
|
|
600
|
-
55,
|
|
601
|
-
40,
|
|
602
|
-
61,
|
|
603
|
-
26,
|
|
604
|
-
17,
|
|
605
|
-
0,
|
|
606
|
-
1,
|
|
607
|
-
60,
|
|
608
|
-
51,
|
|
609
|
-
30,
|
|
610
|
-
4,
|
|
611
|
-
22,
|
|
612
|
-
25,
|
|
613
|
-
54,
|
|
614
|
-
21,
|
|
615
|
-
56,
|
|
616
|
-
59,
|
|
617
|
-
6,
|
|
618
|
-
63,
|
|
619
|
-
57,
|
|
620
|
-
62,
|
|
621
|
-
11,
|
|
622
|
-
36,
|
|
623
|
-
20,
|
|
624
|
-
34,
|
|
625
|
-
44,
|
|
626
|
-
52
|
|
627
|
-
];
|
|
628
|
-
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
629
|
-
function encWbi(params, img_key, sub_key) {
|
|
630
|
-
const mixin_key = getMixinKey(img_key + sub_key);
|
|
631
|
-
const curr_time = Math.round(Date.now() / 1e3);
|
|
632
|
-
const chr_filter = /[!'()*]/g;
|
|
633
|
-
Object.assign(params, { wts: curr_time });
|
|
634
|
-
const query = Object.keys(params).sort().map((key) => {
|
|
635
|
-
const value = params[key].toString().replace(chr_filter, "");
|
|
636
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
637
|
-
}).join("&");
|
|
638
|
-
const wbi_sign2 = crypto__default.default.createHash("md5").update(query + mixin_key).digest("hex");
|
|
639
|
-
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
640
|
-
}
|
|
641
|
-
async function getWbiKeys(cookie) {
|
|
642
|
-
const res = await axios__default.default("https://api.bilibili.com/x/web-interface/nav", {
|
|
643
|
-
headers: {
|
|
644
|
-
Cookie: cookie
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
const responseJson = res.data;
|
|
648
|
-
const response = responseJson;
|
|
649
|
-
const {
|
|
650
|
-
data: {
|
|
651
|
-
wbi_img: { img_url, sub_url }
|
|
652
|
-
}
|
|
653
|
-
} = response;
|
|
654
|
-
return {
|
|
655
|
-
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
656
|
-
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
async function wbi_sign(BASEURL, cookie) {
|
|
660
|
-
const web_keys = await getWbiKeys(cookie);
|
|
661
|
-
const url = new URL(BASEURL);
|
|
662
|
-
const params = {};
|
|
663
|
-
for (const [key, value] of url.searchParams.entries()) {
|
|
664
|
-
params[key] = value;
|
|
665
|
-
}
|
|
666
|
-
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
667
|
-
return query;
|
|
668
|
-
}
|
|
669
669
|
|
|
670
670
|
// src/platform/bilibili/sign/bv2av.ts
|
|
671
671
|
var XOR_CODE = 23442827791579n;
|
|
@@ -1395,7 +1395,9 @@ var registerDouyinRoutes = (cookie) => {
|
|
|
1395
1395
|
router.get("/fetch_work_comments", async (req, res) => {
|
|
1396
1396
|
const data2 = await DouyinData({
|
|
1397
1397
|
methodType: "\u8BC4\u8BBA\u6570\u636E",
|
|
1398
|
-
aweme_id: req.query.aweme_id
|
|
1398
|
+
aweme_id: req.query.aweme_id,
|
|
1399
|
+
number: parseInt(req.query.number ?? "50"),
|
|
1400
|
+
cursor: parseInt(req.query.cursor ?? "0")
|
|
1399
1401
|
}, req.headers.cookie || cookie);
|
|
1400
1402
|
res.json(data2);
|
|
1401
1403
|
});
|
|
@@ -1431,7 +1433,9 @@ var registerDouyinRoutes = (cookie) => {
|
|
|
1431
1433
|
router.get("/fetch_search_info", async (req, res) => {
|
|
1432
1434
|
const data2 = await DouyinData({
|
|
1433
1435
|
methodType: "\u641C\u7D22\u6570\u636E",
|
|
1434
|
-
query: req.query.query
|
|
1436
|
+
query: req.query.query,
|
|
1437
|
+
number: parseInt(req.query.number ?? "10"),
|
|
1438
|
+
search_id: req.query.search_id
|
|
1435
1439
|
}, req.headers.cookie || cookie);
|
|
1436
1440
|
res.json(data2);
|
|
1437
1441
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
1
|
import axios, { AxiosError } from 'axios';
|
|
3
2
|
import crypto from 'crypto';
|
|
3
|
+
import express from 'express';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import log4js from 'log4js';
|
|
6
6
|
|
|
@@ -416,6 +416,113 @@ async function qtparam(BASEURL, cookie) {
|
|
|
416
416
|
return { QUERY: `&fnval=16&fourk=1&${sign}`, STATUS: "isLogin", isvip };
|
|
417
417
|
} else return { QUERY: `&qn=${qn[3]}&fnval=16`, STATUS: "isLogin", isvip };
|
|
418
418
|
}
|
|
419
|
+
var mixinKeyEncTab = [
|
|
420
|
+
46,
|
|
421
|
+
47,
|
|
422
|
+
18,
|
|
423
|
+
2,
|
|
424
|
+
53,
|
|
425
|
+
8,
|
|
426
|
+
23,
|
|
427
|
+
32,
|
|
428
|
+
15,
|
|
429
|
+
50,
|
|
430
|
+
10,
|
|
431
|
+
31,
|
|
432
|
+
58,
|
|
433
|
+
3,
|
|
434
|
+
45,
|
|
435
|
+
35,
|
|
436
|
+
27,
|
|
437
|
+
43,
|
|
438
|
+
5,
|
|
439
|
+
49,
|
|
440
|
+
33,
|
|
441
|
+
9,
|
|
442
|
+
42,
|
|
443
|
+
19,
|
|
444
|
+
29,
|
|
445
|
+
28,
|
|
446
|
+
14,
|
|
447
|
+
39,
|
|
448
|
+
12,
|
|
449
|
+
38,
|
|
450
|
+
41,
|
|
451
|
+
13,
|
|
452
|
+
37,
|
|
453
|
+
48,
|
|
454
|
+
7,
|
|
455
|
+
16,
|
|
456
|
+
24,
|
|
457
|
+
55,
|
|
458
|
+
40,
|
|
459
|
+
61,
|
|
460
|
+
26,
|
|
461
|
+
17,
|
|
462
|
+
0,
|
|
463
|
+
1,
|
|
464
|
+
60,
|
|
465
|
+
51,
|
|
466
|
+
30,
|
|
467
|
+
4,
|
|
468
|
+
22,
|
|
469
|
+
25,
|
|
470
|
+
54,
|
|
471
|
+
21,
|
|
472
|
+
56,
|
|
473
|
+
59,
|
|
474
|
+
6,
|
|
475
|
+
63,
|
|
476
|
+
57,
|
|
477
|
+
62,
|
|
478
|
+
11,
|
|
479
|
+
36,
|
|
480
|
+
20,
|
|
481
|
+
34,
|
|
482
|
+
44,
|
|
483
|
+
52
|
|
484
|
+
];
|
|
485
|
+
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
486
|
+
function encWbi(params, img_key, sub_key) {
|
|
487
|
+
const mixin_key = getMixinKey(img_key + sub_key);
|
|
488
|
+
const curr_time = Math.round(Date.now() / 1e3);
|
|
489
|
+
const chr_filter = /[!'()*]/g;
|
|
490
|
+
Object.assign(params, { wts: curr_time });
|
|
491
|
+
const query = Object.keys(params).sort().map((key) => {
|
|
492
|
+
const value = params[key].toString().replace(chr_filter, "");
|
|
493
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
494
|
+
}).join("&");
|
|
495
|
+
const wbi_sign2 = crypto.createHash("md5").update(query + mixin_key).digest("hex");
|
|
496
|
+
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
497
|
+
}
|
|
498
|
+
async function getWbiKeys(cookie) {
|
|
499
|
+
const res = await axios("https://api.bilibili.com/x/web-interface/nav", {
|
|
500
|
+
headers: {
|
|
501
|
+
Cookie: cookie
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
const responseJson = res.data;
|
|
505
|
+
const response = responseJson;
|
|
506
|
+
const {
|
|
507
|
+
data: {
|
|
508
|
+
wbi_img: { img_url, sub_url }
|
|
509
|
+
}
|
|
510
|
+
} = response;
|
|
511
|
+
return {
|
|
512
|
+
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
513
|
+
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
async function wbi_sign(BASEURL, cookie) {
|
|
517
|
+
const web_keys = await getWbiKeys(cookie);
|
|
518
|
+
const url = new URL(BASEURL);
|
|
519
|
+
const params = {};
|
|
520
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
521
|
+
params[key] = value;
|
|
522
|
+
}
|
|
523
|
+
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
524
|
+
return query;
|
|
525
|
+
}
|
|
419
526
|
var registerBilibiliRoutes = (cookie) => {
|
|
420
527
|
const router = express.Router();
|
|
421
528
|
router.get("/new_login_qrcode", async (req, res) => {
|
|
@@ -447,8 +554,8 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
447
554
|
router.get("/fetch_video_playurl", async (req, res) => {
|
|
448
555
|
const data2 = await BilibiliData({
|
|
449
556
|
methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
450
|
-
avid: req.query.avid,
|
|
451
|
-
cid: req.query.cid
|
|
557
|
+
avid: parseInt(req.query.avid),
|
|
558
|
+
cid: parseInt(req.query.cid)
|
|
452
559
|
}, req.headers.cookie || cookie);
|
|
453
560
|
res.json(data2);
|
|
454
561
|
});
|
|
@@ -477,7 +584,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
477
584
|
router.get("/fetch_bangumi_video_playurl", async (req, res) => {
|
|
478
585
|
const data2 = await BilibiliData({
|
|
479
586
|
methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
480
|
-
cid: req.query.cid,
|
|
587
|
+
cid: parseInt(req.query.cid),
|
|
481
588
|
ep_id: req.query.ep_id
|
|
482
589
|
}, req.headers.cookie || cookie);
|
|
483
590
|
res.json(data2);
|
|
@@ -485,7 +592,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
485
592
|
router.get("/fetch_user_dynamic", async (req, res) => {
|
|
486
593
|
const data2 = await BilibiliData({
|
|
487
594
|
methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
|
|
488
|
-
host_mid: req.query.host_mid
|
|
595
|
+
host_mid: parseInt(req.query.host_mid)
|
|
489
596
|
}, req.headers.cookie || cookie);
|
|
490
597
|
res.json(data2);
|
|
491
598
|
});
|
|
@@ -506,7 +613,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
506
613
|
router.get("/fetch_user_profile", async (req, res) => {
|
|
507
614
|
const data2 = await BilibiliData({
|
|
508
615
|
methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E",
|
|
509
|
-
host_mid: req.query.host_mid
|
|
616
|
+
host_mid: parseInt(req.query.host_mid)
|
|
510
617
|
}, req.headers.cookie || cookie);
|
|
511
618
|
res.json(data2);
|
|
512
619
|
});
|
|
@@ -534,126 +641,19 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
534
641
|
router.get("/av_to_bv", async (req, res) => {
|
|
535
642
|
const data2 = await BilibiliData({
|
|
536
643
|
methodType: "AV\u8F6CBV",
|
|
537
|
-
avid: req.query.avid
|
|
644
|
+
avid: parseInt(req.query.avid)
|
|
538
645
|
}, req.headers.cookie || cookie);
|
|
539
646
|
res.json(data2);
|
|
540
647
|
});
|
|
541
648
|
router.get("/fetch_user_full_view", async (req, res) => {
|
|
542
649
|
const data2 = await BilibiliData({
|
|
543
650
|
methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF",
|
|
544
|
-
host_mid: req.query.host_mid
|
|
651
|
+
host_mid: parseInt(req.query.host_mid)
|
|
545
652
|
}, req.headers.cookie || cookie);
|
|
546
653
|
res.json(data2);
|
|
547
654
|
});
|
|
548
655
|
return router;
|
|
549
656
|
};
|
|
550
|
-
var mixinKeyEncTab = [
|
|
551
|
-
46,
|
|
552
|
-
47,
|
|
553
|
-
18,
|
|
554
|
-
2,
|
|
555
|
-
53,
|
|
556
|
-
8,
|
|
557
|
-
23,
|
|
558
|
-
32,
|
|
559
|
-
15,
|
|
560
|
-
50,
|
|
561
|
-
10,
|
|
562
|
-
31,
|
|
563
|
-
58,
|
|
564
|
-
3,
|
|
565
|
-
45,
|
|
566
|
-
35,
|
|
567
|
-
27,
|
|
568
|
-
43,
|
|
569
|
-
5,
|
|
570
|
-
49,
|
|
571
|
-
33,
|
|
572
|
-
9,
|
|
573
|
-
42,
|
|
574
|
-
19,
|
|
575
|
-
29,
|
|
576
|
-
28,
|
|
577
|
-
14,
|
|
578
|
-
39,
|
|
579
|
-
12,
|
|
580
|
-
38,
|
|
581
|
-
41,
|
|
582
|
-
13,
|
|
583
|
-
37,
|
|
584
|
-
48,
|
|
585
|
-
7,
|
|
586
|
-
16,
|
|
587
|
-
24,
|
|
588
|
-
55,
|
|
589
|
-
40,
|
|
590
|
-
61,
|
|
591
|
-
26,
|
|
592
|
-
17,
|
|
593
|
-
0,
|
|
594
|
-
1,
|
|
595
|
-
60,
|
|
596
|
-
51,
|
|
597
|
-
30,
|
|
598
|
-
4,
|
|
599
|
-
22,
|
|
600
|
-
25,
|
|
601
|
-
54,
|
|
602
|
-
21,
|
|
603
|
-
56,
|
|
604
|
-
59,
|
|
605
|
-
6,
|
|
606
|
-
63,
|
|
607
|
-
57,
|
|
608
|
-
62,
|
|
609
|
-
11,
|
|
610
|
-
36,
|
|
611
|
-
20,
|
|
612
|
-
34,
|
|
613
|
-
44,
|
|
614
|
-
52
|
|
615
|
-
];
|
|
616
|
-
var getMixinKey = (orig) => mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
|
|
617
|
-
function encWbi(params, img_key, sub_key) {
|
|
618
|
-
const mixin_key = getMixinKey(img_key + sub_key);
|
|
619
|
-
const curr_time = Math.round(Date.now() / 1e3);
|
|
620
|
-
const chr_filter = /[!'()*]/g;
|
|
621
|
-
Object.assign(params, { wts: curr_time });
|
|
622
|
-
const query = Object.keys(params).sort().map((key) => {
|
|
623
|
-
const value = params[key].toString().replace(chr_filter, "");
|
|
624
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
625
|
-
}).join("&");
|
|
626
|
-
const wbi_sign2 = crypto.createHash("md5").update(query + mixin_key).digest("hex");
|
|
627
|
-
return `&wts=${curr_time}&w_rid=${wbi_sign2}`;
|
|
628
|
-
}
|
|
629
|
-
async function getWbiKeys(cookie) {
|
|
630
|
-
const res = await axios("https://api.bilibili.com/x/web-interface/nav", {
|
|
631
|
-
headers: {
|
|
632
|
-
Cookie: cookie
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
const responseJson = res.data;
|
|
636
|
-
const response = responseJson;
|
|
637
|
-
const {
|
|
638
|
-
data: {
|
|
639
|
-
wbi_img: { img_url, sub_url }
|
|
640
|
-
}
|
|
641
|
-
} = response;
|
|
642
|
-
return {
|
|
643
|
-
img_key: img_url.slice(img_url.lastIndexOf("/") + 1, img_url.lastIndexOf(".")),
|
|
644
|
-
sub_key: sub_url.slice(sub_url.lastIndexOf("/") + 1, sub_url.lastIndexOf("."))
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
async function wbi_sign(BASEURL, cookie) {
|
|
648
|
-
const web_keys = await getWbiKeys(cookie);
|
|
649
|
-
const url = new URL(BASEURL);
|
|
650
|
-
const params = {};
|
|
651
|
-
for (const [key, value] of url.searchParams.entries()) {
|
|
652
|
-
params[key] = value;
|
|
653
|
-
}
|
|
654
|
-
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
655
|
-
return query;
|
|
656
|
-
}
|
|
657
657
|
|
|
658
658
|
// src/platform/bilibili/sign/bv2av.ts
|
|
659
659
|
var XOR_CODE = 23442827791579n;
|
|
@@ -1383,7 +1383,9 @@ var registerDouyinRoutes = (cookie) => {
|
|
|
1383
1383
|
router.get("/fetch_work_comments", async (req, res) => {
|
|
1384
1384
|
const data2 = await DouyinData({
|
|
1385
1385
|
methodType: "\u8BC4\u8BBA\u6570\u636E",
|
|
1386
|
-
aweme_id: req.query.aweme_id
|
|
1386
|
+
aweme_id: req.query.aweme_id,
|
|
1387
|
+
number: parseInt(req.query.number ?? "50"),
|
|
1388
|
+
cursor: parseInt(req.query.cursor ?? "0")
|
|
1387
1389
|
}, req.headers.cookie || cookie);
|
|
1388
1390
|
res.json(data2);
|
|
1389
1391
|
});
|
|
@@ -1419,7 +1421,9 @@ var registerDouyinRoutes = (cookie) => {
|
|
|
1419
1421
|
router.get("/fetch_search_info", async (req, res) => {
|
|
1420
1422
|
const data2 = await DouyinData({
|
|
1421
1423
|
methodType: "\u641C\u7D22\u6570\u636E",
|
|
1422
|
-
query: req.query.query
|
|
1424
|
+
query: req.query.query,
|
|
1425
|
+
number: parseInt(req.query.number ?? "10"),
|
|
1426
|
+
search_id: req.query.search_id
|
|
1423
1427
|
}, req.headers.cookie || cookie);
|
|
1424
1428
|
res.json(data2);
|
|
1425
1429
|
});
|
package/dist/default/index.d.ts
CHANGED
|
@@ -13760,14 +13760,19 @@ declare function qtparam(BASEURL: string, cookie: string): Promise<{
|
|
|
13760
13760
|
isvip: false;
|
|
13761
13761
|
}>;
|
|
13762
13762
|
|
|
13763
|
+
declare function wbi_sign(BASEURL: string | URL, cookie: string): Promise<string>;
|
|
13764
|
+
|
|
13765
|
+
interface BilibiliRequest<T extends keyof BilibiliDataOptionsMap> extends Request {
|
|
13766
|
+
query: {
|
|
13767
|
+
[K in keyof OmitMethodType<BilibiliDataOptionsMap[T]['opt']>]: string;
|
|
13768
|
+
};
|
|
13769
|
+
}
|
|
13763
13770
|
/**
|
|
13764
13771
|
* 注册B站相关的API接口路由
|
|
13765
13772
|
* @param cookie - 有效的cookie
|
|
13766
13773
|
*/
|
|
13767
13774
|
declare const registerBilibiliRoutes: (cookie: string) => Router;
|
|
13768
13775
|
|
|
13769
|
-
declare function wbi_sign(BASEURL: string | URL, cookie: string): Promise<string>;
|
|
13770
|
-
|
|
13771
13776
|
declare function av2bv(aid: number): `BV1${string}`;
|
|
13772
13777
|
declare function bv2av(bvid: string): number;
|
|
13773
13778
|
|
|
@@ -13794,12 +13799,6 @@ declare const douyinAPI: DouyinAPI;
|
|
|
13794
13799
|
|
|
13795
13800
|
declare const DouyinData: <T extends keyof DouyinDataOptionsMap>(data: DouyinDataOptionsMap[T]["opt"], cookie?: string) => Promise<any>;
|
|
13796
13801
|
|
|
13797
|
-
/**
|
|
13798
|
-
* 注册抖音相关的API接口路由
|
|
13799
|
-
* @param cookie - 有效的cookie
|
|
13800
|
-
*/
|
|
13801
|
-
declare const registerDouyinRoutes: (cookie: string) => Router;
|
|
13802
|
-
|
|
13803
13802
|
declare class douyinSign {
|
|
13804
13803
|
/** 生成一个指定长度的随机字符串 */
|
|
13805
13804
|
static Mstoken(length: number): string;
|
|
@@ -13809,6 +13808,17 @@ declare class douyinSign {
|
|
|
13809
13808
|
static VerifyFpManager(): string;
|
|
13810
13809
|
}
|
|
13811
13810
|
|
|
13811
|
+
interface DouyinRequest<T extends keyof DouyinDataOptionsMap> extends Request {
|
|
13812
|
+
query: {
|
|
13813
|
+
[K in keyof OmitMethodType<DouyinDataOptionsMap[T]['opt']>]: string;
|
|
13814
|
+
};
|
|
13815
|
+
}
|
|
13816
|
+
/**
|
|
13817
|
+
* 注册抖音相关的API接口路由
|
|
13818
|
+
* @param cookie - 有效的cookie
|
|
13819
|
+
*/
|
|
13820
|
+
declare const registerDouyinRoutes: (cookie: string) => Router;
|
|
13821
|
+
|
|
13812
13822
|
type KuaishouMethodOptionsWithoutMethodType = {
|
|
13813
13823
|
[K in keyof KuaishouMethodOptionsMap]: OmitMethodType<KuaishouMethodOptionsMap[K]>;
|
|
13814
13824
|
};
|
|
@@ -13857,7 +13867,9 @@ declare const KuaishouAPI: API;
|
|
|
13857
13867
|
declare const KuaishouData: <T extends keyof KuaishouDataOptionsMap>(data: KuaishouDataOptionsMap[T]["opt"], cookie?: string) => Promise<any>;
|
|
13858
13868
|
|
|
13859
13869
|
interface KusiahouRequest<T extends keyof KuaishouDataOptionsMap> extends Request {
|
|
13860
|
-
query:
|
|
13870
|
+
query: {
|
|
13871
|
+
[K in keyof OmitMethodType<KuaishouDataOptionsMap[T]['opt']>]: string;
|
|
13872
|
+
};
|
|
13861
13873
|
}
|
|
13862
13874
|
/**
|
|
13863
13875
|
* 注册快手相关的API接口路由
|
|
@@ -13963,4 +13975,4 @@ declare class amagi {
|
|
|
13963
13975
|
|
|
13964
13976
|
declare function Amagi(options: ckParams): amagi;
|
|
13965
13977
|
|
|
13966
|
-
export { Amagi, type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, BilibiliValidateData, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
|
13978
|
+
export { Amagi, type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, type BilibiliRequest, BilibiliValidateData, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type DouyinRequest, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikenxuan/amagi",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.6",
|
|
4
4
|
"description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"douyin",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"import": "./dist/default/esm/index.mjs",
|
|
24
24
|
"require": "./dist/default/cjs/index.cjs"
|
|
25
25
|
},
|
|
26
|
-
"./
|
|
27
|
-
"types": "./dist/exports/
|
|
28
|
-
"import": "./dist/exports/
|
|
29
|
-
"require": "./dist/exports/
|
|
26
|
+
"./express": {
|
|
27
|
+
"types": "./dist/exports/express.d.ts",
|
|
28
|
+
"import": "./dist/exports/express.js",
|
|
29
|
+
"require": "./dist/exports/express.cjs"
|
|
30
30
|
},
|
|
31
31
|
"./axios": {
|
|
32
32
|
"types": "./dist/exports/axios.d.ts",
|