floating-live 0.14.11 → 0.15.0-beta.0

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.
Files changed (64) hide show
  1. package/LICENSE +5 -670
  2. package/{src/abstract → dist/core}/LiveRoom.d.ts +1 -1
  3. package/{src/abstract → dist/core}/LiveRoom.js +6 -6
  4. package/{src/abstract → dist/core}/Reglist.d.ts +1 -1
  5. package/dist/core/index.d.ts +2 -0
  6. package/dist/core/index.js +18 -0
  7. package/dist/index.d.ts +6 -0
  8. package/{index.js → dist/index.js} +7 -7
  9. package/{src → dist}/module/ModAuth.d.ts +2 -2
  10. package/{src → dist}/module/ModAuth.js +1 -1
  11. package/{src → dist}/module/ModCommand.d.ts +2 -2
  12. package/{src → dist}/module/ModCommand.js +1 -1
  13. package/{src → dist}/module/ModMessage.d.ts +2 -2
  14. package/{src → dist}/module/ModMessage.js +1 -1
  15. package/{src → dist}/module/ModPlugin.d.ts +1 -1
  16. package/{src → dist}/module/ModRoom.d.ts +3 -3
  17. package/{src → dist}/module/ModRoom.js +1 -1
  18. package/{src → dist}/module/ModState.d.ts +2 -2
  19. package/{src → dist}/module/ModState.js +1 -1
  20. package/{src → dist}/types/message.d.ts +2 -2
  21. package/{src → dist}/types/plugin.d.ts +1 -1
  22. package/{src → dist}/types/room.d.ts +1 -1
  23. package/package.json +26 -5
  24. package/index.d.ts +0 -6
  25. package/plugin/acfun/acfunLive.d.ts +0 -74
  26. package/plugin/acfun/acfunLive.js +0 -279
  27. package/plugin/acfun/index.d.ts +0 -3
  28. package/plugin/acfun/index.js +0 -16
  29. package/plugin/bilibili/index.d.ts +0 -6
  30. package/plugin/bilibili/index.js +0 -45
  31. package/plugin/bilibili/parser.d.ts +0 -6
  32. package/plugin/bilibili/parser.js +0 -397
  33. package/plugin/bilibili/room.d.ts +0 -77
  34. package/plugin/bilibili/room.js +0 -261
  35. package/plugin/bilibili/types.d.ts +0 -424
  36. package/plugin/bilibili/types.js +0 -2
  37. package/plugin/bilibili/utils.d.ts +0 -17
  38. package/plugin/bilibili/utils.js +0 -137
  39. package/plugin/chatPrint/chatPrint.d.ts +0 -20
  40. package/plugin/chatPrint/chatPrint.js +0 -116
  41. package/plugin/chatPrint/index.d.ts +0 -7
  42. package/plugin/chatPrint/index.js +0 -10
  43. package/plugin/consoleEvent/index.d.ts +0 -6
  44. package/plugin/consoleEvent/index.js +0 -51
  45. package/plugin/msgSave/index.d.ts +0 -10
  46. package/plugin/msgSave/index.js +0 -81
  47. package/plugin/msgSave/msgSave.d.ts +0 -83
  48. package/plugin/msgSave/msgSave.js +0 -168
  49. package/test/type/bilibili_getInfoByRoom.d.ts +0 -492
  50. /package/{src/abstract → dist/core}/Reglist.js +0 -0
  51. /package/{src/enum.d.ts → dist/enums.d.ts} +0 -0
  52. /package/{src/enum.js → dist/enums.js} +0 -0
  53. /package/{src/index.d.ts → dist/live.d.ts} +0 -0
  54. /package/{src/index.js → dist/live.js} +0 -0
  55. /package/{src → dist}/module/ModPlugin.js +0 -0
  56. /package/{src → dist}/types/auth.d.ts +0 -0
  57. /package/{src → dist}/types/auth.js +0 -0
  58. /package/{src → dist}/types/index.d.ts +0 -0
  59. /package/{src → dist}/types/index.js +0 -0
  60. /package/{src → dist}/types/message.js +0 -0
  61. /package/{src → dist}/types/plugin.js +0 -0
  62. /package/{src → dist}/types/room.js +0 -0
  63. /package/{src → dist}/utils.d.ts +0 -0
  64. /package/{src → dist}/utils.js +0 -0
@@ -1,168 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const __1 = require("../..");
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- function getTimeStr(timestamp) {
10
- let startDate = new Date(timestamp);
11
- return `${startDate.getFullYear()}${(startDate.getMonth() + 1)
12
- .toString()
13
- .padStart(2, "0")}${startDate
14
- .getDate()
15
- .toString()
16
- .padStart(2, "0")}_${startDate
17
- .getHours()
18
- .toString()
19
- .padStart(2, "0")}${startDate
20
- .getMinutes()
21
- .toString()
22
- .padStart(2, "0")}${startDate.getSeconds().toString().padStart(2, "0")}`;
23
- }
24
- /** 获取当次记录状态
25
- * S=直播开始 L=直播中 E=直播结束 O=未开播
26
- */
27
- function getRecordStatus(status, statusChanged) {
28
- if (status == __1.RoomStatus.live) {
29
- /** 已开播 */
30
- return statusChanged ? "S" : "L";
31
- }
32
- else {
33
- /** 未开播 */
34
- return statusChanged ? "E" : "O";
35
- }
36
- }
37
- class SaveInfo {
38
- constructor({ platform, room, status, timestamp, statusChanged, sliceByStatus = false, sliceByCount = 0, }) {
39
- /** 文件是否存在 */
40
- this.exist = false;
41
- /** 记录状态是否已更改 */
42
- this.statusChanged = false;
43
- /** 消息记录数 */
44
- this.count = 0;
45
- /** 总消息记录数 */
46
- this.totalCount = 0;
47
- this.platform = platform;
48
- this.room = room;
49
- this.status = status;
50
- this.timestamp = timestamp;
51
- this.statusChanged = statusChanged;
52
- this.sliceByStatus = sliceByStatus;
53
- this.sliceByCount = sliceByCount;
54
- this.part = sliceByCount && 1;
55
- }
56
- /** 文件id */
57
- get fileId() {
58
- return `${this.platform}_${this.room}-${getTimeStr(this.timestamp || 0)}${this.sliceByStatus ? getRecordStatus(this.status, this.statusChanged) : ""}${this.part ? `.${this.part}` : ""}`;
59
- }
60
- /** 分块 */
61
- slice() {
62
- this.exist = false;
63
- this.count = 0;
64
- this.part += 1;
65
- }
66
- }
67
- class MsgSave {
68
- constructor(main, { filePath, prefix = "", suffix = "", open = true, sliceByStatus = false, sliceByCount = 0, }) {
69
- /** 列表 */
70
- this.list = new Map();
71
- this.paused = !open;
72
- this.main = main;
73
- this.path = filePath;
74
- this.prefix = prefix;
75
- this.suffix = suffix;
76
- this.sliceByStatus = sliceByStatus;
77
- this.sliceByCount = sliceByCount;
78
- }
79
- write(message, { platform, room }) {
80
- if (this.paused)
81
- return;
82
- const roomKey = `${platform}:${room}`;
83
- // 获取保存信息,若信息不存在,则设置一个信息
84
- const saveInfo = this.list.get(roomKey) || this.createSaveInfo({ platform, room });
85
- // 若文件不存在,则创建一个有record_info信息的.floatrec文件
86
- if (!saveInfo.exist)
87
- this.createFile(roomKey);
88
- const file = path_1.default.join(this.path, `${this.prefix}${saveInfo.fileId}${this.suffix}.floatrec`);
89
- fs_extra_1.default.writeFile(file, JSON.stringify(message) + ",", { encoding: "utf8", flag: "a" }, (err) => {
90
- if (err)
91
- throw err;
92
- // console.log('写入成功');
93
- });
94
- // 保存信息递增
95
- saveInfo.count += 1;
96
- // 若单文件保存信息已达最大值,则切分到下一个文件
97
- if (saveInfo.sliceByCount && saveInfo.sliceByCount <= saveInfo.count)
98
- saveInfo.slice();
99
- }
100
- start() {
101
- this.paused = false;
102
- }
103
- pause() {
104
- this.paused = true;
105
- }
106
- /** 设置保存信息 */
107
- setSaveInfo({ platform, room, status, timestamp, statusChanged, }) {
108
- const saveInfo = new SaveInfo({
109
- platform,
110
- room,
111
- status,
112
- timestamp,
113
- statusChanged,
114
- sliceByStatus: this.sliceByStatus,
115
- sliceByCount: this.sliceByCount,
116
- });
117
- const roomKey = `${platform}:${room}`;
118
- if (this.list.get(roomKey)?.fileId == saveInfo.fileId)
119
- return;
120
- this.list.set(roomKey, saveInfo);
121
- }
122
- /** 创建保存信息,用于记录信息可能不存在的情况 */
123
- createSaveInfo({ platform, room, }) {
124
- const { status, timestamp } = this.main.room.get(`${platform}:${room}`)
125
- ?.info || { status: __1.RoomStatus.off, timestamp: 0 };
126
- const saveInfoConfig = {
127
- platform,
128
- room,
129
- status,
130
- timestamp,
131
- statusChanged: false,
132
- sliceByStatus: this.sliceByStatus,
133
- sliceByCount: this.sliceByCount,
134
- };
135
- this.setSaveInfo(saveInfoConfig);
136
- return this.list.get(`${platform}:${room}`);
137
- }
138
- /** 创建记录文件 */
139
- createFile(roomKey) {
140
- const saveInfo = this.list.get(roomKey);
141
- const file = path_1.default.join(this.path, `${this.prefix}${saveInfo.fileId}${this.suffix}.floatrec`);
142
- // 如果文件已存在,则将文件标记为已存在,否则创建一个文件并写入record_info信息
143
- if (fs_extra_1.default.existsSync(file)) {
144
- saveInfo.exist = true;
145
- return;
146
- }
147
- fs_extra_1.default.ensureFileSync(file);
148
- const message = {
149
- type: "record_info",
150
- platform: saveInfo.platform,
151
- room: saveInfo.room,
152
- timestamp: saveInfo.timestamp,
153
- statusChanged: saveInfo.statusChanged,
154
- index: saveInfo.totalCount,
155
- part: saveInfo.part,
156
- roomInfo: this.main.room.get(roomKey)?.info,
157
- };
158
- fs_extra_1.default.writeFileSync(file, JSON.stringify(message) + ",", {
159
- encoding: "utf8",
160
- flag: "a",
161
- });
162
- }
163
- /** 移除记录信息 */
164
- removeSaveInfo(roomKey) {
165
- this.list.delete(roomKey);
166
- }
167
- }
168
- exports.default = MsgSave;
@@ -1,492 +0,0 @@
1
- export interface RawInfo {
2
- room_info: {
3
- /** 用户uid */
4
- uid: number;
5
- /** 房间id */
6
- room_id: number;
7
- /** 短id */
8
- short_id: number;
9
- /** 直播间标题 */
10
- title: string;
11
- /** 直播间封面 */
12
- cover: string;
13
- /** 直播间标签 */
14
- tags: string;
15
- /** 直播间背景 */
16
- background: string;
17
- /** 直播间简介 */
18
- description: string;
19
- /** 直播状态 */
20
- live_status: number;
21
- /** 直播开始时间(s) */
22
- live_start_time: number;
23
- /** 是否被封禁 */
24
- lock_status: number;
25
- /** 封禁时间 */
26
- lock_time: number;
27
- /** 是否被隐藏 */
28
- hidden_status: number;
29
- /** 隐藏时间 */
30
- hidden_time: number;
31
- /** 分区id */
32
- area_id: number;
33
- /** 分区名 */
34
- area_name: string;
35
- /** 一级分区id */
36
- parent_area_id: number;
37
- /** 一级分区名 */
38
- parent_area_name: string;
39
- /** session */
40
- up_session: string;
41
- /** 直播场次id */
42
- live_id: number;
43
- /** 直播场次id */
44
- live_id_str: string;
45
- /** 观看数 */
46
- online: number;
47
- };
48
- /** 主播信息 */
49
- anchor_info: {
50
- /** 基本信息 */
51
- base_info: {
52
- /** 用户名 */
53
- uname: string;
54
- /** 头像 */
55
- face: string;
56
- /** 性别 */
57
- gender: string;
58
- /** 官方信息 */
59
- official_info: {
60
- role: number;
61
- title: string;
62
- desc: string;
63
- };
64
- };
65
- /** 直播信息 */
66
- live_info: {
67
- /** 主播等级 */
68
- level: number;
69
- /** 等级颜色 */
70
- level_color: number;
71
- /** 经验值 */
72
- score: number;
73
- /** 下一级所需经验值 */
74
- upgrade_score: number;
75
- /** 当前等级 */
76
- current: [number, number];
77
- /** 下一等级 */
78
- next: [number, number];
79
- /** 直播间排名 */
80
- rank: string;
81
- };
82
- /** 直播间粉丝牌信息 */
83
- medal_info: {
84
- /** 粉丝牌名称 */
85
- medal_name: string;
86
- /** 粉丝牌id */
87
- medal_id: number;
88
- /** 粉丝团成员数 */
89
- fansclub: number;
90
- };
91
- };
92
- /** 公告信息 */
93
- news_info: {
94
- /** uid */
95
- uid: number;
96
- /** 创建时间 */
97
- ctime: string;
98
- /** 公告内容 */
99
- content: string;
100
- };
101
- /** 分区排名信息 */
102
- area_rank_info: {
103
- areaRank: {
104
- index: number;
105
- rank: string;
106
- };
107
- liveRank: {
108
- rank: string;
109
- };
110
- };
111
- /** sc信息 */
112
- super_chat_info: {
113
- status: number;
114
- ranked_mark: number;
115
- message_list: [];
116
- };
117
- /** 在线榜单信息 */
118
- online_gold_rank_info_v2: {
119
- list: {
120
- uid: number;
121
- face: string;
122
- uname: string;
123
- score: string;
124
- rank: number;
125
- guard_level: number;
126
- }[];
127
- };
128
- watched_show: {
129
- num: number;
130
- text_small: string;
131
- text_large: string;
132
- };
133
- show_reserve_status: false;
134
- /** 点赞信息 */
135
- like_info_v3: {
136
- /** 总点赞数 */
137
- total_likes: number;
138
- };
139
- /** 大航海信息 */
140
- guard_info: {
141
- count: number;
142
- anchor_guard_achieve_level: number;
143
- };
144
- room_rank_info: {
145
- user_rank_entry: {
146
- /** 贡献榜排行 */
147
- user_contribution_rank_entry: {
148
- item: {
149
- uid: number;
150
- name: string;
151
- face: string;
152
- rank: number;
153
- score: number;
154
- medal_info: null;
155
- guard_level: number;
156
- wealth_level: number;
157
- }[];
158
- /** 贡献榜总数 */
159
- count: number;
160
- /** 最大显示数量 */
161
- show_max: number;
162
- };
163
- };
164
- };
165
- }
166
- declare const bilibili_getInfoByRoom_expamle: {
167
- room_info: {
168
- uid: number;
169
- room_id: number;
170
- short_id: number;
171
- title: string;
172
- cover: string;
173
- tags: string;
174
- background: string;
175
- description: string;
176
- live_status: number;
177
- live_start_time: number;
178
- live_screen_type: number;
179
- lock_status: number;
180
- lock_time: number;
181
- hidden_status: number;
182
- hidden_time: number;
183
- area_id: number;
184
- area_name: string;
185
- parent_area_id: number;
186
- parent_area_name: string;
187
- keyframe: string;
188
- special_type: number;
189
- up_session: string;
190
- pk_status: number;
191
- is_studio: boolean;
192
- pendants: {
193
- frame: {
194
- name: string;
195
- value: string;
196
- desc: string;
197
- };
198
- };
199
- on_voice_join: number;
200
- online: number;
201
- room_type: {
202
- "2-3": number;
203
- "3-19": number;
204
- "3-21": number;
205
- "3-50": number;
206
- "3-51": number;
207
- };
208
- };
209
- anchor_info: {
210
- base_info: {
211
- uname: string;
212
- face: string;
213
- gender: string;
214
- official_info: {
215
- role: number;
216
- title: string;
217
- desc: string;
218
- is_nft: number;
219
- nft_dmark: string;
220
- };
221
- };
222
- live_info: {
223
- level: number;
224
- level_color: number;
225
- score: number;
226
- upgrade_score: number;
227
- current: number[];
228
- next: never[];
229
- rank: string;
230
- };
231
- relation_info: {
232
- attention: number;
233
- };
234
- medal_info: {
235
- medal_name: string;
236
- medal_id: number;
237
- fansclub: number;
238
- };
239
- };
240
- news_info: {
241
- uid: number;
242
- ctime: string;
243
- content: string;
244
- };
245
- rankdb_info: {
246
- roomid: number;
247
- rank_desc: string;
248
- color: string;
249
- h5_url: string;
250
- web_url: string;
251
- timestamp: number;
252
- };
253
- area_rank_info: {
254
- areaRank: {
255
- index: number;
256
- rank: string;
257
- };
258
- liveRank: {
259
- rank: string;
260
- };
261
- };
262
- battle_rank_entry_info: null;
263
- tab_info: {
264
- list: {
265
- type: string;
266
- desc: string;
267
- isFirst: number;
268
- isEvent: number;
269
- eventType: string;
270
- listType: string;
271
- apiPrefix: string;
272
- rank_name: string;
273
- }[];
274
- };
275
- activity_init_info: {
276
- eventList: never[];
277
- weekInfo: {
278
- bannerInfo: null;
279
- giftName: null;
280
- };
281
- giftName: null;
282
- lego: {
283
- timestamp: number;
284
- config: string;
285
- };
286
- };
287
- voice_join_info: {
288
- status: null;
289
- icons: null;
290
- web_share_link: string;
291
- };
292
- ad_banner_info: {
293
- data: null;
294
- };
295
- skin_info: {
296
- id: number;
297
- skin_name: string;
298
- skin_config: string;
299
- show_text: string;
300
- skin_url: string;
301
- start_time: number;
302
- end_time: number;
303
- current_time: number;
304
- };
305
- web_banner_info: {
306
- id: number;
307
- title: string;
308
- left: string;
309
- right: string;
310
- jump_url: string;
311
- bg_color: string;
312
- hover_color: string;
313
- text_bg_color: string;
314
- text_hover_color: string;
315
- link_text: string;
316
- link_color: string;
317
- input_color: string;
318
- input_text_color: string;
319
- input_hover_color: string;
320
- input_border_color: string;
321
- input_search_color: string;
322
- };
323
- lol_info: null;
324
- pk_info: null;
325
- battle_info: null;
326
- silent_room_info: {
327
- type: string;
328
- level: number;
329
- second: number;
330
- expire_time: number;
331
- };
332
- switch_info: {
333
- close_guard: boolean;
334
- close_gift: boolean;
335
- close_online: boolean;
336
- close_danmaku: boolean;
337
- };
338
- record_switch_info: null;
339
- room_config_info: {
340
- dm_text: string;
341
- };
342
- gift_memory_info: {
343
- list: null;
344
- };
345
- new_switch_info: {
346
- "room-socket": number;
347
- "room-prop-send": number;
348
- "room-sailing": number;
349
- "room-info-popularity": number;
350
- "room-danmaku-editor": number;
351
- "room-effect": number;
352
- "room-fans_medal": number;
353
- "room-report": number;
354
- "room-feedback": number;
355
- "room-player-watermark": number;
356
- "room-recommend-live_off": number;
357
- "room-activity": number;
358
- "room-web_banner": number;
359
- "room-silver_seeds-box": number;
360
- "room-wishing_bottle": number;
361
- "room-board": number;
362
- "room-supplication": number;
363
- "room-hour_rank": number;
364
- "room-week_rank": number;
365
- "room-anchor_rank": number;
366
- "room-info-integral": number;
367
- "room-super-chat": number;
368
- "room-tab": number;
369
- "room-hot-rank": number;
370
- "fans-medal-progress": number;
371
- "gift-bay-screen": number;
372
- "room-enter": number;
373
- "room-my-idol": number;
374
- "room-topic": number;
375
- "fans-club": number;
376
- };
377
- super_chat_info: {
378
- status: number;
379
- jump_url: string;
380
- icon: string;
381
- ranked_mark: number;
382
- message_list: never[];
383
- };
384
- online_gold_rank_info_v2: {
385
- list: {
386
- uid: number;
387
- face: string;
388
- uname: string;
389
- score: string;
390
- rank: number;
391
- guard_level: number;
392
- }[];
393
- };
394
- dm_brush_info: {
395
- min_time: number;
396
- brush_count: number;
397
- slice_count: number;
398
- storage_time: number;
399
- };
400
- dm_emoticon_info: {
401
- is_open_emoticon: number;
402
- is_shield_emoticon: number;
403
- };
404
- dm_tag_info: {
405
- dm_tag: number;
406
- platform: never[];
407
- extra: string;
408
- dm_chronos_extra: string;
409
- dm_mode: never[];
410
- dm_setting_switch: number;
411
- material_conf: null;
412
- };
413
- topic_info: {
414
- topic_id: number;
415
- topic_name: string;
416
- };
417
- game_info: {
418
- game_status: number;
419
- };
420
- watched_show: {
421
- switch: boolean;
422
- num: number;
423
- text_small: string;
424
- text_large: string;
425
- icon: string;
426
- icon_location: number;
427
- icon_web: string;
428
- };
429
- topic_room_info: {
430
- interactive_h5_url: string;
431
- watermark: number;
432
- };
433
- show_reserve_status: boolean;
434
- second_create_info: {
435
- click_permission: number;
436
- common_permission: number;
437
- icon_name: string;
438
- icon_url: string;
439
- url: string;
440
- };
441
- play_together_info: {
442
- switch: number;
443
- icon_list: {
444
- icon: string;
445
- title: string;
446
- jump_url: string;
447
- status: number;
448
- }[];
449
- };
450
- cloud_game_info: {
451
- is_gaming: number;
452
- };
453
- gift_star: {
454
- show: boolean;
455
- };
456
- like_info_v3: {
457
- total_likes: number;
458
- click_block: boolean;
459
- count_block: boolean;
460
- guild_emo_text: string;
461
- guild_dm_text: string;
462
- like_dm_text: string;
463
- hand_icons: string[];
464
- dm_icons: string[];
465
- eggshells_icon: string;
466
- count_show_time: number;
467
- process_icon: string;
468
- process_color: string;
469
- };
470
- live_play_info: {
471
- show_widget_banner: boolean;
472
- };
473
- multi_voice: {
474
- switch_status: number;
475
- members: never[];
476
- };
477
- video_connection_info: null;
478
- player_throttle_info: {
479
- status: number;
480
- normal_sleep_time: number;
481
- fullscreen_sleep_time: number;
482
- tab_sleep_time: number;
483
- prompt_time: number;
484
- };
485
- guard_info: {
486
- count: number;
487
- anchor_guard_achieve_level: number;
488
- };
489
- hot_rank_info: null;
490
- };
491
- export declare type bilibili_getInfoByRoom = typeof bilibili_getInfoByRoom_expamle;
492
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes