@ikenxuan/amagi 4.4.4 → 4.4.5

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.
@@ -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) => {
@@ -559,113 +666,6 @@ var registerBilibiliRoutes = (cookie) => {
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;
@@ -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) => {
@@ -547,113 +654,6 @@ var registerBilibiliRoutes = (cookie) => {
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;
@@ -13760,14 +13760,18 @@ 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
+ /** @ts-ignore */
13766
+ interface BilibiliRequest<T extends keyof BilibiliDataOptionsMap> extends Request {
13767
+ query: Omit<BilibiliDataOptionsMap[T]['opt'], 'methodType'>;
13768
+ }
13763
13769
  /**
13764
13770
  * 注册B站相关的API接口路由
13765
13771
  * @param cookie - 有效的cookie
13766
13772
  */
13767
13773
  declare const registerBilibiliRoutes: (cookie: string) => Router;
13768
13774
 
13769
- declare function wbi_sign(BASEURL: string | URL, cookie: string): Promise<string>;
13770
-
13771
13775
  declare function av2bv(aid: number): `BV1${string}`;
13772
13776
  declare function bv2av(bvid: string): number;
13773
13777
 
@@ -13794,12 +13798,6 @@ declare const douyinAPI: DouyinAPI;
13794
13798
 
13795
13799
  declare const DouyinData: <T extends keyof DouyinDataOptionsMap>(data: DouyinDataOptionsMap[T]["opt"], cookie?: string) => Promise<any>;
13796
13800
 
13797
- /**
13798
- * 注册抖音相关的API接口路由
13799
- * @param cookie - 有效的cookie
13800
- */
13801
- declare const registerDouyinRoutes: (cookie: string) => Router;
13802
-
13803
13801
  declare class douyinSign {
13804
13802
  /** 生成一个指定长度的随机字符串 */
13805
13803
  static Mstoken(length: number): string;
@@ -13809,6 +13807,16 @@ declare class douyinSign {
13809
13807
  static VerifyFpManager(): string;
13810
13808
  }
13811
13809
 
13810
+ /** @ts-ignore */
13811
+ interface DouyinRequest<T extends keyof DouyinDataOptionsMap> extends Request {
13812
+ query: Omit<DouyinDataOptionsMap[T]['opt'], 'methodType'>;
13813
+ }
13814
+ /**
13815
+ * 注册抖音相关的API接口路由
13816
+ * @param cookie - 有效的cookie
13817
+ */
13818
+ declare const registerDouyinRoutes: (cookie: string) => Router;
13819
+
13812
13820
  type KuaishouMethodOptionsWithoutMethodType = {
13813
13821
  [K in keyof KuaishouMethodOptionsMap]: OmitMethodType<KuaishouMethodOptionsMap[K]>;
13814
13822
  };
@@ -13856,6 +13864,7 @@ declare const KuaishouAPI: API;
13856
13864
 
13857
13865
  declare const KuaishouData: <T extends keyof KuaishouDataOptionsMap>(data: KuaishouDataOptionsMap[T]["opt"], cookie?: string) => Promise<any>;
13858
13866
 
13867
+ /** @ts-ignore */
13859
13868
  interface KusiahouRequest<T extends keyof KuaishouDataOptionsMap> extends Request {
13860
13869
  query: Omit<KuaishouDataOptionsMap[T]['opt'], 'methodType'>;
13861
13870
  }
@@ -13963,4 +13972,4 @@ declare class amagi {
13963
13972
 
13964
13973
  declare function Amagi(options: ckParams): amagi;
13965
13974
 
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 };
13975
+ 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.4",
3
+ "version": "4.4.5",
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
- "./fastify": {
27
- "types": "./dist/exports/fastify.d.ts",
28
- "import": "./dist/exports/fastify.js",
29
- "require": "./dist/exports/fastify.cjs"
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",