@dan-uni/dan-any 1.3.0 → 1.3.3
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/README.md +1 -0
- package/dist/browser/index.min.js +13384 -1
- package/dist/browser/plugins/bili.min.js +77 -1
- package/dist/browser/plugins/index.min.js +2 -2
- package/dist/browser/plugins/stats.min.js +10 -1
- package/dist/browser/rslib-runtime.min.js +5 -5
- package/dist/browser/src/index.d.ts +4 -2
- package/dist/browser/src/utils/fileParser.d.ts +3 -0
- package/dist/node/index.js +1959 -1
- package/dist/node/plugins/bili.js +77 -1
- package/dist/node/plugins/index.js +2 -2
- package/dist/node/plugins/stats.js +10 -1
- package/dist/node/rslib-runtime.js +5 -5
- package/dist/node/src/index.d.ts +4 -2
- package/dist/node/src/utils/fileParser.d.ts +3 -0
- package/dist/umd/index.umd.min.js +1076 -320
- package/dist/umd/plugins/bili.umd.min.js +1077 -321
- package/dist/umd/plugins/index.umd.min.js +1077 -321
- package/dist/umd/src/index.d.ts +4 -2
- package/dist/umd/src/utils/fileParser.d.ts +3 -0
- package/package.json +5 -7
- package/src/index.test.ts +22 -0
- package/src/index.ts +130 -43
- package/src/utils/dm-gen.ts +1 -1
- package/src/utils/fileParser.ts +37 -0
- package/dist/browser/17.min.js +0 -13305
- package/dist/browser/705.min.js +0 -77
- package/dist/browser/898.min.js +0 -10
- package/dist/node/17.js +0 -1880
- package/dist/node/705.js +0 -77
- package/dist/node/898.js +0 -10
- /package/dist/browser/{17.min.js.LICENSE.txt → index.min.js.LICENSE.txt} +0 -0
|
@@ -1 +1,77 @@
|
|
|
1
|
-
|
|
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 "
|
|
2
|
-
export { stats } from "
|
|
1
|
+
export { bili } from "./bili.js";
|
|
2
|
+
export { stats } from "./stats.js";
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
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
|
})();
|
package/dist/node/src/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -200,9 +201,9 @@ export declare class UniPool {
|
|
|
200
201
|
minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
|
|
201
202
|
static import(file: unknown, options?: Options,
|
|
202
203
|
/**
|
|
203
|
-
*
|
|
204
|
+
* 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
|
|
204
205
|
*/
|
|
205
|
-
mod?: ('json' | 'str' | 'bin')[]): {
|
|
206
|
+
mod?: string | ('json' | 'str' | 'bin')[]): {
|
|
206
207
|
pool: UniPool;
|
|
207
208
|
fmt: DM_format;
|
|
208
209
|
};
|
|
@@ -213,6 +214,7 @@ export declare class UniPool {
|
|
|
213
214
|
}) | (DM_JSON_DDPlay & {
|
|
214
215
|
danuni?: DanUniConvertTip;
|
|
215
216
|
});
|
|
217
|
+
static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
|
|
216
218
|
static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
|
|
217
219
|
/**
|
|
218
220
|
* 转为 protobuf 二进制
|