@ikenxuan/amagi 2.1.3 → 2.1.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.
package/README.md CHANGED
@@ -56,6 +56,9 @@ pnpm build
56
56
  [GPL-3.0](https://github.com/ikenxuan/amagi/blob/main/LICENSE)
57
57
 
58
58
  ## 声明
59
+ 本库没有后门,本库不会上传有关你的任何信息到第三方。
60
+ 所配置的ck只会用于请求官方API接口
61
+
59
62
  该项目代码从 [kkkkkk-10086](https://github.com/ikenxuan/kkkkkk-10086) 提取修改并发布
60
63
 
61
64
  <h2>未经同意,禁止将本项目的开源代码用于任何商业目的。因使用本项目产生的一切问题与后果由使用者自行承担,项目开发者不承担任何责任</h2>
@@ -8,7 +8,7 @@ export default class BilibiliData {
8
8
  this.type = type;
9
9
  this.headers = {};
10
10
  this.headers.Referer = 'https://api.bilibili.com/';
11
- this.headers.Cookie = cookie.replace(/\s+/g, '');
11
+ this.headers.Cookie = cookie ? cookie.replace(/\s+/g, '') : '';
12
12
  this.headers['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';
13
13
  }
14
14
  async GetData(data = {}) {
@@ -35,7 +35,7 @@ export default class BilibiliData {
35
35
  else {
36
36
  const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.bvid }) });
37
37
  const PARAM = await wbi_sign(BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid }), this.headers.Cookie);
38
- COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid, number: data.number }) + PARAM, headers: this.headers });
38
+ COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ commentstype: 1, oid: INFODATA.data.aid, number: data.number }) + PARAM, headers: this.headers });
39
39
  }
40
40
  return COMMENTSDATA;
41
41
  }
@@ -8,7 +8,7 @@ export default class DouyinData {
8
8
  this.type = type;
9
9
  this.headers = {
10
10
  Referer: 'https://www.douyin.com/',
11
- Cookie: cookie.replace(/\s+/g, ''),
11
+ Cookie: cookie ? cookie.replace(/\s+/g, '') : '',
12
12
  Accept: '*/*',
13
13
  'Content-Type': 'application/json',
14
14
  'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
@@ -8,27 +8,39 @@ export default async function GetDouyinID(url) {
8
8
  const longLink = await new Networks({ url }).getLongLink();
9
9
  let result = {};
10
10
  switch (true) {
11
- case /video\/(\d+)/.test(longLink):
11
+ case /share\/slides\/(\d+)/.test(longLink): {
12
+ const newres = await new Networks({ url }).getLocation();
13
+ const match = newres.match(/share\/slides\/(\d+)/);
14
+ result = {
15
+ type: "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */,
16
+ aweme_id: match ? match[1] : '',
17
+ };
18
+ break;
19
+ }
20
+ case /video\/(\d+)/.test(longLink): {
12
21
  const videoMatch = longLink.match(/video\/(\d+)/);
13
22
  result = {
14
- type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType['单个视频作品数据'] */,
23
+ type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */,
15
24
  aweme_id: videoMatch ? videoMatch[1] : ''
16
25
  };
17
26
  break;
18
- case /note\/(\d+)/.test(longLink):
27
+ }
28
+ case /note\/(\d+)/.test(longLink): {
19
29
  const noteMatch = longLink.match(/note\/(\d+)/);
20
30
  result = {
21
- type: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType['图集作品数据'] */,
31
+ type: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.图集作品数据 */,
22
32
  aweme_id: noteMatch ? noteMatch[1] : ''
23
33
  };
24
34
  break;
25
- case /user\/(\S+?)\?/.test(longLink):
35
+ }
36
+ case /user\/(\S+?)\?/.test(longLink): {
26
37
  const userMatch = longLink.match(/user\/(\S+?)\?/);
27
38
  result = {
28
- type: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType['用户主页视频列表数据'] */,
39
+ type: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType.用户主页视频列表数据 */,
29
40
  sec_uid: userMatch ? userMatch[1] : ''
30
41
  };
31
42
  break;
43
+ }
32
44
  default:
33
45
  break;
34
46
  }
@@ -10,9 +10,9 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
10
10
  case "\u5B98\u65B9emoji\u6570\u636E" /* DouyinDataType.官方emoji数据 */:
11
11
  case "\u52A8\u6001\u8868\u60C5\u6570\u636E" /* DouyinDataType.动态表情数据 */:
12
12
  case "\u97F3\u4E50\u6570\u636E" /* DouyinDataType.音乐数据 */:
13
- case "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */:
14
13
  result = await new DouyinData(config.type, config.cookie).GetData(options);
15
14
  break;
15
+ case "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */:
16
16
  case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */:
17
17
  case "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.图集作品数据 */:
18
18
  case "\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */: {
@@ -21,8 +21,7 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
21
21
  result = await new DouyinData(config.type, config.cookie).GetData({ aweme_id: options.aweme_id, number: options.number });
22
22
  }
23
23
  else {
24
- const defurl = options.url?.toString().match(/(http|https):\/\/.*\.(douyin|iesdouyin)\.com\/[^ ]+/g);
25
- const iddata = await GetDouyinID(String(defurl));
24
+ const iddata = await GetDouyinID(String(options.url));
26
25
  result = await new DouyinData(config.type, config.cookie).GetData(iddata);
27
26
  }
28
27
  break;
@@ -24,7 +24,8 @@ export default class Networks {
24
24
  // 创建axios实例
25
25
  this.axiosInstance = axios.create({
26
26
  timeout: this.timeout,
27
- headers: this.headers
27
+ headers: this.headers,
28
+ maxRedirects: 5
28
29
  })
29
30
  }
30
31
  get config () {
@@ -58,8 +59,11 @@ export default class Networks {
58
59
  /** 最终地址(跟随重定向) */
59
60
  async getLongLink () {
60
61
  try {
61
- const result = await this.returnResult()
62
- return result.request.res.responseUrl // axios中获取最终的请求URL
62
+ const response = await this.axiosInstance({
63
+ method: 'GET',
64
+ url: this.url
65
+ })
66
+ return response.request.res.responseUrl // axios中获取最终的请求URL
63
67
  }
64
68
  catch (error) {
65
69
  if (error instanceof AxiosError) {
@@ -116,7 +120,7 @@ export default class Networks {
116
120
  async getHeadersAndData () {
117
121
  try {
118
122
  // 发起网络请求获取响应对象
119
- const result = await this.axiosInstance.get(this.config)
123
+ const result = await this.axiosInstance(this.config)
120
124
  // 初始化响应头和响应数据
121
125
  let headers = {}
122
126
  const fetchHeaders = result.headers
@@ -122,7 +122,7 @@ export class client {
122
122
  client.get('/api/bilibili/login', async (request, reply) => {
123
123
  reply.type('application/json').send(await BilibiliResult({
124
124
  type: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" /* BilibiliDataType.登录基本信息 */,
125
- cookie: request.query.cookie
125
+ cookie: request.headers.cookie
126
126
  }, {}))
127
127
  })
128
128
  client.get('/api/bilibili/work', async (request, reply) => {
@@ -135,7 +135,7 @@ export class client {
135
135
  reply.type('application/json').send(await BilibiliResult({
136
136
  type: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.单个视频下载信息数据 */,
137
137
  cookie: this.bilibili
138
- }, { url: request.query.url }))
138
+ }, { avid: request.query.avid, cid: request.query.cid }))
139
139
  })
140
140
  client.get('/api/bilibili/comment', async (request, reply) => {
141
141
  reply.type('application/json').send(await BilibiliResult({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikenxuan/amagi",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",