@ikenxuan/amagi 1.5.4 → 1.5.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.
@@ -22,7 +22,7 @@ export default class BilibiliData {
22
22
  url: BiLiBiLiAPI.视频流信息({ avid: INFODATA.data.aid, cid: INFODATA.data.cid }) + SIGN.QUERY,
23
23
  headers: this.headers
24
24
  });
25
- return { INFODATA, DATA, };
25
+ return { INFODATA, DATA };
26
26
  }
27
27
  case 'CommentData': {
28
28
  const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.bvid }) });
@@ -94,6 +94,8 @@ export default class BilibiliData {
94
94
  });
95
95
  return result;
96
96
  }
97
+ default:
98
+ return null;
97
99
  }
98
100
  }
99
101
  async GlobalGetData(options) {
@@ -108,30 +110,6 @@ export default class BilibiliData {
108
110
  }
109
111
  }
110
112
  }
111
- function mapping_table(type) {
112
- // 使用类型断言来告诉 TypeScript 编译器 Array 对象实际上是一个可以接受字符串索引的对象
113
- const Array = {
114
- 1: ['DYNAMIC_TYPE_AV', 'DYNAMIC_TYPE_PGC', 'DYNAMIC_TYPE_UGC_SEASON'],
115
- 11: ['DYNAMIC_TYPE_DRAW'],
116
- 12: ['DYNAMIC_TYPE_ARTICLE'],
117
- 17: ['DYNAMIC_TYPE_LIVE_RCMD', 'DYNAMIC_TYPE_FORWARD', 'DYNAMIC_TYPE_WORD', 'DYNAMIC_TYPE_COMMON_SQUARE'],
118
- 19: ['DYNAMIC_TYPE_MEDIALIST']
119
- };
120
- for (const key in Array) {
121
- if (Array[key].includes(type)) {
122
- return parseInt(key);
123
- }
124
- }
125
- return 1;
126
- }
127
- function oid(dynamicINFO, dynamicINFO_CARD) {
128
- if (dynamicINFO.data.item.type == 'DYNAMIC_TYPE_WORD') {
129
- return dynamicINFO.data.item.id_str;
130
- }
131
- else
132
- return dynamicINFO_CARD.data.card.desc.rid;
133
- }
134
- // 同上
135
113
  const errorMap = {
136
114
  '-1': '应用程序不存在或已被封禁',
137
115
  '-2': 'Access Key 错误',
@@ -12,7 +12,7 @@ export default async function GetBilibiliID(url) {
12
12
  const bvideoMatch = longLink.match(/video\/([A-Za-z0-9]+)/);
13
13
  result = {
14
14
  type: "VideoData" /* BilibiliDataType['单个视频作品数据'] */,
15
- id: bvideoMatch ? bvideoMatch[1] : '',
15
+ id: bvideoMatch ? bvideoMatch[1] : ''
16
16
  };
17
17
  break;
18
18
  }
@@ -20,7 +20,7 @@ export default async function GetBilibiliID(url) {
20
20
  const playMatch = longLink.match(/play\/(\w+)/);
21
21
  result = {
22
22
  type: "BangumiVideoData" /* BilibiliDataType['番剧基本信息数据'] */,
23
- id: playMatch ? playMatch[1] : '',
23
+ id: playMatch ? playMatch[1] : ''
24
24
  };
25
25
  break;
26
26
  }
@@ -30,7 +30,7 @@ export default async function GetBilibiliID(url) {
30
30
  const dynamic_id = tMatch || opusMatch;
31
31
  result = {
32
32
  type: "DynamicInfoData" /* BilibiliDataType['动态详情数据'] */,
33
- dynamic_id: dynamic_id ? dynamic_id[1] : '',
33
+ dynamic_id: dynamic_id ? dynamic_id[1] : ''
34
34
  };
35
35
  break;
36
36
  }
@@ -34,7 +34,7 @@ export default class BilibiliResult {
34
34
  return {
35
35
  code: result !== false && result !== '' ? 200 : 503,
36
36
  message: result !== !false && result !== '' ? 'success' : 'error',
37
- data: result !== !false && result !== '' ? result : null,
37
+ data: result !== !false && result !== '' ? result : null
38
38
  };
39
39
  }
40
40
  }
@@ -2,7 +2,7 @@ import md5 from 'md5';
2
2
  import fetch from 'node-fetch';
3
3
  const mixinKeyEncTab = [
4
4
  46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26,
5
- 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52,
5
+ 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52
6
6
  ];
7
7
  // 对 imgKey 和 subKey 进行字符顺序打乱编码
8
8
  const getMixinKey = (orig) => mixinKeyEncTab
@@ -31,16 +31,16 @@ function encWbi(params, img_key, sub_key) {
31
31
  async function getWbiKeys(cookie) {
32
32
  const res = await fetch('https://api.bilibili.com/x/web-interface/nav', {
33
33
  headers: {
34
- Cookie: cookie,
35
- },
34
+ Cookie: cookie
35
+ }
36
36
  });
37
37
  const responseJson = await res.json();
38
38
  const response = responseJson; // 类型断言
39
39
  // 确保response是ResponseData类型后再解构
40
- const { data: { wbi_img: { img_url, sub_url }, }, } = response;
40
+ const { data: { wbi_img: { img_url, sub_url } } } = response;
41
41
  return {
42
42
  img_key: img_url.slice(img_url.lastIndexOf('/') + 1, img_url.lastIndexOf('.')),
43
- sub_key: sub_url.slice(sub_url.lastIndexOf('/') + 1, sub_url.lastIndexOf('.')),
43
+ sub_key: sub_url.slice(sub_url.lastIndexOf('/') + 1, sub_url.lastIndexOf('.'))
44
44
  };
45
45
  }
46
46
  export default async function wbi_sign(BASEURL, cookie) {
@@ -6,10 +6,14 @@ export default class DouyinData {
6
6
  URL;
7
7
  constructor(type, cookie) {
8
8
  this.type = type;
9
- this.headers = {};
10
- this.headers.Referer = 'https://www.douyin.com/';
11
- this.headers.Cookie = cookie,
12
- this.headers['Content-Type'] = 'application/json';
9
+ this.headers = {
10
+ Referer: 'https://www.douyin.com/',
11
+ Cookie: cookie,
12
+ Accept: '*/*',
13
+ 'Content-Type': 'application/json',
14
+ 'Accpet-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
15
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'
16
+ };
13
17
  }
14
18
  async GetData(data = {}) {
15
19
  switch (this.type) {
@@ -19,21 +23,21 @@ export default class DouyinData {
19
23
  const VideoData = await this.GlobalGetData({
20
24
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
21
25
  method: 'GET',
22
- headers: this.headers,
26
+ headers: this.headers
23
27
  });
24
28
  return VideoData;
25
29
  case 'CommentData':
26
30
  this.URL = DouyinAPI.评论({ aweme_id: data.aweme_id });
27
31
  const CommentsData = await this.GlobalGetData({
28
32
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
29
- headers: this.headers,
33
+ headers: this.headers
30
34
  });
31
35
  return CommentsData;
32
36
  case 'CommentReplyData':
33
37
  this.URL = DouyinAPI.二级评论({ aweme_id: data.aweme_id, comment_id: data.comment_id });
34
38
  const CommentReplyData = await this.GlobalGetData({
35
39
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
36
- headers: this.headers,
40
+ headers: this.headers
37
41
  });
38
42
  return CommentReplyData;
39
43
  case 'UserInfoData':
@@ -42,15 +46,15 @@ export default class DouyinData {
42
46
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
43
47
  headers: {
44
48
  ...this.headers,
45
- Referer: `https://www.douyin.com/user/${data.sec_uid}`,
46
- },
49
+ Referer: `https://www.douyin.com/user/${data.sec_uid}`
50
+ }
47
51
  });
48
52
  return UserInfoData;
49
53
  case 'EmojiData':
50
54
  this.URL = DouyinAPI.表情();
51
55
  const EmojiData = await this.GlobalGetData({
52
56
  url: this.URL,
53
- headers: this.headers,
57
+ headers: this.headers
54
58
  });
55
59
  return EmojiData;
56
60
  case 'UserVideosListData':
@@ -59,8 +63,8 @@ export default class DouyinData {
59
63
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
60
64
  headers: {
61
65
  ...this.headers,
62
- Referer: `https://www.douyin.com/user/${data.sec_uid}`,
63
- },
66
+ Referer: `https://www.douyin.com/user/${data.sec_uid}`
67
+ }
64
68
  });
65
69
  return UserVideoListData;
66
70
  case 'SuggestWordsData':
@@ -69,8 +73,8 @@ export default class DouyinData {
69
73
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
70
74
  headers: {
71
75
  ...this.headers,
72
- Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
73
- },
76
+ Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`
77
+ }
74
78
  });
75
79
  return SuggestWordsData;
76
80
  case 'SearchData':
@@ -79,22 +83,22 @@ export default class DouyinData {
79
83
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
80
84
  headers: {
81
85
  ...this.headers,
82
- Referer: `https://www.douyin.com/https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
83
- },
86
+ Referer: `https://www.douyin.com/https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`
87
+ }
84
88
  });
85
89
  return SearchData;
86
90
  case 'ExpressionPlusData':
87
91
  this.URL = DouyinAPI.互动表情();
88
92
  const ExpressionPlusData = await this.GlobalGetData({
89
93
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
90
- headers: this.headers,
94
+ headers: this.headers
91
95
  });
92
96
  return ExpressionPlusData;
93
97
  case 'MusicData':
94
98
  this.URL = DouyinAPI.背景音乐({ music_id: data.music_id });
95
99
  const MusicData = await this.GlobalGetData({
96
100
  url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
97
- headers: this.headers,
101
+ headers: this.headers
98
102
  });
99
103
  return MusicData;
100
104
  default:
@@ -12,21 +12,21 @@ export default async function GetDouyinID(url) {
12
12
  const videoMatch = longLink.match(/video\/(\d+)/);
13
13
  result = {
14
14
  type: "VideoData" /* DouyinDataType['单个视频作品数据'] */,
15
- aweme_id: videoMatch ? videoMatch[1] : '',
15
+ aweme_id: videoMatch ? videoMatch[1] : ''
16
16
  };
17
17
  break;
18
18
  case /note\/(\d+)/.test(longLink):
19
19
  const noteMatch = longLink.match(/note\/(\d+)/);
20
20
  result = {
21
21
  type: "NoteData" /* DouyinDataType['图集作品数据'] */,
22
- aweme_id: noteMatch ? noteMatch[1] : '',
22
+ aweme_id: noteMatch ? noteMatch[1] : ''
23
23
  };
24
24
  break;
25
25
  case /user\/(\S+?)\?/.test(longLink):
26
26
  const userMatch = longLink.match(/user\/(\S+?)\?/);
27
27
  result = {
28
28
  type: "UserVideosListData" /* DouyinDataType['用户主页视频列表数据'] */,
29
- sec_uid: userMatch ? userMatch[1] : '',
29
+ sec_uid: userMatch ? userMatch[1] : ''
30
30
  };
31
31
  break;
32
32
  default:
@@ -35,7 +35,7 @@ export default class DouyinResult {
35
35
  return {
36
36
  code: result !== false && result !== '' ? 200 : 503,
37
37
  message: result !== false && result !== '' ? 'success' : 'error',
38
- data: result !== false && result !== '' ? result : null,
38
+ data: result !== false && result !== '' ? result : null
39
39
  };
40
40
  }
41
41
  }
@@ -1,50 +1,2 @@
1
- export declare class ABogus {
2
- filter: RegExp;
3
- arguments: number[];
4
- ua_key: string;
5
- end_string: string;
6
- version: number[];
7
- browser: string;
8
- reg: number[];
9
- str: any;
10
- chunk: number[];
11
- size: number;
12
- ua_code: number[];
13
- browser_len: number;
14
- browser_code: number[];
15
- constructor(platform?: string | null);
16
- list_1(random_num?: number | null, a?: number, b?: number, c?: number): number[];
17
- list_2(random_num?: number | null, a?: number, b?: number): number[];
18
- list_3(random_num?: number | null, a?: number, b?: number): number[];
19
- random_list(a?: number | null, b?: number, c?: number, d?: number, e?: number, f?: number, g?: number): number[];
20
- from_char_code(...args: number[]): string;
21
- generate_string_1(random_num_1?: number | null, random_num_2?: number | null, random_num_3?: number | null): string;
22
- generate_string_2(url_params: string, method?: string, start_time?: number, end_time?: number): string;
23
- generate_string_2_list(url_params: string, method?: string, start_time?: number, end_time?: number): number[];
24
- reg_to_array(a: number[]): number[];
25
- compress(a: number[]): void;
26
- generate_f(e: number[]): number[];
27
- generate_params_code(url_params: string): number[];
28
- generate_method_code(method: string): number[];
29
- sm3ToArray(data: string | number[]): number[];
30
- generate_params(url_params: string): string;
31
- generate_method(method: string): string;
32
- char_code_at(str: string): number[];
33
- de(a: number, b: number): number;
34
- pe(a: number): number;
35
- ve(a: number, b: number, c: number, d: number): number;
36
- he(a: number, b: number, c: number, d: number): number;
37
- end_check_num(a: number[]): number;
38
- tobase(a: number): string;
39
- rc4_encrypt(a: string, b: string): string;
40
- rc4_key_schedule(b: string): number[];
41
- list_4(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number): number[];
42
- generate_browser_info(platform: string): string;
43
- getABogus(url: string, method: string, start_time: number, end_time: number): string;
44
- get_reg(): string;
45
- get_value(url_params?: string, method?: string, start_time?: number, end_time?: number, random_num_1?: number | null, random_num_2?: number | null, random_num_3?: number | null): string;
46
- generateString(url_params: any, method: string, start_time: number, end_time: number): string;
47
- generate_result(s: string, e?: string): string;
48
- }
49
- declare const _default: (url: string, ua: string) => string;
1
+ declare const _default: (url: string, user_agent: string) => string;
50
2
  export default _default;