koishi-plugin-bilibili-videolink-analysis 1.1.25 → 1.3.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.
- package/lib/index.d.ts +60 -3
- package/lib/index.js +752 -966
- package/lib/utils.d.ts +63 -0
- package/package.json +3 -4
- package/src/index.ts +355 -0
- package/src/utils.ts +536 -0
- package/LICENSE.txt +0 -21
package/lib/index.js
CHANGED
|
@@ -1,966 +1,752 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
* 解析 ID 类型
|
|
754
|
-
* @param id 视频 ID
|
|
755
|
-
* @returns type: ID 类型, id: 视频 ID
|
|
756
|
-
*/
|
|
757
|
-
vid_type_parse(id) {
|
|
758
|
-
var idRegex = [
|
|
759
|
-
{
|
|
760
|
-
pattern: /av([0-9]+)/i,
|
|
761
|
-
type: "av",
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
pattern: /bv([0-9a-zA-Z]+)/i,
|
|
765
|
-
type: "bv",
|
|
766
|
-
},
|
|
767
|
-
];
|
|
768
|
-
for (const rule of idRegex) {
|
|
769
|
-
var match = id.match(rule.pattern);
|
|
770
|
-
if (match) {
|
|
771
|
-
return {
|
|
772
|
-
type: rule.type,
|
|
773
|
-
id: match[1],
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
return {
|
|
778
|
-
type: null,
|
|
779
|
-
id: null,
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* 根据视频 ID 查找视频信息
|
|
784
|
-
* @param id 视频 ID
|
|
785
|
-
* @returns 视频信息 Json
|
|
786
|
-
*/
|
|
787
|
-
async fetch_video_info(id) {
|
|
788
|
-
var ret;
|
|
789
|
-
const vid = this.vid_type_parse(id);
|
|
790
|
-
switch (vid["type"]) {
|
|
791
|
-
case "av":
|
|
792
|
-
ret = await this.ctx.http.get("https://api.bilibili.com/x/web-interface/view?aid=" + vid["id"], {
|
|
793
|
-
headers: {
|
|
794
|
-
"User-Agent": this.config.userAgent,
|
|
795
|
-
},
|
|
796
|
-
});
|
|
797
|
-
break;
|
|
798
|
-
case "bv":
|
|
799
|
-
ret = await this.ctx.http.get("https://api.bilibili.com/x/web-interface/view?bvid=" + vid["id"], {
|
|
800
|
-
headers: {
|
|
801
|
-
"User-Agent": this.config.userAgent,
|
|
802
|
-
},
|
|
803
|
-
});
|
|
804
|
-
break;
|
|
805
|
-
default:
|
|
806
|
-
ret = null;
|
|
807
|
-
break;
|
|
808
|
-
}
|
|
809
|
-
return ret;
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* 生成视频信息
|
|
813
|
-
* @param id 视频 ID
|
|
814
|
-
* @returns 文字视频信息
|
|
815
|
-
*/
|
|
816
|
-
async gen_context(id) {
|
|
817
|
-
const info = await this.fetch_video_info(id);
|
|
818
|
-
if (!info || !info["data"])
|
|
819
|
-
return null;
|
|
820
|
-
|
|
821
|
-
let description = info["data"]["desc"];
|
|
822
|
-
// 根据配置处理简介
|
|
823
|
-
const maxLength = config.bVideoShowIntroductionTofixed;
|
|
824
|
-
if (description.length > maxLength) {
|
|
825
|
-
description = description.substring(0, maxLength) + '...';
|
|
826
|
-
}
|
|
827
|
-
// 定义占位符对应的数据
|
|
828
|
-
const placeholders = {
|
|
829
|
-
'${标题}': info["data"]["title"],
|
|
830
|
-
'${UP主}': info["data"]["owner"]["name"],
|
|
831
|
-
'${封面}': `<img src="${info["data"]["pic"]}"/>`,
|
|
832
|
-
'${简介}': description, // 使用处理后的简介
|
|
833
|
-
'${点赞}': `${(0, numeral)(info["data"]["stat"]["like"], this.config)}`,
|
|
834
|
-
'${投币}': `${(0, numeral)(info["data"]["stat"]["coin"], this.config)}`,
|
|
835
|
-
'${收藏}': `${(0, numeral)(info["data"]["stat"]["favorite"], this.config)}`,
|
|
836
|
-
'${转发}': `${(0, numeral)(info["data"]["stat"]["share"], this.config)}`,
|
|
837
|
-
'${观看}': `${(0, numeral)(info["data"]["stat"]["view"], this.config)}`,
|
|
838
|
-
'${弹幕}': `${(0, numeral)(info["data"]["stat"]["danmaku"], this.config)}`,
|
|
839
|
-
};
|
|
840
|
-
|
|
841
|
-
// 根据配置项中的格式替换占位符
|
|
842
|
-
let ret = this.config.bVideo_area;
|
|
843
|
-
for (const [placeholder, value] of Object.entries(placeholders)) {
|
|
844
|
-
ret = ret.replace(new RegExp(placeholder.replace(/\$/g, '\\$'), 'g'), value);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
// 根据 ID 偏好添加视频链接
|
|
848
|
-
switch (this.config.bVideoIDPreference) {
|
|
849
|
-
case "bv":
|
|
850
|
-
ret += `\nhttps://www.bilibili.com/video/${info["data"]["bvid"]}`;
|
|
851
|
-
break;
|
|
852
|
-
case "av":
|
|
853
|
-
ret += `\nhttps://www.bilibili.com/video/av${info["data"]["aid"]}`;
|
|
854
|
-
break;
|
|
855
|
-
default:
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
return ret;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* 链接类型解析
|
|
867
|
-
* @param content 传入消息
|
|
868
|
-
* @returns type: "链接类型", id :"内容ID"
|
|
869
|
-
*/
|
|
870
|
-
function link_type_parser(content) {
|
|
871
|
-
// 先替换转义斜杠
|
|
872
|
-
content = content.replace(/\\\//g, '/');
|
|
873
|
-
var linkRegex = [
|
|
874
|
-
{
|
|
875
|
-
pattern: /bilibili\.com\/video\/([ab]v[0-9a-zA-Z]+)/gim,
|
|
876
|
-
type: "Video",
|
|
877
|
-
},
|
|
878
|
-
{
|
|
879
|
-
pattern: /b23\.tv(?:\\)?\/([0-9a-zA-Z]+)/gim,
|
|
880
|
-
type: "Short",
|
|
881
|
-
},
|
|
882
|
-
{
|
|
883
|
-
pattern: /bili(?:22|23|33)\.cn\/([0-9a-zA-Z]+)/gim,
|
|
884
|
-
type: "Short",
|
|
885
|
-
},
|
|
886
|
-
{
|
|
887
|
-
pattern: /bili2233\.cn\/([0-9a-zA-Z]+)/gim,
|
|
888
|
-
type: "Short",
|
|
889
|
-
},
|
|
890
|
-
];
|
|
891
|
-
var ret = [];
|
|
892
|
-
for (const rule of linkRegex) {
|
|
893
|
-
var match;
|
|
894
|
-
let lastID;
|
|
895
|
-
while ((match = rule.pattern.exec(content)) !== null) {
|
|
896
|
-
if (lastID == match[1])
|
|
897
|
-
continue;
|
|
898
|
-
ret.push({
|
|
899
|
-
type: rule.type,
|
|
900
|
-
id: match[1],
|
|
901
|
-
});
|
|
902
|
-
lastID = match[1];
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return ret;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* 类型执行器
|
|
910
|
-
* @param ctx Context
|
|
911
|
-
* @param config Config
|
|
912
|
-
* @param element 链接列表
|
|
913
|
-
* @returns 解析来的文本
|
|
914
|
-
*/
|
|
915
|
-
async function type_processer(ctx, config, element) {
|
|
916
|
-
var ret = "";
|
|
917
|
-
switch (element["type"]) {
|
|
918
|
-
case "Video":
|
|
919
|
-
const bili_video = new Bili_Video(ctx, config);
|
|
920
|
-
const video_info = await bili_video.gen_context(element["id"]);
|
|
921
|
-
if (video_info != null)
|
|
922
|
-
ret += video_info;
|
|
923
|
-
break;
|
|
924
|
-
|
|
925
|
-
case "Short":
|
|
926
|
-
const bili_short = new Bili_Short(ctx, config);
|
|
927
|
-
const typed_link = link_type_parser(await bili_short.get_redir_url(element["id"]));
|
|
928
|
-
for (const element of typed_link) {
|
|
929
|
-
const final_info = await type_processer(ctx, config, element);
|
|
930
|
-
if (final_info != null)
|
|
931
|
-
ret += final_info;
|
|
932
|
-
break;
|
|
933
|
-
}
|
|
934
|
-
break;
|
|
935
|
-
}
|
|
936
|
-
return ret;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
class Bili_Short {
|
|
940
|
-
ctx;
|
|
941
|
-
config;
|
|
942
|
-
constructor(ctx, config) {
|
|
943
|
-
this.ctx = ctx;
|
|
944
|
-
this.config = config;
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* 根据短链接重定向获取正常链接
|
|
948
|
-
* @param id 短链接 ID
|
|
949
|
-
* @returns 正常链接
|
|
950
|
-
*/
|
|
951
|
-
async get_redir_url(id) {
|
|
952
|
-
var data = await this.ctx.http.get("https://b23.tv/" + id, {
|
|
953
|
-
redirect: "manual",
|
|
954
|
-
headers: {
|
|
955
|
-
"User-Agent": this.config.userAgent,
|
|
956
|
-
},
|
|
957
|
-
});
|
|
958
|
-
const match = data.match(/<a\s+(?:[^>]*?\s+)?href="([^"]*)"/i);
|
|
959
|
-
if (match)
|
|
960
|
-
return match[1];
|
|
961
|
-
else
|
|
962
|
-
return null;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
exports.apply = apply;
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Config: () => Config,
|
|
24
|
+
apply: () => apply,
|
|
25
|
+
inject: () => inject,
|
|
26
|
+
name: () => name,
|
|
27
|
+
usage: () => usage
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
var import_koishi2 = require("koishi");
|
|
31
|
+
|
|
32
|
+
// src/utils.ts
|
|
33
|
+
var import_koishi = require("koishi");
|
|
34
|
+
var BilibiliParser = class {
|
|
35
|
+
constructor(ctx, config, logger2) {
|
|
36
|
+
this.ctx = ctx;
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.logger = logger2;
|
|
39
|
+
}
|
|
40
|
+
static {
|
|
41
|
+
__name(this, "BilibiliParser");
|
|
42
|
+
}
|
|
43
|
+
lastProcessedUrls = {};
|
|
44
|
+
logInfo(...args) {
|
|
45
|
+
if (this.config.loggerinfo) {
|
|
46
|
+
this.logger.info(...args);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// 判断是否需要解析
|
|
50
|
+
async isProcessLinks(sessioncontent) {
|
|
51
|
+
const links = this.link_type_parser(sessioncontent);
|
|
52
|
+
if (links.length === 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return links;
|
|
56
|
+
}
|
|
57
|
+
//提取链接
|
|
58
|
+
async extractLinks(session, links) {
|
|
59
|
+
let ret = "";
|
|
60
|
+
if (!this.config.isfigure) {
|
|
61
|
+
ret += (0, import_koishi.h)("quote", { id: session.messageId });
|
|
62
|
+
}
|
|
63
|
+
let countLink = 0;
|
|
64
|
+
let tp_ret;
|
|
65
|
+
for (const element of links) {
|
|
66
|
+
if (countLink >= 1) ret += "\n";
|
|
67
|
+
if (countLink >= this.config.parseLimit) {
|
|
68
|
+
ret += "已达到解析上限…";
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
tp_ret = await this.type_processer(element);
|
|
72
|
+
if (tp_ret == "") {
|
|
73
|
+
if (this.config.showError)
|
|
74
|
+
ret = "无法解析链接信息。可能是 ID 不存在,或该类型可能暂不支持。";
|
|
75
|
+
else
|
|
76
|
+
ret = null;
|
|
77
|
+
} else {
|
|
78
|
+
ret += tp_ret;
|
|
79
|
+
}
|
|
80
|
+
countLink++;
|
|
81
|
+
}
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
//判断链接是否已经处理过
|
|
85
|
+
isLinkProcessedRecently(ret, channelId) {
|
|
86
|
+
const lastretUrl = this.extractLastUrl(ret);
|
|
87
|
+
const currentTime = Date.now();
|
|
88
|
+
const channelKey = `${channelId}:${lastretUrl}`;
|
|
89
|
+
if (lastretUrl && this.lastProcessedUrls[channelKey] && currentTime - this.lastProcessedUrls[channelKey] < this.config.MinimumTimeInterval * 1e3) {
|
|
90
|
+
this.ctx.logger.info(`重复出现,略过处理:
|
|
91
|
+
${lastretUrl} (频道 ${channelId})`);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (lastretUrl) {
|
|
95
|
+
this.lastProcessedUrls[channelKey] = currentTime;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
async processVideoFromLink(session, ret, options = { video: true }) {
|
|
100
|
+
const lastretUrl = this.extractLastUrl(ret);
|
|
101
|
+
let waitTipMsgId = null;
|
|
102
|
+
if (this.config.waitTip_Switch) {
|
|
103
|
+
const result = await session.send(`${import_koishi.h.quote(session.messageId)}${this.config.waitTip_Switch}`);
|
|
104
|
+
waitTipMsgId = Array.isArray(result) ? result[0] : result;
|
|
105
|
+
}
|
|
106
|
+
let videoElements = [];
|
|
107
|
+
let textElements = [];
|
|
108
|
+
let shouldPerformTextParsing = this.config.videoParseComponents.includes("text");
|
|
109
|
+
if (shouldPerformTextParsing) {
|
|
110
|
+
let fullText;
|
|
111
|
+
if (this.config.bVideoShowLink) {
|
|
112
|
+
fullText = ret;
|
|
113
|
+
} else {
|
|
114
|
+
fullText = ret.replace(lastretUrl, "");
|
|
115
|
+
}
|
|
116
|
+
const textParts = fullText.split("${~~~}");
|
|
117
|
+
for (const part of textParts) {
|
|
118
|
+
const trimmedPart = part.trim();
|
|
119
|
+
if (trimmedPart) {
|
|
120
|
+
const parsedElements = import_koishi.h.parse(trimmedPart);
|
|
121
|
+
const messageElement = (0, import_koishi.h)("message", {
|
|
122
|
+
userId: session.userId,
|
|
123
|
+
nickname: session.author?.nickname || session.username
|
|
124
|
+
}, parsedElements);
|
|
125
|
+
textElements.push(messageElement);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this.config.videoParseComponents.length > 0) {
|
|
130
|
+
const fullAPIurl = `http://api.xingzhige.cn/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
|
|
131
|
+
try {
|
|
132
|
+
const responseData = await this.ctx.http.get(fullAPIurl);
|
|
133
|
+
if (responseData.code === 0 && responseData.msg === "video" && responseData.data) {
|
|
134
|
+
const { bvid, cid, video } = responseData.data;
|
|
135
|
+
const bilibiliUrl = `https://api.bilibili.com/x/player/playurl?fnval=80&cid=${cid}&bvid=${bvid}`;
|
|
136
|
+
const playData = await this.ctx.http.get(bilibiliUrl);
|
|
137
|
+
this.logInfo(bilibiliUrl);
|
|
138
|
+
if (playData.code === 0 && playData.data && playData.data.dash && playData.data.dash.duration) {
|
|
139
|
+
const videoDurationSeconds = playData.data.dash.duration;
|
|
140
|
+
const videoDurationMinutes = videoDurationSeconds / 60;
|
|
141
|
+
if (videoDurationMinutes < this.config.Minimumduration) {
|
|
142
|
+
if (this.config.Minimumduration_tip === "return") {
|
|
143
|
+
return;
|
|
144
|
+
} else if (typeof this.config.Minimumduration_tip === "object" && this.config.Minimumduration_tip !== null) {
|
|
145
|
+
if (this.config.Minimumduration_tip.tipcontent) {
|
|
146
|
+
if (this.config.Minimumduration_tip.tipanalysis) {
|
|
147
|
+
videoElements.push(import_koishi.h.text(this.config.Minimumduration_tip.tipcontent));
|
|
148
|
+
} else {
|
|
149
|
+
await session.send(this.config.Minimumduration_tip.tipcontent);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
shouldPerformTextParsing = this.config.Minimumduration_tip.tipanalysis === true;
|
|
153
|
+
if (!shouldPerformTextParsing) {
|
|
154
|
+
textElements = [];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} else if (videoDurationMinutes > this.config.Maximumduration) {
|
|
158
|
+
if (this.config.Maximumduration_tip === "return") {
|
|
159
|
+
return;
|
|
160
|
+
} else if (typeof this.config.Maximumduration_tip === "object" && this.config.Maximumduration_tip !== null) {
|
|
161
|
+
if (this.config.Maximumduration_tip.tipcontent) {
|
|
162
|
+
if (this.config.Maximumduration_tip.tipanalysis) {
|
|
163
|
+
videoElements.push(import_koishi.h.text(this.config.Maximumduration_tip.tipcontent));
|
|
164
|
+
} else {
|
|
165
|
+
await session.send(this.config.Maximumduration_tip.tipcontent);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
shouldPerformTextParsing = this.config.Maximumduration_tip.tipanalysis === true;
|
|
169
|
+
if (!shouldPerformTextParsing) {
|
|
170
|
+
textElements = [];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
let videoData = video.url;
|
|
175
|
+
this.logInfo(videoData);
|
|
176
|
+
if (this.config.filebuffer) {
|
|
177
|
+
try {
|
|
178
|
+
const videoFileBuffer = await this.ctx.http.file(video.url);
|
|
179
|
+
this.logInfo(videoFileBuffer);
|
|
180
|
+
if (videoFileBuffer && videoFileBuffer.data) {
|
|
181
|
+
const buffer = Buffer.from(videoFileBuffer.data);
|
|
182
|
+
const mimeType = videoFileBuffer.type || videoFileBuffer.mime || "video/mp4";
|
|
183
|
+
const base64Data = buffer.toString("base64");
|
|
184
|
+
videoData = `data:${mimeType};base64,${base64Data}`;
|
|
185
|
+
this.logInfo("成功使用 ctx.http.file 将视频URL 转换为data URI格式");
|
|
186
|
+
} else {
|
|
187
|
+
this.logInfo("文件数据无效,使用原始URL");
|
|
188
|
+
}
|
|
189
|
+
} catch (error) {
|
|
190
|
+
this.logger.error("获取视频文件失败:", error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (videoData) {
|
|
194
|
+
if (options.link) {
|
|
195
|
+
videoElements.push(import_koishi.h.text(video.url));
|
|
196
|
+
} else if (options.audio) {
|
|
197
|
+
videoElements.push(import_koishi.h.audio(videoData));
|
|
198
|
+
} else {
|
|
199
|
+
if (this.config.videoParseComponents.includes("log")) {
|
|
200
|
+
this.logger.info(video.url);
|
|
201
|
+
}
|
|
202
|
+
if (this.config.videoParseComponents.includes("link")) {
|
|
203
|
+
videoElements.push(import_koishi.h.text(video.url));
|
|
204
|
+
}
|
|
205
|
+
if (this.config.videoParseComponents.includes("video")) {
|
|
206
|
+
videoElements.push(import_koishi.h.video(videoData));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
throw new Error("解析视频直链失败");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
throw new Error("获取播放数据失败");
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
throw new Error("解析视频信息失败或非视频类型内容");
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
this.logger.error("请求解析 API 失败或处理出错:", error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
let allElements = [...textElements, ...videoElements];
|
|
224
|
+
if (allElements.length === 0) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (this.config.isfigure && (session.platform === "onebot" || session.platform === "red")) {
|
|
228
|
+
this.logInfo(`使用合并转发,正在合并消息。`);
|
|
229
|
+
const figureContent = (0, import_koishi.h)("figure", {
|
|
230
|
+
children: allElements
|
|
231
|
+
});
|
|
232
|
+
if (this.config.loggerinfofulljson) {
|
|
233
|
+
this.logInfo(JSON.stringify(figureContent, null, 2));
|
|
234
|
+
}
|
|
235
|
+
await session.send(figureContent);
|
|
236
|
+
} else {
|
|
237
|
+
for (const element of allElements) {
|
|
238
|
+
await session.send(element);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
this.logInfo(`机器人已发送完整消息。`);
|
|
242
|
+
if (waitTipMsgId) {
|
|
243
|
+
await session.bot.deleteMessage(session.channelId, waitTipMsgId);
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
// 提取最后一个URL
|
|
248
|
+
extractLastUrl(text) {
|
|
249
|
+
const urlPattern = /https?:\/\/[^\s]+/g;
|
|
250
|
+
const urls = text.match(urlPattern);
|
|
251
|
+
return urls ? urls.pop() : null;
|
|
252
|
+
}
|
|
253
|
+
// 检测BV / AV 号并转换为URL
|
|
254
|
+
convertBVToUrl(text) {
|
|
255
|
+
const bvPattern = /(?:^|\s)(BV\w{10})(?:\s|$)/g;
|
|
256
|
+
const avPattern = /(?:^|\s)(av\d+)(?:\s|$)/g;
|
|
257
|
+
const matches = [];
|
|
258
|
+
let match;
|
|
259
|
+
while ((match = bvPattern.exec(text)) !== null) {
|
|
260
|
+
matches.push(`https://www.bilibili.com/video/${match[1]}`);
|
|
261
|
+
}
|
|
262
|
+
while ((match = avPattern.exec(text)) !== null) {
|
|
263
|
+
matches.push(`https://www.bilibili.com/video/${match[1]}`);
|
|
264
|
+
}
|
|
265
|
+
return matches;
|
|
266
|
+
}
|
|
267
|
+
numeral(number) {
|
|
268
|
+
if (this.config.useNumeral) {
|
|
269
|
+
if (number >= 1e4 && number < 1e8) {
|
|
270
|
+
return (number / 1e4).toFixed(1) + "万";
|
|
271
|
+
} else if (number >= 1e8) {
|
|
272
|
+
return (number / 1e8).toFixed(1) + "亿";
|
|
273
|
+
} else {
|
|
274
|
+
return number.toString();
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
return number;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* 解析 ID 类型
|
|
282
|
+
* @param id 视频 ID
|
|
283
|
+
* @returns type: ID 类型, id: 视频 ID
|
|
284
|
+
*/
|
|
285
|
+
vid_type_parse(id) {
|
|
286
|
+
var idRegex = [
|
|
287
|
+
{
|
|
288
|
+
pattern: /av([0-9]+)/i,
|
|
289
|
+
type: "av"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
pattern: /bv([0-9a-zA-Z]+)/i,
|
|
293
|
+
type: "bv"
|
|
294
|
+
}
|
|
295
|
+
];
|
|
296
|
+
for (const rule of idRegex) {
|
|
297
|
+
var match = id.match(rule.pattern);
|
|
298
|
+
if (match) {
|
|
299
|
+
return {
|
|
300
|
+
type: rule.type,
|
|
301
|
+
id: match[1]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
type: null,
|
|
307
|
+
id: null
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 根据视频 ID 查找视频信息
|
|
312
|
+
* @param id 视频 ID
|
|
313
|
+
* @returns 视频信息 Json
|
|
314
|
+
*/
|
|
315
|
+
async fetch_video_info(id) {
|
|
316
|
+
var ret;
|
|
317
|
+
const vid = this.vid_type_parse(id);
|
|
318
|
+
switch (vid["type"]) {
|
|
319
|
+
case "av":
|
|
320
|
+
ret = await this.ctx.http.get("https://api.bilibili.com/x/web-interface/view?aid=" + vid["id"], {
|
|
321
|
+
headers: {
|
|
322
|
+
"User-Agent": this.config.userAgent
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
break;
|
|
326
|
+
case "bv":
|
|
327
|
+
ret = await this.ctx.http.get("https://api.bilibili.com/x/web-interface/view?bvid=" + vid["id"], {
|
|
328
|
+
headers: {
|
|
329
|
+
"User-Agent": this.config.userAgent
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
ret = null;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
return ret;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* 生成视频信息
|
|
341
|
+
* @param id 视频 ID
|
|
342
|
+
* @returns 文字视频信息
|
|
343
|
+
*/
|
|
344
|
+
async gen_context(id) {
|
|
345
|
+
const info = await this.fetch_video_info(id);
|
|
346
|
+
if (!info || !info["data"])
|
|
347
|
+
return null;
|
|
348
|
+
let description = info["data"]["desc"];
|
|
349
|
+
const maxLength = this.config.bVideoShowIntroductionTofixed;
|
|
350
|
+
if (description.length > maxLength) {
|
|
351
|
+
description = description.substring(0, maxLength) + "...";
|
|
352
|
+
}
|
|
353
|
+
const placeholders = {
|
|
354
|
+
"${标题}": info["data"]["title"],
|
|
355
|
+
"${UP主}": info["data"]["owner"]["name"],
|
|
356
|
+
"${封面}": `<img src="${info["data"]["pic"]}"/>`,
|
|
357
|
+
"${简介}": description,
|
|
358
|
+
// 使用处理后的简介
|
|
359
|
+
"${点赞}": `${this.numeral(info["data"]["stat"]["like"])}`,
|
|
360
|
+
"${投币}": `${this.numeral(info["data"]["stat"]["coin"])}`,
|
|
361
|
+
"${收藏}": `${this.numeral(info["data"]["stat"]["favorite"])}`,
|
|
362
|
+
"${转发}": `${this.numeral(info["data"]["stat"]["share"])}`,
|
|
363
|
+
"${观看}": `${this.numeral(info["data"]["stat"]["view"])}`,
|
|
364
|
+
"${弹幕}": `${this.numeral(info["data"]["stat"]["danmaku"])}`,
|
|
365
|
+
"${tab}": `<pre> </pre>`
|
|
366
|
+
};
|
|
367
|
+
let ret = this.config.bVideo_area;
|
|
368
|
+
for (const [placeholder, value] of Object.entries(placeholders)) {
|
|
369
|
+
ret = ret.replace(new RegExp(placeholder.replace(/\$/g, "\\$"), "g"), value);
|
|
370
|
+
}
|
|
371
|
+
switch (this.config.bVideoIDPreference) {
|
|
372
|
+
case "bv":
|
|
373
|
+
ret += `
|
|
374
|
+
https://www.bilibili.com/video/${info["data"]["bvid"]}`;
|
|
375
|
+
break;
|
|
376
|
+
case "av":
|
|
377
|
+
ret += `
|
|
378
|
+
https://www.bilibili.com/video/av${info["data"]["aid"]}`;
|
|
379
|
+
break;
|
|
380
|
+
default:
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
return ret;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* 链接类型解析
|
|
387
|
+
* @param content 传入消息
|
|
388
|
+
* @returns type: "链接类型", id :"内容ID"
|
|
389
|
+
*/
|
|
390
|
+
link_type_parser(content) {
|
|
391
|
+
content = content.replace(/\\\//g, "/");
|
|
392
|
+
var linkRegex = [
|
|
393
|
+
{
|
|
394
|
+
pattern: /bilibili\.com\/video\/([ab]v[0-9a-zA-Z]+)/gim,
|
|
395
|
+
type: "Video"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
pattern: /b23\.tv(?:\\)?\/([0-9a-zA-Z]+)/gim,
|
|
399
|
+
type: "Short"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
pattern: /bili(?:22|23|33)\.cn\/([0-9a-zA-Z]+)/gim,
|
|
403
|
+
type: "Short"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
pattern: /bili2233\.cn\/([0-9a-zA-Z]+)/gim,
|
|
407
|
+
type: "Short"
|
|
408
|
+
}
|
|
409
|
+
];
|
|
410
|
+
var ret = [];
|
|
411
|
+
for (const rule of linkRegex) {
|
|
412
|
+
var match;
|
|
413
|
+
let lastID;
|
|
414
|
+
while ((match = rule.pattern.exec(content)) !== null) {
|
|
415
|
+
if (lastID == match[1])
|
|
416
|
+
continue;
|
|
417
|
+
ret.push({
|
|
418
|
+
type: rule.type,
|
|
419
|
+
id: match[1]
|
|
420
|
+
});
|
|
421
|
+
lastID = match[1];
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return ret;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 类型执行器
|
|
428
|
+
* @param element 链接列表
|
|
429
|
+
* @returns 解析来的文本
|
|
430
|
+
*/
|
|
431
|
+
async type_processer(element) {
|
|
432
|
+
var ret = "";
|
|
433
|
+
switch (element["type"]) {
|
|
434
|
+
case "Video":
|
|
435
|
+
const video_info = await this.gen_context(element["id"]);
|
|
436
|
+
if (video_info != null)
|
|
437
|
+
ret += video_info;
|
|
438
|
+
break;
|
|
439
|
+
case "Short":
|
|
440
|
+
const typed_link = this.link_type_parser(await this.get_redir_url(element["id"]));
|
|
441
|
+
for (const element2 of typed_link) {
|
|
442
|
+
const final_info = await this.type_processer(element2);
|
|
443
|
+
if (final_info != null)
|
|
444
|
+
ret += final_info;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
return ret;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* 根据短链接重定向获取正常链接
|
|
453
|
+
* @param id 短链接 ID
|
|
454
|
+
* @returns 正常链接
|
|
455
|
+
*/
|
|
456
|
+
async get_redir_url(id) {
|
|
457
|
+
var data = await this.ctx.http.get("https://b23.tv/" + id, {
|
|
458
|
+
redirect: "manual",
|
|
459
|
+
headers: {
|
|
460
|
+
"User-Agent": this.config.userAgent
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
const match = data.match(/<a\s+(?:[^>]*?\s+)?href="([^"]*)"/i);
|
|
464
|
+
if (match)
|
|
465
|
+
return match[1];
|
|
466
|
+
else
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
// src/index.ts
|
|
472
|
+
var logger = new import_koishi2.Logger("bilibili-videolink-analysis");
|
|
473
|
+
var name = "bilibili-videolink-analysis";
|
|
474
|
+
var inject = {
|
|
475
|
+
optional: ["puppeteer"]
|
|
476
|
+
// required: ['BiliBiliVideo']
|
|
477
|
+
};
|
|
478
|
+
var usage = `
|
|
479
|
+
|
|
480
|
+
<h2>→ <a href="https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis" target="_blank">可以点击这里查看详细的文档说明✨</a></h2>
|
|
481
|
+
|
|
482
|
+
✨ 只需开启插件,就可以解析B站视频的链接啦~ ✨
|
|
483
|
+
|
|
484
|
+
向bot发送B站视频链接吧~
|
|
485
|
+
|
|
486
|
+
会返回视频信息与视频哦
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
#### ⚠️ **如果你使用不了本项目,请优先检查:** ⚠️
|
|
491
|
+
#### 若无注册的指令,请关开一下[command插件](/market?keyword=commands+email:shigma10826@gmail.com)(没有指令也不影响解析别人的链接)
|
|
492
|
+
#### 视频内容是否为B站的大会员专属视频/付费视频/充电专属视频
|
|
493
|
+
#### 接入方法是否支持获取网址链接/小程序卡片消息
|
|
494
|
+
#### 接入方法是否支持视频元素的发送
|
|
495
|
+
#### 发送视频超时/其他网络问题
|
|
496
|
+
#### 视频内容被平台屏蔽/其他平台因素
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
### 注意,点播功能需要使用 puppeteer 服务
|
|
501
|
+
|
|
502
|
+
点播功能是为了方便群友一起刷B站哦~
|
|
503
|
+
|
|
504
|
+
比如:搜索 “遠い空へ” 的第二页,并且结果以语音格式返回
|
|
505
|
+
|
|
506
|
+
示例:\`点播 遠い空へ -a -p 2\`
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
### 特别鸣谢 💖
|
|
512
|
+
|
|
513
|
+
特别鸣谢以下项目的支持:
|
|
514
|
+
|
|
515
|
+
- [@summonhim/koishi-plugin-bili-parser](/market?keyword=bili-parser)
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
`;
|
|
520
|
+
var Config = import_koishi2.Schema.intersect([
|
|
521
|
+
import_koishi2.Schema.object({
|
|
522
|
+
demand: import_koishi2.Schema.boolean().default(true).description("开启点播指令功能<br>`其实点播登录不登录 都搜不准,登录只是写着玩的`")
|
|
523
|
+
}).description("点播设置(需要puppeteer服务)"),
|
|
524
|
+
import_koishi2.Schema.union([
|
|
525
|
+
import_koishi2.Schema.object({
|
|
526
|
+
demand: import_koishi2.Schema.const(false).required()
|
|
527
|
+
}),
|
|
528
|
+
import_koishi2.Schema.object({
|
|
529
|
+
demand: import_koishi2.Schema.const(true),
|
|
530
|
+
timeout: import_koishi2.Schema.number().role("slider").min(1).max(300).step(1).default(60).description("指定播放视频的输入时限。`单位 秒`"),
|
|
531
|
+
point: import_koishi2.Schema.tuple([Number, Number]).description("序号标注位置。分别表示`距离顶部 距离左侧`的百分比").default([50, 50]),
|
|
532
|
+
enable: import_koishi2.Schema.boolean().description("是否开启自动解析`选择对应视频 会自动解析视频内容`").default(true)
|
|
533
|
+
})
|
|
534
|
+
]),
|
|
535
|
+
import_koishi2.Schema.object({
|
|
536
|
+
enablebilianalysis: import_koishi2.Schema.boolean().default(true).description("开启解析功能<br>`关闭后,解析功能将关闭`")
|
|
537
|
+
}).description("视频解析 - 功能开关"),
|
|
538
|
+
import_koishi2.Schema.union([
|
|
539
|
+
import_koishi2.Schema.object({
|
|
540
|
+
enablebilianalysis: import_koishi2.Schema.const(true),
|
|
541
|
+
waitTip_Switch: import_koishi2.Schema.union([
|
|
542
|
+
import_koishi2.Schema.const(null).description("不返回文字提示"),
|
|
543
|
+
import_koishi2.Schema.string().description("返回文字提示(请在右侧填写文字内容)").default("正在解析B站链接...")
|
|
544
|
+
]).description("是否返回等待提示。开启后,会发送`等待提示语`"),
|
|
545
|
+
videoParseMode: import_koishi2.Schema.array(import_koishi2.Schema.union([
|
|
546
|
+
import_koishi2.Schema.const("link").description("解析链接"),
|
|
547
|
+
import_koishi2.Schema.const("card").description("解析哔哩哔哩分享卡片")
|
|
548
|
+
])).default(["link", "card"]).role("checkbox").description("选择解析来源"),
|
|
549
|
+
videoParseComponents: import_koishi2.Schema.array(import_koishi2.Schema.union([
|
|
550
|
+
import_koishi2.Schema.const("log").description("记录日志"),
|
|
551
|
+
import_koishi2.Schema.const("text").description("返回图文"),
|
|
552
|
+
import_koishi2.Schema.const("link").description("返回视频直链"),
|
|
553
|
+
import_koishi2.Schema.const("video").description("返回视频")
|
|
554
|
+
])).default(["text", "video"]).role("checkbox").description("选择要返回的内容组件"),
|
|
555
|
+
BVnumberParsing: import_koishi2.Schema.boolean().default(true).description("是否允许根据`独立的BV、AV号`解析视频 `开启后,可以通过视频的BV、AV号解析视频。` <br> [触发说明见README](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)"),
|
|
556
|
+
MinimumTimeInterval: import_koishi2.Schema.number().default(180).description("若干`秒`内 不再处理相同链接 `防止多bot互相触发 导致的刷屏/性能浪费`").min(1),
|
|
557
|
+
Minimumduration: import_koishi2.Schema.number().default(0).description("允许解析的视频最小时长(分钟)`低于这个时长 就不会发视频内容`").min(0),
|
|
558
|
+
Minimumduration_tip: import_koishi2.Schema.union([
|
|
559
|
+
import_koishi2.Schema.const("return").description("不返回文字提示"),
|
|
560
|
+
import_koishi2.Schema.object({
|
|
561
|
+
tipcontent: import_koishi2.Schema.string().default("视频太短啦!不看不看~").description("文字提示内容"),
|
|
562
|
+
tipanalysis: import_koishi2.Schema.boolean().default(true).description("是否进行图文解析(不会返回视频链接)")
|
|
563
|
+
}).description("返回文字提示"),
|
|
564
|
+
import_koishi2.Schema.const(null)
|
|
565
|
+
]).description("对`过短视频`的文字提示内容").default(null),
|
|
566
|
+
Maximumduration: import_koishi2.Schema.number().default(25).description("允许解析的视频最大时长(分钟)`超过这个时长 就不会发视频内容`").min(1),
|
|
567
|
+
Maximumduration_tip: import_koishi2.Schema.union([
|
|
568
|
+
import_koishi2.Schema.const("return").description("不返回文字提示"),
|
|
569
|
+
import_koishi2.Schema.object({
|
|
570
|
+
tipcontent: import_koishi2.Schema.string().default("视频太长啦!内容还是去B站看吧~").description("文字提示内容"),
|
|
571
|
+
tipanalysis: import_koishi2.Schema.boolean().default(true).description("是否进行图文解析(不会返回视频链接)")
|
|
572
|
+
}).description("返回文字提示"),
|
|
573
|
+
import_koishi2.Schema.const(null)
|
|
574
|
+
]).description("对`过长视频`的文字提示内容").default(null),
|
|
575
|
+
parseLimit: import_koishi2.Schema.number().default(3).description("单对话多链接解析上限").hidden(),
|
|
576
|
+
useNumeral: import_koishi2.Schema.boolean().default(true).description("使用格式化数字").hidden(),
|
|
577
|
+
showError: import_koishi2.Schema.boolean().default(false).description("当链接不正确时提醒发送者").hidden(),
|
|
578
|
+
bVideoIDPreference: import_koishi2.Schema.union([
|
|
579
|
+
import_koishi2.Schema.const("bv").description("BV 号"),
|
|
580
|
+
import_koishi2.Schema.const("av").description("AV 号")
|
|
581
|
+
]).default("bv").description("ID 偏好").hidden(),
|
|
582
|
+
bVideo_area: import_koishi2.Schema.string().role("textarea", { rows: [8, 16] }).default("${标题} ${tab} ${UP主}\n${简介}\n点赞:${点赞} ${tab} 投币:${投币}\n收藏:${收藏} ${tab} 转发:${转发}\n观看:${观看} ${tab} 弹幕:${弹幕}\n${~~~}\n${封面}").description(`图文解析的返回格式<br>
|
|
583
|
+
注意变量格式,以及变量名称。<br>比如 \`\${标题}\` 不可以变成\`\${标题123}\`,你可以直接删掉但是不能修改变量名称哦<br>
|
|
584
|
+
当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。<br>
|
|
585
|
+
· 特殊变量\`\${~~~}\`表示分割线,会把上下内容分为两个信息单独发送。\`\${tab}\`表示制表符。`),
|
|
586
|
+
bVideoShowLink: import_koishi2.Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
|
|
587
|
+
bVideoShowIntroductionTofixed: import_koishi2.Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
|
|
588
|
+
isfigure: import_koishi2.Schema.boolean().default(true).description("是否开启合并转发 `仅支持 onebot 适配器` 其他平台开启 无效").experimental(),
|
|
589
|
+
filebuffer: import_koishi2.Schema.boolean().default(true).description("是否将视频链接下载后再发送 (以解决部分onebot协议端的问题)<br>否则使用视频直链发送").experimental(),
|
|
590
|
+
middleware: import_koishi2.Schema.boolean().default(false).description("前置中间件模式"),
|
|
591
|
+
userAgent: import_koishi2.Schema.string().description("所有 API 请求所用的 User-Agent").default("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36")
|
|
592
|
+
}),
|
|
593
|
+
import_koishi2.Schema.object({
|
|
594
|
+
enablebilianalysis: import_koishi2.Schema.const(false).required()
|
|
595
|
+
})
|
|
596
|
+
]),
|
|
597
|
+
import_koishi2.Schema.object({
|
|
598
|
+
pageclose: import_koishi2.Schema.boolean().default(true).description("自动`page.close()`<br>非开发者请勿改动").experimental(),
|
|
599
|
+
loggerinfo: import_koishi2.Schema.boolean().default(false).description("日志调试输出 `日常使用无需开启`<br>非开发者请勿改动").experimental(),
|
|
600
|
+
loggerinfofulljson: import_koishi2.Schema.boolean().default(false).description("打印完整的机器人发送的json输出").experimental()
|
|
601
|
+
}).description("开发者选项")
|
|
602
|
+
]);
|
|
603
|
+
function apply(ctx, config) {
|
|
604
|
+
const bilibiliParser = new BilibiliParser(ctx, config, logger);
|
|
605
|
+
if (config.enablebilianalysis) {
|
|
606
|
+
ctx.middleware(async (session, next) => {
|
|
607
|
+
let isCard = false;
|
|
608
|
+
try {
|
|
609
|
+
if (session.stripped.content.startsWith("<json data=")) {
|
|
610
|
+
isCard = true;
|
|
611
|
+
}
|
|
612
|
+
} catch (e) {
|
|
613
|
+
}
|
|
614
|
+
if (isCard) {
|
|
615
|
+
if (!config.videoParseMode.includes("card")) {
|
|
616
|
+
return next();
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
if (!config.videoParseMode.includes("link")) {
|
|
620
|
+
return next();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
let sessioncontent = session.stripped.content;
|
|
624
|
+
ctx.logger.info(sessioncontent);
|
|
625
|
+
if (config.BVnumberParsing) {
|
|
626
|
+
const bvUrls = bilibiliParser.convertBVToUrl(sessioncontent);
|
|
627
|
+
if (bvUrls.length > 0) {
|
|
628
|
+
sessioncontent += "\n" + bvUrls.join("\n");
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const links = await bilibiliParser.isProcessLinks(sessioncontent);
|
|
632
|
+
if (links) {
|
|
633
|
+
const ret = await bilibiliParser.extractLinks(session, links);
|
|
634
|
+
if (ret && !bilibiliParser.isLinkProcessedRecently(ret, session.channelId)) {
|
|
635
|
+
await bilibiliParser.processVideoFromLink(session, ret);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return next();
|
|
639
|
+
}, config.middleware);
|
|
640
|
+
}
|
|
641
|
+
if (config.demand) {
|
|
642
|
+
ctx.command("B站点播 [keyword]", "点播B站视频").option("video", "-v 解析返回视频").option("audio", "-a 解析返回语音").option("link", "-l 解析返回链接").option("page", "-p <page:number> 指定页数", { fallback: "1" }).example("B站点播 遠い空へ -v").action(async ({ options, session }, keyword) => {
|
|
643
|
+
if (!keyword) {
|
|
644
|
+
await session.send(import_koishi2.h.text("告诉我 你想要点播的关键词吧~"));
|
|
645
|
+
keyword = await session.prompt(30 * 1e3);
|
|
646
|
+
}
|
|
647
|
+
const url = `https://search.bilibili.com/video?keyword=${encodeURIComponent(keyword)}&page=${options.page}&o=30`;
|
|
648
|
+
const page = await ctx.puppeteer.page();
|
|
649
|
+
await page.goto(url, {
|
|
650
|
+
waitUntil: "networkidle2"
|
|
651
|
+
});
|
|
652
|
+
await page.addStyleTag({
|
|
653
|
+
content: `
|
|
654
|
+
div.bili-header,
|
|
655
|
+
div.login-tip,
|
|
656
|
+
div.v-popover,
|
|
657
|
+
div.right-entry__outside {
|
|
658
|
+
display: none !important;
|
|
659
|
+
}
|
|
660
|
+
`
|
|
661
|
+
});
|
|
662
|
+
const videos = await page.evaluate((point) => {
|
|
663
|
+
const items = Array.from(document.querySelectorAll('.video-list-item:not([style*="display: none"])'));
|
|
664
|
+
return items.map((item, index) => {
|
|
665
|
+
const link = item.querySelector("a");
|
|
666
|
+
const href = link?.getAttribute("href") || "";
|
|
667
|
+
const idMatch = href.match(/\/video\/(BV\w+)\//);
|
|
668
|
+
const id = idMatch ? idMatch[1] : "";
|
|
669
|
+
if (!id) {
|
|
670
|
+
const htmlElement = item;
|
|
671
|
+
htmlElement.style.display = "none";
|
|
672
|
+
} else {
|
|
673
|
+
const overlay = document.createElement("div");
|
|
674
|
+
overlay.style.position = "absolute";
|
|
675
|
+
overlay.style.top = `${point[0]}%`;
|
|
676
|
+
overlay.style.left = `${point[1]}%`;
|
|
677
|
+
overlay.style.transform = "translate(-50%, -50%)";
|
|
678
|
+
overlay.style.fontSize = "48px";
|
|
679
|
+
overlay.style.fontWeight = "bold";
|
|
680
|
+
overlay.style.color = "black";
|
|
681
|
+
overlay.style.zIndex = "10";
|
|
682
|
+
overlay.style.backgroundColor = "rgba(255, 255, 255, 0.7)";
|
|
683
|
+
overlay.style.padding = "10px";
|
|
684
|
+
overlay.style.borderRadius = "8px";
|
|
685
|
+
overlay.textContent = `${index + 1}`;
|
|
686
|
+
const videoElement = item;
|
|
687
|
+
videoElement.style.position = "relative";
|
|
688
|
+
videoElement.appendChild(overlay);
|
|
689
|
+
}
|
|
690
|
+
return { id };
|
|
691
|
+
}).filter((video) => video.id);
|
|
692
|
+
}, config.point);
|
|
693
|
+
bilibiliParser.logInfo(options);
|
|
694
|
+
bilibiliParser.logInfo(`共找到 ${videos.length} 个视频:`);
|
|
695
|
+
videos.forEach((video, index) => {
|
|
696
|
+
bilibiliParser.logInfo(`序号 ${index + 1}: ID - ${video.id}`);
|
|
697
|
+
});
|
|
698
|
+
if (videos.length === 0) {
|
|
699
|
+
await page.close();
|
|
700
|
+
await session.send(import_koishi2.h.text("未找到相关视频。"));
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
const viewportHeight = 200 + videos.length * 100;
|
|
704
|
+
await page.setViewport({
|
|
705
|
+
width: 1440,
|
|
706
|
+
height: viewportHeight
|
|
707
|
+
});
|
|
708
|
+
bilibiliParser.logInfo("窗口:宽度:");
|
|
709
|
+
bilibiliParser.logInfo(1440);
|
|
710
|
+
bilibiliParser.logInfo("窗口:高度:");
|
|
711
|
+
bilibiliParser.logInfo(viewportHeight);
|
|
712
|
+
let msg;
|
|
713
|
+
const videoListElement = await page.$(".video-list.row");
|
|
714
|
+
if (videoListElement) {
|
|
715
|
+
const imgBuf = await videoListElement.screenshot({
|
|
716
|
+
captureBeyondViewport: false
|
|
717
|
+
});
|
|
718
|
+
msg = import_koishi2.h.image(imgBuf, "image/png");
|
|
719
|
+
}
|
|
720
|
+
if (page && config.pageclose) {
|
|
721
|
+
await page.close();
|
|
722
|
+
}
|
|
723
|
+
await session.send(msg + import_koishi2.h.text(`请选择视频的序号:`));
|
|
724
|
+
const userChoice = await session.prompt(config.timeout * 1e3);
|
|
725
|
+
const choiceIndex = parseInt(userChoice) - 1;
|
|
726
|
+
if (isNaN(choiceIndex) || choiceIndex < 0 || choiceIndex >= videos.length) {
|
|
727
|
+
await session.send(import_koishi2.h.text("输入无效,请输入正确的序号。"));
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const chosenVideo = videos[choiceIndex];
|
|
731
|
+
bilibiliParser.logInfo(`渲染序号设置
|
|
732
|
+
overlay.style.top = ${config.point[0]}%
|
|
733
|
+
overlay.style.left = ${config.point[1]}%`);
|
|
734
|
+
bilibiliParser.logInfo(`用户选择了序号 ${choiceIndex + 1}: ID - ${chosenVideo.id}`);
|
|
735
|
+
if (config.enable) {
|
|
736
|
+
const ret = await bilibiliParser.extractLinks(session, [{ type: "Video", id: chosenVideo.id }]);
|
|
737
|
+
if (ret && !bilibiliParser.isLinkProcessedRecently(ret, session.channelId)) {
|
|
738
|
+
await bilibiliParser.processVideoFromLink(session, ret, options);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
__name(apply, "apply");
|
|
745
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
746
|
+
0 && (module.exports = {
|
|
747
|
+
Config,
|
|
748
|
+
apply,
|
|
749
|
+
inject,
|
|
750
|
+
name,
|
|
751
|
+
usage
|
|
752
|
+
});
|