@dan-uni/dan-any 1.2.2 → 1.2.7

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 (50) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/17.min.js +28 -18
  3. package/dist/browser/705.min.js +77 -0
  4. package/dist/browser/index.min.js +1 -1
  5. package/dist/browser/plugins/bili.min.js +1 -0
  6. package/dist/browser/plugins/index.min.js +1 -1
  7. package/dist/browser/src/index.d.ts +13 -5
  8. package/dist/browser/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  9. package/dist/browser/src/plugins/bili/index.d.ts +2 -0
  10. package/dist/browser/src/plugins/index.d.ts +1 -1
  11. package/dist/node/17.js +28 -18
  12. package/dist/node/705.js +77 -0
  13. package/dist/node/index.js +1 -1
  14. package/dist/node/plugins/bili.js +1 -0
  15. package/dist/node/plugins/index.js +1 -1
  16. package/dist/node/src/index.d.ts +13 -5
  17. package/dist/node/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  18. package/dist/node/src/plugins/bili/index.d.ts +2 -0
  19. package/dist/node/src/plugins/index.d.ts +1 -1
  20. package/dist/umd/index.umd.min.js +44 -24
  21. package/dist/umd/plugins/{bili-dedupe.umd.min.js → bili.umd.min.js} +4644 -29
  22. package/dist/umd/plugins/index.umd.min.js +4646 -31
  23. package/dist/umd/src/index.d.ts +13 -5
  24. package/dist/umd/src/plugins/bili/history-danmaku-fast-forward.d.ts +18 -0
  25. package/dist/umd/src/plugins/bili/index.d.ts +2 -0
  26. package/dist/umd/src/plugins/index.d.ts +1 -1
  27. package/package.json +5 -3
  28. package/rslib.config.ts +1 -1
  29. package/src/index.ts +26 -32
  30. package/src/plugins/bili/README.md +87 -0
  31. package/src/plugins/bili/history-danmaku-fast-forward.ts +86 -0
  32. package/src/plugins/bili/index.test.ts +129 -0
  33. package/src/plugins/bili/index.ts +2 -0
  34. package/src/plugins/index.ts +1 -1
  35. package/src/plugins/stats/README.md +44 -0
  36. package/src/plugins/stats/index.test.ts +1 -1
  37. package/src/utils/dm-gen.ts +2 -2
  38. package/dist/browser/157.min.js +0 -30
  39. package/dist/browser/plugins/bili-dedupe.min.js +0 -1
  40. package/dist/node/157.js +0 -30
  41. package/dist/node/plugins/bili-dedupe.js +0 -1
  42. package/src/plugins/bili-dedupe/index.test.ts +0 -43
  43. /package/dist/browser/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  44. /package/dist/browser/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  45. /package/dist/node/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  46. /package/dist/node/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  47. /package/dist/umd/plugins/{bili-dedupe.umd.min.js.LICENSE.txt → bili.umd.min.js.LICENSE.txt} +0 -0
  48. /package/dist/umd/src/plugins/{bili-dedupe/index.d.ts → bili/dedupe.d.ts} +0 -0
  49. /package/dist/umd/src/plugins/{bili-dedupe → bili}/index.test.d.ts +0 -0
  50. /package/src/plugins/{bili-dedupe/index.ts → bili/dedupe.ts} +0 -0
package/README.md CHANGED
@@ -29,6 +29,7 @@
29
29
  插件的使用方法参见对应路径下README.md
30
30
 
31
31
  - [dan-any-plugin-detaolu](https://github.com/ani-uni/danuni/tree/master/packages/dan-any-plugin-detaolu): 基于pakku.js的弹幕过滤器
32
+ - `src/plugins`下的插件 `bili`(B站弹幕相关) `stats`(统计相关),内部附有使用文档
32
33
 
33
34
  ## 特殊字段提示
34
35
 
@@ -11461,7 +11461,7 @@ __webpack_require__.d(platform_namespaceObject, {
11461
11461
  PlatformVideoSource: ()=>platform_PlatformVideoSource,
11462
11462
  PlatformVideoSources: ()=>PlatformVideoSources
11463
11463
  });
11464
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.2","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
11464
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.7","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
11465
11465
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
11466
11466
  const decimalToHex = (n)=>color_pad(n.toString(16));
11467
11467
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -11776,7 +11776,7 @@ class UniDM {
11776
11776
  if (this.attr.length > 0) result.attr = this.attr;
11777
11777
  if (void 0 !== this.platform) result.platform = this.platform;
11778
11778
  if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
11779
- if (void 0 !== this.DMID) result.DMID = this.DMID;
11779
+ if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
11780
11780
  return result;
11781
11781
  }
11782
11782
  downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
@@ -11892,7 +11892,7 @@ class UniDM {
11892
11892
  }) ? args.midHash : id_gen_UniID.fromBili({
11893
11893
  midHash: args.midHash
11894
11894
  });
11895
- let mode = 0;
11895
+ let mode;
11896
11896
  const pool = args.pool;
11897
11897
  const extra = {
11898
11898
  bili: {
@@ -12729,6 +12729,19 @@ const DanUniConvertTipTemplate = {
12729
12729
  meassage: 'Converted by DanUni!',
12730
12730
  version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
12731
12731
  };
12732
+ var src_DM_format = /*#__PURE__*/ function(DM_format) {
12733
+ DM_format["DanuniJson"] = "danuni.json";
12734
+ DM_format["DanuniPbBin"] = "danuni.pb.bin";
12735
+ DM_format["BiliXml"] = "bili.xml";
12736
+ DM_format["BiliPbBin"] = "bili.pb.bin";
12737
+ DM_format["BiliCmdPbBin"] = "bili.cmd.pb.bin";
12738
+ DM_format["BiliUpJson"] = "bili.up.json";
12739
+ DM_format["DplayerJson"] = "dplayer.json";
12740
+ DM_format["ArtplayerJson"] = "artplayer.json";
12741
+ DM_format["DdplayJson"] = "ddplay.json";
12742
+ DM_format["CommonAss"] = "common.ass";
12743
+ return DM_format;
12744
+ }({});
12732
12745
  class UniPool {
12733
12746
  constructor(dans, options = {}, info = {
12734
12747
  fromConverted: false
@@ -12739,10 +12752,7 @@ class UniPool {
12739
12752
  if (false !== options.dedupe) options.dedupe = true;
12740
12753
  if (this.options.dedupe) this.dedupe();
12741
12754
  }
12742
- async pipe(fn) {
12743
- return fn(this);
12744
- }
12745
- pipeSync(fn) {
12755
+ pipe(fn) {
12746
12756
  return fn(this);
12747
12757
  }
12748
12758
  get shared() {
@@ -12954,23 +12964,23 @@ class UniPool {
12954
12964
  try {
12955
12965
  if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
12956
12966
  pool: new UniPool(json, options),
12957
- fmt: 'danuni.json'
12967
+ fmt: "danuni.json"
12958
12968
  };
12959
12969
  if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
12960
12970
  pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
12961
- fmt: 'artplayer.json'
12971
+ fmt: "artplayer.json"
12962
12972
  };
12963
12973
  if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
12964
12974
  pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
12965
- fmt: 'ddplay.json'
12975
+ fmt: "ddplay.json"
12966
12976
  };
12967
12977
  else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
12968
12978
  pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
12969
- fmt: 'dplayer.json'
12979
+ fmt: "dplayer.json"
12970
12980
  };
12971
12981
  else if (0 == json.code && '0' == json.message && json.data && json.data.page && json.data.result && Array.isArray(json.data.result) && json.data.result.every((d)=>d.id && d.oid)) return {
12972
12982
  pool: this.fromBiliUp(json, options),
12973
- fmt: 'bili.up.json'
12983
+ fmt: "bili.up.json"
12974
12984
  };
12975
12985
  } catch {}
12976
12986
  };
@@ -12989,13 +12999,13 @@ class UniPool {
12989
12999
  const xml = xmlParser.parse(file);
12990
13000
  if (xml?.i?.d) return {
12991
13001
  pool: this.fromBiliXML(file, options),
12992
- fmt: 'bili.xml'
13002
+ fmt: "bili.xml"
12993
13003
  };
12994
13004
  } catch {}
12995
13005
  try {
12996
13006
  return {
12997
13007
  pool: this.fromASS(file, options),
12998
- fmt: 'common.ass'
13008
+ fmt: "common.ass"
12999
13009
  };
13000
13010
  } catch {}
13001
13011
  }
@@ -13007,19 +13017,19 @@ class UniPool {
13007
13017
  try {
13008
13018
  return {
13009
13019
  pool: this.fromPb(file),
13010
- fmt: 'danuni.pb.bin'
13020
+ fmt: "danuni.pb.bin"
13011
13021
  };
13012
13022
  } catch {}
13013
13023
  try {
13014
13024
  return {
13015
13025
  pool: this.fromBiliGrpc(file),
13016
- fmt: 'bili.pb.bin'
13026
+ fmt: "bili.pb.bin"
13017
13027
  };
13018
13028
  } catch {}
13019
13029
  try {
13020
13030
  return {
13021
13031
  pool: this.fromBiliCommandGrpc(file),
13022
- fmt: 'bili.cmd.pb.bin'
13032
+ fmt: "bili.cmd.pb.bin"
13023
13033
  };
13024
13034
  } catch {}
13025
13035
  }
@@ -13286,4 +13296,4 @@ class UniPool {
13286
13296
  }, canvasCtx);
13287
13297
  }
13288
13298
  }
13289
- export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
13299
+ export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform, src_DM_format as DM_format };
@@ -0,0 +1,77 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.min.js";
2
+ import { DateTime } from "luxon";
3
+ import { UniPool, platform_PlatformVideoSource } from "./17.min.js";
4
+ var dedupe_namespaceObject = {};
5
+ __webpack_require__.r(dedupe_namespaceObject);
6
+ __webpack_require__.d(dedupe_namespaceObject, {
7
+ bili_dedupe: ()=>bili_dedupe,
8
+ to_bili_deduped: ()=>to_bili_deduped
9
+ });
10
+ var bili_namespaceObject = {};
11
+ __webpack_require__.r(bili_namespaceObject);
12
+ __webpack_require__.d(bili_namespaceObject, {
13
+ bili_dedupe: ()=>dedupe_namespaceObject,
14
+ bili_history_fast_forward: ()=>bili_history_fast_forward
15
+ });
16
+ function main(that) {
17
+ that.dans.forEach((d)=>{
18
+ if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
19
+ if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
20
+ });
21
+ const map = new Map();
22
+ that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
23
+ return map;
24
+ }
25
+ function to_bili_deduped(that) {
26
+ const map = main(that);
27
+ return new UniPool([
28
+ ...map.values()
29
+ ], that.options, that.info);
30
+ }
31
+ function bili_dedupe(that) {
32
+ const map = main(that);
33
+ that.dans = [
34
+ ...map.values()
35
+ ];
36
+ }
37
+ function history_danmaku_fast_forward_main(that, query_history_date) {
38
+ const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
39
+ zone: 'Asia/Shanghai'
40
+ }).setZone('Asia/Shanghai');
41
+ if (!qhd.isValid) throw new Error('Invalid query_history_date');
42
+ const s = qhd.startOf('day');
43
+ const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
44
+ if (0 === before.length) return {
45
+ earliest: null,
46
+ FastForward: [],
47
+ skip: [],
48
+ SpecificDate: qhd.toFormat('yyyy-MM-dd')
49
+ };
50
+ const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
51
+ const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
52
+ const datesWithDanmaku = new Set();
53
+ for (const dan of before){
54
+ const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
55
+ datesWithDanmaku.add(dateStr);
56
+ }
57
+ let current = earliestDate;
58
+ const allDates = [];
59
+ while(current < s){
60
+ allDates.push(current.toFormat('yyyy-MM-dd'));
61
+ current = current.plus({
62
+ days: 1
63
+ });
64
+ }
65
+ const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
66
+ const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
67
+ return {
68
+ earliest: earliestDate.toFormat('yyyy-MM-dd'),
69
+ FastForward,
70
+ skip,
71
+ SpecificDate: qhd.toFormat('yyyy-MM-dd')
72
+ };
73
+ }
74
+ function bili_history_fast_forward(query_history_date) {
75
+ return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
76
+ }
77
+ export { bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe };
@@ -1 +1 @@
1
- export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.min.js";
1
+ export { DM_format, UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.min.js";
@@ -0,0 +1 @@
1
+ export { bili_dedupe, bili_history_fast_forward } from "../705.min.js";
@@ -1,2 +1,2 @@
1
- export { bili_dedupe } from "../157.min.js";
1
+ export { bili } from "../705.min.js";
2
2
  export { stats } from "../898.min.js";
@@ -116,12 +116,21 @@ export interface DM_JSON_DDPlay {
116
116
  m: string;
117
117
  }[];
118
118
  }
119
- export type DM_format = 'danuni.json' | 'danuni.pb.bin' | 'bili.xml' | 'bili.pb.bin' | 'bili.cmd.pb.bin' | 'bili.up.json' | 'dplayer.json' | 'artplayer.json' | 'ddplay.json' | 'common.ass';
119
+ export declare enum DM_format {
120
+ DanuniJson = "danuni.json",
121
+ DanuniPbBin = "danuni.pb.bin",
122
+ BiliXml = "bili.xml",
123
+ BiliPbBin = "bili.pb.bin",
124
+ BiliCmdPbBin = "bili.cmd.pb.bin",
125
+ BiliUpJson = "bili.up.json",
126
+ DplayerJson = "dplayer.json",
127
+ ArtplayerJson = "artplayer.json",
128
+ DdplayJson = "ddplay.json",
129
+ CommonAss = "common.ass"
130
+ }
120
131
  type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
121
132
  type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
122
133
  type Stats<T extends keyof statItems> = Map<statItems[T], number>;
123
- type UniPoolPipe = (that: UniPool) => Promise<any>;
124
- type UniPoolPipeSync = (that: UniPool) => any;
125
134
  export interface Options {
126
135
  dedupe?: boolean;
127
136
  /**
@@ -145,8 +154,7 @@ export declare class UniPool {
145
154
  */
146
155
  fromConverted: boolean;
147
156
  });
148
- pipe<T extends (...args: any) => any = UniPoolPipe>(fn: T): Promise<ReturnType<T>>;
149
- pipeSync<T extends (...args: any) => any = UniPoolPipeSync>(fn: T): ReturnType<T>;
157
+ pipe<T extends (...args: any) => any>(fn: T): ReturnType<T>;
150
158
  /**
151
159
  * @deprecated 使用 `getShared` 代替
152
160
  */
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 注:该方法受BiliPlus全弹幕下载器启发
3
+ * 详情参考以下链接
4
+ * @see https://github.com/HengXin666/BiLiBiLi_DanMu_Crawling/issues/14
5
+ */
6
+ import type { UniPool } from '../..';
7
+ interface BiliHistoryDanmakuFastForwardResult {
8
+ earliest: string | null;
9
+ FastForward: string[];
10
+ skip: string[];
11
+ SpecificDate: string;
12
+ }
13
+ export declare function bili_history_fast_forward(
14
+ /**
15
+ * 请求api时使用的日期(UTC+8, yyyy-MM-dd)
16
+ */
17
+ query_history_date: string): (that: UniPool) => BiliHistoryDanmakuFastForwardResult;
18
+ export {};
@@ -0,0 +1,2 @@
1
+ export * as bili_dedupe from './dedupe';
2
+ export { bili_history_fast_forward } from './history-danmaku-fast-forward';
@@ -1,2 +1,2 @@
1
- export * as bili_dedupe from './bili-dedupe';
1
+ export * as bili from './bili';
2
2
  export * as stats from './stats';
package/dist/node/17.js CHANGED
@@ -39,7 +39,7 @@ __webpack_require__.d(platform_namespaceObject, {
39
39
  PlatformVideoSource: ()=>platform_PlatformVideoSource,
40
40
  PlatformVideoSources: ()=>PlatformVideoSources
41
41
  });
42
- var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.2","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
42
+ var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.7","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
43
43
  const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
44
44
  const decimalToHex = (n)=>color_pad(n.toString(16));
45
45
  const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
@@ -353,7 +353,7 @@ class UniDM {
353
353
  if (this.attr.length > 0) result.attr = this.attr;
354
354
  if (void 0 !== this.platform) result.platform = this.platform;
355
355
  if (this.extraStr && '{}' !== this.extraStr) result.extraStr = this.extraStr;
356
- if (void 0 !== this.DMID) result.DMID = this.DMID;
356
+ if (void 0 !== this.DMID && this.options.dmid) result.DMID = this.DMID;
357
357
  return result;
358
358
  }
359
359
  downgradeAdvcancedDan({ include, exclude, cleanExtra = false } = {}) {
@@ -469,7 +469,7 @@ class UniDM {
469
469
  }) ? args.midHash : id_gen_UniID.fromBili({
470
470
  midHash: args.midHash
471
471
  });
472
- let mode = 0;
472
+ let mode;
473
473
  const pool = args.pool;
474
474
  const extra = {
475
475
  bili: {
@@ -1304,6 +1304,19 @@ const DanUniConvertTipTemplate = {
1304
1304
  meassage: 'Converted by DanUni!',
1305
1305
  version: `JS/TS ${package_namespaceObject.UU} (v${package_namespaceObject.rE})`
1306
1306
  };
1307
+ var src_DM_format = /*#__PURE__*/ function(DM_format) {
1308
+ DM_format["DanuniJson"] = "danuni.json";
1309
+ DM_format["DanuniPbBin"] = "danuni.pb.bin";
1310
+ DM_format["BiliXml"] = "bili.xml";
1311
+ DM_format["BiliPbBin"] = "bili.pb.bin";
1312
+ DM_format["BiliCmdPbBin"] = "bili.cmd.pb.bin";
1313
+ DM_format["BiliUpJson"] = "bili.up.json";
1314
+ DM_format["DplayerJson"] = "dplayer.json";
1315
+ DM_format["ArtplayerJson"] = "artplayer.json";
1316
+ DM_format["DdplayJson"] = "ddplay.json";
1317
+ DM_format["CommonAss"] = "common.ass";
1318
+ return DM_format;
1319
+ }({});
1307
1320
  class UniPool {
1308
1321
  constructor(dans, options = {}, info = {
1309
1322
  fromConverted: false
@@ -1314,10 +1327,7 @@ class UniPool {
1314
1327
  if (false !== options.dedupe) options.dedupe = true;
1315
1328
  if (this.options.dedupe) this.dedupe();
1316
1329
  }
1317
- async pipe(fn) {
1318
- return fn(this);
1319
- }
1320
- pipeSync(fn) {
1330
+ pipe(fn) {
1321
1331
  return fn(this);
1322
1332
  }
1323
1333
  get shared() {
@@ -1529,23 +1539,23 @@ class UniPool {
1529
1539
  try {
1530
1540
  if (Array.isArray(json) && json.every((d)=>d.SOID)) return {
1531
1541
  pool: new UniPool(json, options),
1532
- fmt: 'danuni.json'
1542
+ fmt: "danuni.json"
1533
1543
  };
1534
1544
  if (json.danmuku && json.danmuku.every((d)=>d.text)) return {
1535
1545
  pool: this.fromArtplayer(json, json.danuni?.data ?? '', void 0, options),
1536
- fmt: 'artplayer.json'
1546
+ fmt: "artplayer.json"
1537
1547
  };
1538
1548
  if (json.count && json.comments && Array.isArray(json.comments) && json.comments.every((d)=>d.m)) return {
1539
1549
  pool: this.fromDDPlay(json, json.danuni?.data ?? '', options),
1540
- fmt: 'ddplay.json'
1550
+ fmt: "ddplay.json"
1541
1551
  };
1542
1552
  else if (0 == json.code && json.data && Array.isArray(json.data) && json.data.every((d)=>Array.isArray(d))) return {
1543
1553
  pool: this.fromDplayer(json, json.danuni?.data ?? '', void 0, options),
1544
- fmt: 'dplayer.json'
1554
+ fmt: "dplayer.json"
1545
1555
  };
1546
1556
  else if (0 == json.code && '0' == json.message && json.data && json.data.page && json.data.result && Array.isArray(json.data.result) && json.data.result.every((d)=>d.id && d.oid)) return {
1547
1557
  pool: this.fromBiliUp(json, options),
1548
- fmt: 'bili.up.json'
1558
+ fmt: "bili.up.json"
1549
1559
  };
1550
1560
  } catch {}
1551
1561
  };
@@ -1564,13 +1574,13 @@ class UniPool {
1564
1574
  const xml = xmlParser.parse(file);
1565
1575
  if (xml?.i?.d) return {
1566
1576
  pool: this.fromBiliXML(file, options),
1567
- fmt: 'bili.xml'
1577
+ fmt: "bili.xml"
1568
1578
  };
1569
1579
  } catch {}
1570
1580
  try {
1571
1581
  return {
1572
1582
  pool: this.fromASS(file, options),
1573
- fmt: 'common.ass'
1583
+ fmt: "common.ass"
1574
1584
  };
1575
1585
  } catch {}
1576
1586
  }
@@ -1582,19 +1592,19 @@ class UniPool {
1582
1592
  try {
1583
1593
  return {
1584
1594
  pool: this.fromPb(file),
1585
- fmt: 'danuni.pb.bin'
1595
+ fmt: "danuni.pb.bin"
1586
1596
  };
1587
1597
  } catch {}
1588
1598
  try {
1589
1599
  return {
1590
1600
  pool: this.fromBiliGrpc(file),
1591
- fmt: 'bili.pb.bin'
1601
+ fmt: "bili.pb.bin"
1592
1602
  };
1593
1603
  } catch {}
1594
1604
  try {
1595
1605
  return {
1596
1606
  pool: this.fromBiliCommandGrpc(file),
1597
- fmt: 'bili.cmd.pb.bin'
1607
+ fmt: "bili.cmd.pb.bin"
1598
1608
  };
1599
1609
  } catch {}
1600
1610
  }
@@ -1861,4 +1871,4 @@ class UniPool {
1861
1871
  }, canvasCtx);
1862
1872
  }
1863
1873
  }
1864
- export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
1874
+ export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform, src_DM_format as DM_format };
@@ -0,0 +1,77 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { DateTime } from "luxon";
3
+ import { UniPool, platform_PlatformVideoSource } from "./17.js";
4
+ var dedupe_namespaceObject = {};
5
+ __webpack_require__.r(dedupe_namespaceObject);
6
+ __webpack_require__.d(dedupe_namespaceObject, {
7
+ bili_dedupe: ()=>bili_dedupe,
8
+ to_bili_deduped: ()=>to_bili_deduped
9
+ });
10
+ var bili_namespaceObject = {};
11
+ __webpack_require__.r(bili_namespaceObject);
12
+ __webpack_require__.d(bili_namespaceObject, {
13
+ bili_dedupe: ()=>dedupe_namespaceObject,
14
+ bili_history_fast_forward: ()=>bili_history_fast_forward
15
+ });
16
+ function main(that) {
17
+ that.dans.forEach((d)=>{
18
+ if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
19
+ if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
20
+ });
21
+ const map = new Map();
22
+ that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
23
+ return map;
24
+ }
25
+ function to_bili_deduped(that) {
26
+ const map = main(that);
27
+ return new UniPool([
28
+ ...map.values()
29
+ ], that.options, that.info);
30
+ }
31
+ function bili_dedupe(that) {
32
+ const map = main(that);
33
+ that.dans = [
34
+ ...map.values()
35
+ ];
36
+ }
37
+ function history_danmaku_fast_forward_main(that, query_history_date) {
38
+ const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
39
+ zone: 'Asia/Shanghai'
40
+ }).setZone('Asia/Shanghai');
41
+ if (!qhd.isValid) throw new Error('Invalid query_history_date');
42
+ const s = qhd.startOf('day');
43
+ const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
44
+ if (0 === before.length) return {
45
+ earliest: null,
46
+ FastForward: [],
47
+ skip: [],
48
+ SpecificDate: qhd.toFormat('yyyy-MM-dd')
49
+ };
50
+ const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
51
+ const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
52
+ const datesWithDanmaku = new Set();
53
+ for (const dan of before){
54
+ const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
55
+ datesWithDanmaku.add(dateStr);
56
+ }
57
+ let current = earliestDate;
58
+ const allDates = [];
59
+ while(current < s){
60
+ allDates.push(current.toFormat('yyyy-MM-dd'));
61
+ current = current.plus({
62
+ days: 1
63
+ });
64
+ }
65
+ const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
66
+ const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
67
+ return {
68
+ earliest: earliestDate.toFormat('yyyy-MM-dd'),
69
+ FastForward,
70
+ skip,
71
+ SpecificDate: qhd.toFormat('yyyy-MM-dd')
72
+ };
73
+ }
74
+ function bili_history_fast_forward(query_history_date) {
75
+ return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
76
+ }
77
+ export { bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe };
@@ -1 +1 @@
1
- export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.js";
1
+ export { DM_format, UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.js";
@@ -0,0 +1 @@
1
+ export { bili_dedupe, bili_history_fast_forward } from "../705.js";
@@ -1,2 +1,2 @@
1
- export { bili_dedupe } from "../157.js";
1
+ export { bili } from "../705.js";
2
2
  export { stats } from "../898.js";
@@ -116,12 +116,21 @@ export interface DM_JSON_DDPlay {
116
116
  m: string;
117
117
  }[];
118
118
  }
119
- export type DM_format = 'danuni.json' | 'danuni.pb.bin' | 'bili.xml' | 'bili.pb.bin' | 'bili.cmd.pb.bin' | 'bili.up.json' | 'dplayer.json' | 'artplayer.json' | 'ddplay.json' | 'common.ass';
119
+ export declare enum DM_format {
120
+ DanuniJson = "danuni.json",
121
+ DanuniPbBin = "danuni.pb.bin",
122
+ BiliXml = "bili.xml",
123
+ BiliPbBin = "bili.pb.bin",
124
+ BiliCmdPbBin = "bili.cmd.pb.bin",
125
+ BiliUpJson = "bili.up.json",
126
+ DplayerJson = "dplayer.json",
127
+ ArtplayerJson = "artplayer.json",
128
+ DdplayJson = "ddplay.json",
129
+ CommonAss = "common.ass"
130
+ }
120
131
  type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
121
132
  type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
122
133
  type Stats<T extends keyof statItems> = Map<statItems[T], number>;
123
- type UniPoolPipe = (that: UniPool) => Promise<any>;
124
- type UniPoolPipeSync = (that: UniPool) => any;
125
134
  export interface Options {
126
135
  dedupe?: boolean;
127
136
  /**
@@ -145,8 +154,7 @@ export declare class UniPool {
145
154
  */
146
155
  fromConverted: boolean;
147
156
  });
148
- pipe<T extends (...args: any) => any = UniPoolPipe>(fn: T): Promise<ReturnType<T>>;
149
- pipeSync<T extends (...args: any) => any = UniPoolPipeSync>(fn: T): ReturnType<T>;
157
+ pipe<T extends (...args: any) => any>(fn: T): ReturnType<T>;
150
158
  /**
151
159
  * @deprecated 使用 `getShared` 代替
152
160
  */
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 注:该方法受BiliPlus全弹幕下载器启发
3
+ * 详情参考以下链接
4
+ * @see https://github.com/HengXin666/BiLiBiLi_DanMu_Crawling/issues/14
5
+ */
6
+ import type { UniPool } from '../..';
7
+ interface BiliHistoryDanmakuFastForwardResult {
8
+ earliest: string | null;
9
+ FastForward: string[];
10
+ skip: string[];
11
+ SpecificDate: string;
12
+ }
13
+ export declare function bili_history_fast_forward(
14
+ /**
15
+ * 请求api时使用的日期(UTC+8, yyyy-MM-dd)
16
+ */
17
+ query_history_date: string): (that: UniPool) => BiliHistoryDanmakuFastForwardResult;
18
+ export {};
@@ -0,0 +1,2 @@
1
+ export * as bili_dedupe from './dedupe';
2
+ export { bili_history_fast_forward } from './history-danmaku-fast-forward';
@@ -1,2 +1,2 @@
1
- export * as bili_dedupe from './bili-dedupe';
1
+ export * as bili from './bili';
2
2
  export * as stats from './stats';