@dan-uni/dan-any 1.3.0 → 1.3.4

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.
@@ -1 +1,77 @@
1
- export { bili_dedupe, bili_history_fast_forward } from "../705.js";
1
+ import { __webpack_require__ } from "../rslib-runtime.js";
2
+ import { DateTime } from "luxon";
3
+ import { UniPool, platform_PlatformVideoSource } from "../index.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,2 +1,2 @@
1
- export { bili } from "../705.js";
2
- export { stats } from "../898.js";
1
+ export { bili } from "./bili.js";
2
+ export { stats } from "./stats.js";
@@ -1 +1,10 @@
1
- export { getLatestDan } from "../898.js";
1
+ import { __webpack_require__ } from "../rslib-runtime.js";
2
+ var stats_namespaceObject = {};
3
+ __webpack_require__.r(stats_namespaceObject);
4
+ __webpack_require__.d(stats_namespaceObject, {
5
+ getLatestDan: ()=>getLatestDan
6
+ });
7
+ function getLatestDan(that) {
8
+ return 0 === that.dans.length ? null : that.dans.reduce((latest, current)=>current.ctime > latest.ctime ? current : latest);
9
+ }
10
+ export { getLatestDan, stats_namespaceObject as stats };
@@ -8,11 +8,6 @@ function __webpack_require__(moduleId) {
8
8
  __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
9
9
  return module.exports;
10
10
  }
11
- (()=>{
12
- __webpack_require__.add = function(modules) {
13
- Object.assign(__webpack_require__.m, modules);
14
- };
15
- })();
16
11
  (()=>{
17
12
  __webpack_require__.d = (exports, definition)=>{
18
13
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
@@ -21,6 +16,11 @@ function __webpack_require__(moduleId) {
21
16
  });
22
17
  };
23
18
  })();
19
+ (()=>{
20
+ __webpack_require__.add = function(modules) {
21
+ Object.assign(__webpack_require__.m, modules);
22
+ };
23
+ })();
24
24
  (()=>{
25
25
  __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
26
  })();
@@ -10,6 +10,7 @@ interface DanUniConvertTip {
10
10
  version: string;
11
11
  data?: string;
12
12
  }
13
+ export type DM_JSON_DanuniMin = Partial<UniDMTools.UniDMObj>[];
13
14
  export interface DM_XML_Bili {
14
15
  i: {
15
16
  chatserver: string;
@@ -140,6 +141,22 @@ export interface Options {
140
141
  */
141
142
  dmid?: boolean | number | UniIDTools.DMIDGenerator;
142
143
  }
144
+ type Convert2Format = DM_format.DanuniJson | DM_format.DanuniMinJson | DM_format.DanuniPbBin | DM_format.BiliXml | DM_format.DplayerJson | DM_format.ArtplayerJson | DM_format.DdplayJson;
145
+ type Convert2ResultMap = {
146
+ [DM_format.DanuniJson]: UniDM[];
147
+ [DM_format.DanuniMinJson]: DM_JSON_DanuniMin;
148
+ [DM_format.DanuniPbBin]: Uint8Array;
149
+ [DM_format.BiliXml]: string;
150
+ [DM_format.DplayerJson]: DM_JSON_Dplayer & {
151
+ danuni?: DanUniConvertTip;
152
+ };
153
+ [DM_format.ArtplayerJson]: DM_JSON_Artplayer & {
154
+ danuni?: DanUniConvertTip;
155
+ };
156
+ [DM_format.DdplayJson]: DM_JSON_DDPlay & {
157
+ danuni?: DanUniConvertTip;
158
+ };
159
+ };
143
160
  export declare class UniPool {
144
161
  dans: UniDM[];
145
162
  options: Options;
@@ -200,19 +217,15 @@ export declare class UniPool {
200
217
  minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
201
218
  static import(file: unknown, options?: Options,
202
219
  /**
203
- * 加载指定解析模块,为空则全选
220
+ * 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
204
221
  */
205
- mod?: ('json' | 'str' | 'bin')[]): {
222
+ mod?: string | ('json' | 'str' | 'bin')[]): {
206
223
  pool: UniPool;
207
224
  fmt: DM_format;
208
225
  };
209
- convert2(format: DM_format, continue_on_error?: boolean): string | Uint8Array<ArrayBuffer> | UniDM[] | (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[] | (DM_JSON_Dplayer & {
210
- danuni?: DanUniConvertTip;
211
- }) | (DM_JSON_Artplayer & {
212
- danuni?: DanUniConvertTip;
213
- }) | (DM_JSON_DDPlay & {
214
- danuni?: DanUniConvertTip;
215
- });
226
+ convert2<T extends Convert2Format>(format: T, file_wrapper: true, continue_on_error?: boolean): File;
227
+ convert2<T extends Convert2Format>(format: T, file_wrapper?: false, continue_on_error?: boolean): Convert2ResultMap[T];
228
+ static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
216
229
  static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
217
230
  /**
218
231
  * 转为 protobuf 二进制
@@ -0,0 +1,3 @@
1
+ export declare function fileParser(file: unknown, mod: 'bin'): ArrayBuffer | Uint8Array;
2
+ export declare function fileParser(file: unknown, mod: 'string'): string;
3
+ export declare function fileParser<T extends object>(file: unknown, mod: 'json'): T;