koishi-plugin-cat-raising 1.3.4 → 1.3.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/lib/index.js +29 -89
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -237,28 +237,47 @@ async function fetchBilibiliInfo(ctx, roomId) {
|
|
|
237
237
|
let uid;
|
|
238
238
|
let anchorName = "未知";
|
|
239
239
|
try {
|
|
240
|
-
const
|
|
241
|
-
`https://api.live.bilibili.com/
|
|
240
|
+
const anchorInRoom = await ctx.http.get(
|
|
241
|
+
`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${roomId}`,
|
|
242
242
|
{ headers: commonHeaders }
|
|
243
243
|
);
|
|
244
|
-
uid =
|
|
245
|
-
anchorName =
|
|
244
|
+
uid = anchorInRoom?.data?.info?.uid || uid;
|
|
245
|
+
anchorName = anchorInRoom?.data?.info?.uname || anchorName;
|
|
246
246
|
} catch {
|
|
247
247
|
}
|
|
248
248
|
if (!uid || anchorName === "未知") {
|
|
249
249
|
try {
|
|
250
|
-
const
|
|
251
|
-
`https://api.live.bilibili.com/room/v1/Room/
|
|
250
|
+
const roomInfo = await ctx.http.get(
|
|
251
|
+
`https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomId}`,
|
|
252
252
|
{ headers: commonHeaders }
|
|
253
253
|
);
|
|
254
|
-
uid =
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
uid = roomInfo?.data?.uid || uid;
|
|
255
|
+
anchorName = roomInfo?.data?.uname || anchorName;
|
|
256
|
+
} catch {
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (anchorName === "未知" || !uid) {
|
|
260
|
+
await sleep(300);
|
|
261
|
+
try {
|
|
262
|
+
const anchorInRoom2 = await ctx.http.get(
|
|
263
|
+
`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${roomId}`,
|
|
257
264
|
{ headers: commonHeaders }
|
|
258
265
|
);
|
|
259
|
-
|
|
266
|
+
uid = uid || anchorInRoom2?.data?.info?.uid;
|
|
267
|
+
anchorName = anchorInRoom2?.data?.info?.uname || anchorName;
|
|
260
268
|
} catch {
|
|
261
269
|
}
|
|
270
|
+
if (!uid || anchorName === "未知") {
|
|
271
|
+
try {
|
|
272
|
+
const roomInfo2 = await ctx.http.get(
|
|
273
|
+
`https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomId}`,
|
|
274
|
+
{ headers: commonHeaders }
|
|
275
|
+
);
|
|
276
|
+
uid = uid || roomInfo2?.data?.uid;
|
|
277
|
+
anchorName = roomInfo2?.data?.uname || anchorName;
|
|
278
|
+
} catch {
|
|
279
|
+
}
|
|
280
|
+
}
|
|
262
281
|
}
|
|
263
282
|
if (!uid) throw new Error("无法从房间信息中获取UID");
|
|
264
283
|
const statsInfo = await ctx.http.get(
|
|
@@ -273,85 +292,6 @@ async function fetchBilibiliInfo(ctx, roomId) {
|
|
|
273
292
|
);
|
|
274
293
|
const videoCount = statsInfo?.data?.video;
|
|
275
294
|
if (videoCount === void 0) throw new Error("无法从空间信息中获取投稿数");
|
|
276
|
-
try {
|
|
277
|
-
const anchorInfo = await ctx.http.get(
|
|
278
|
-
`https://api.bilibili.com/x/space/acc/info?mid=${uid}`,
|
|
279
|
-
{
|
|
280
|
-
headers: {
|
|
281
|
-
...commonHeaders,
|
|
282
|
-
Origin: "https://space.bilibili.com",
|
|
283
|
-
Referer: `https://space.bilibili.com/${uid}`
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
);
|
|
287
|
-
anchorName = anchorInfo?.data?.name || anchorName;
|
|
288
|
-
} catch {
|
|
289
|
-
}
|
|
290
|
-
if (anchorName === "未知") {
|
|
291
|
-
try {
|
|
292
|
-
const liveUser = await ctx.http.get(
|
|
293
|
-
`https://api.live.bilibili.com/live_user/v3/UserInfo/get_info?uid=${uid}`,
|
|
294
|
-
{
|
|
295
|
-
headers: {
|
|
296
|
-
...commonHeaders,
|
|
297
|
-
Origin: "https://live.bilibili.com",
|
|
298
|
-
Referer: `https://live.bilibili.com/${roomId}`
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
anchorName = liveUser?.data?.info?.uname || anchorName;
|
|
303
|
-
} catch {
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (anchorName === "未知") {
|
|
307
|
-
try {
|
|
308
|
-
const baseInfo = await ctx.http.get(
|
|
309
|
-
`https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomBaseInfo?room_id=${roomId}`,
|
|
310
|
-
{ headers: commonHeaders }
|
|
311
|
-
);
|
|
312
|
-
anchorName = baseInfo?.data?.anchor_info?.base_info?.uname || baseInfo?.data?.anchor_info?.uname || baseInfo?.data?.room_info?.uname || baseInfo?.data?.uname || anchorName;
|
|
313
|
-
} catch {
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (anchorName === "未知") {
|
|
317
|
-
await sleep(300);
|
|
318
|
-
try {
|
|
319
|
-
const infoByRoom2 = await ctx.http.get(
|
|
320
|
-
`https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=${roomId}`,
|
|
321
|
-
{ headers: commonHeaders }
|
|
322
|
-
);
|
|
323
|
-
anchorName = infoByRoom2?.data?.anchor_info?.base_info?.uname || infoByRoom2?.data?.anchor_info?.uname || anchorName;
|
|
324
|
-
} catch {
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
const anchorInfo2 = await ctx.http.get(
|
|
328
|
-
`https://api.bilibili.com/x/space/acc/info?mid=${uid}`,
|
|
329
|
-
{
|
|
330
|
-
headers: {
|
|
331
|
-
...commonHeaders,
|
|
332
|
-
Origin: "https://space.bilibili.com",
|
|
333
|
-
Referer: `https://space.bilibili.com/${uid}`
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
);
|
|
337
|
-
anchorName = anchorInfo2?.data?.name || anchorName;
|
|
338
|
-
} catch {
|
|
339
|
-
}
|
|
340
|
-
try {
|
|
341
|
-
const liveUser2 = await ctx.http.get(
|
|
342
|
-
`https://api.live.bilibili.com/live_user/v3/UserInfo/get_info?uid=${uid}`,
|
|
343
|
-
{
|
|
344
|
-
headers: {
|
|
345
|
-
...commonHeaders,
|
|
346
|
-
Origin: "https://live.bilibili.com",
|
|
347
|
-
Referer: `https://live.bilibili.com/${roomId}`
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
);
|
|
351
|
-
anchorName = liveUser2?.data?.info?.uname || anchorName;
|
|
352
|
-
} catch {
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
295
|
return { videoCount, anchorName };
|
|
356
296
|
} catch (error) {
|
|
357
297
|
const status = error?.response?.status;
|