@forward-widget/danmu-universe 0.2.1 → 0.3.1
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/dist/danmu-universe.js +164 -7
- package/package.json +4 -5
package/dist/danmu-universe.js
CHANGED
|
@@ -4343,7 +4343,10 @@ const DEFAULT_COLOR_HEX = "ffffff", DEFAULT_COLOR_INT = parseInt(DEFAULT_COLOR_H
|
|
|
4343
4343
|
"never",
|
|
4344
4344
|
"auto"
|
|
4345
4345
|
]).catch("auto").optional().default("auto")
|
|
4346
|
-
})
|
|
4346
|
+
}), EMPTY_ANIME_CONFIG = {
|
|
4347
|
+
ID: "__empty__",
|
|
4348
|
+
TITLE: "\uD83D\uDE2D \u672A\u5339\u914D\u5230\u8D44\u6E90"
|
|
4349
|
+
};
|
|
4347
4350
|
var enc_base64 = __webpack_require__(716), enc_base64_default = __webpack_require__.n(enc_base64);
|
|
4348
4351
|
function safeJsonParse(e) {
|
|
4349
4352
|
try {
|
|
@@ -4977,6 +4980,66 @@ function noop() {}
|
|
|
4977
4980
|
function isEqual(e, t) {
|
|
4978
4981
|
return isEqualWith(e, t, noop);
|
|
4979
4982
|
}
|
|
4983
|
+
function isDeepKey(e) {
|
|
4984
|
+
switch(typeof e){
|
|
4985
|
+
case 'number':
|
|
4986
|
+
case 'symbol':
|
|
4987
|
+
return !1;
|
|
4988
|
+
case 'string':
|
|
4989
|
+
return e.includes('.') || e.includes('[') || e.includes(']');
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
function toKey(e) {
|
|
4993
|
+
return 'string' == typeof e || 'symbol' == typeof e ? e : Object.is(e?.valueOf?.(), -0) ? '-0' : String(e);
|
|
4994
|
+
}
|
|
4995
|
+
function toPath(e) {
|
|
4996
|
+
let t = [], r = e.length;
|
|
4997
|
+
if (0 === r) return t;
|
|
4998
|
+
let n = 0, i = '', o = '', s = !1;
|
|
4999
|
+
for(46 === e.charCodeAt(0) && (t.push(''), n++); n < r;){
|
|
5000
|
+
let a = e[n];
|
|
5001
|
+
o ? '\\' === a && n + 1 < r ? i += e[++n] : a === o ? o = '' : i += a : s ? '"' === a || "'" === a ? o = a : ']' === a ? (s = !1, t.push(i), i = '') : i += a : '[' === a ? (s = !0, i && (t.push(i), i = '')) : '.' === a ? i && (t.push(i), i = '') : i += a, n++;
|
|
5002
|
+
}
|
|
5003
|
+
return i && t.push(i), t;
|
|
5004
|
+
}
|
|
5005
|
+
function get(e, t, r) {
|
|
5006
|
+
if (null == e) return r;
|
|
5007
|
+
switch(typeof t){
|
|
5008
|
+
case 'string':
|
|
5009
|
+
{
|
|
5010
|
+
if (isUnsafeProperty(t)) return r;
|
|
5011
|
+
let n = e[t];
|
|
5012
|
+
if (void 0 === n) if (isDeepKey(t)) return get(e, toPath(t), r);
|
|
5013
|
+
else return r;
|
|
5014
|
+
return n;
|
|
5015
|
+
}
|
|
5016
|
+
case 'number':
|
|
5017
|
+
case 'symbol':
|
|
5018
|
+
{
|
|
5019
|
+
'number' == typeof t && (t = toKey(t));
|
|
5020
|
+
let n = e[t];
|
|
5021
|
+
if (void 0 === n) return r;
|
|
5022
|
+
return n;
|
|
5023
|
+
}
|
|
5024
|
+
default:
|
|
5025
|
+
{
|
|
5026
|
+
if (Array.isArray(t)) return getWithPath(e, t, r);
|
|
5027
|
+
if (isUnsafeProperty(t = Object.is(t?.valueOf(), -0) ? '-0' : String(t))) return r;
|
|
5028
|
+
let n = e[t];
|
|
5029
|
+
if (void 0 === n) return r;
|
|
5030
|
+
return n;
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
function getWithPath(e, t, r) {
|
|
5035
|
+
if (0 === t.length) return r;
|
|
5036
|
+
let n = e;
|
|
5037
|
+
for(let e = 0; e < t.length; e++){
|
|
5038
|
+
if (null == n || isUnsafeProperty(t[e])) return r;
|
|
5039
|
+
n = n[t[e]];
|
|
5040
|
+
}
|
|
5041
|
+
return void 0 === n ? r : n;
|
|
5042
|
+
}
|
|
4980
5043
|
function base_define_property(e, t, r) {
|
|
4981
5044
|
return t in e ? Object.defineProperty(e, t, {
|
|
4982
5045
|
value: r,
|
|
@@ -4996,6 +5059,13 @@ const providerCommentItemSchema = schemas_object({
|
|
|
4996
5059
|
content: schemas_string()
|
|
4997
5060
|
});
|
|
4998
5061
|
class BaseScraper {
|
|
5062
|
+
get providerConfig() {
|
|
5063
|
+
return this._providerConfig;
|
|
5064
|
+
}
|
|
5065
|
+
set providerConfig(e) {
|
|
5066
|
+
let t = get(e, this.providerName);
|
|
5067
|
+
t && (this.logger.debug("\u8BBE\u7F6E Provider \u914D\u7F6E", t), this._providerConfig = e);
|
|
5068
|
+
}
|
|
4999
5069
|
parseIdString(e) {
|
|
5000
5070
|
var t, r;
|
|
5001
5071
|
let n = safeJsonParse(decodeURIComponent(e)), i = null == (t = this.idSchema) ? void 0 : t.safeParse(n);
|
|
@@ -5030,7 +5100,7 @@ class BaseScraper {
|
|
|
5030
5100
|
}
|
|
5031
5101
|
constructor(){
|
|
5032
5102
|
var e = this;
|
|
5033
|
-
base_define_property(this, "idSchema", void 0), base_define_property(this, "fetch", new Fetch()), base_define_property(this, "GLOBAL_EPISODE_BLACKLIST_DEFAULT", "^(.*?)((.+?\u7248)|(\u7279(\u522B|\u5178))|((\u5BFC|\u6F14)\u5458|\u5609\u5BBE|\u89D2\u8272)\u8BBF\u8C08|\u798F\u5229|\u5148\u5BFC|\u5F69\u86CB|\u82B1\u7D6E|\u9884\u544A|\u7279\u8F91|\u4E13\u8BBF|\u8BBF\u8C08|\u5E55\u540E|\u5468\u8FB9|\u8D44\u8BAF|\u770B\u70B9|\u901F\u770B|\u56DE\u987E|\u76D8\u70B9|\u5408\u96C6|PV|MV|CM|OST|ED|OP|BD|\u7279\u5178|SP|NCOP|NCED|MENU|Web-DL|rip|x264|x265|aac|flac)(.*?)$"), base_define_property(this, "PROVIDER_SPECIFIC_BLACKLIST_DEFAULT", ""), base_define_property(this, "logger", {
|
|
5103
|
+
base_define_property(this, "_providerConfig", {}), base_define_property(this, "idSchema", void 0), base_define_property(this, "fetch", new Fetch()), base_define_property(this, "GLOBAL_EPISODE_BLACKLIST_DEFAULT", "^(.*?)((.+?\u7248)|(\u7279(\u522B|\u5178))|((\u5BFC|\u6F14)\u5458|\u5609\u5BBE|\u89D2\u8272)\u8BBF\u8C08|\u798F\u5229|\u5148\u5BFC|\u5F69\u86CB|\u82B1\u7D6E|\u9884\u544A|\u7279\u8F91|\u4E13\u8BBF|\u8BBF\u8C08|\u5E55\u540E|\u5468\u8FB9|\u8D44\u8BAF|\u770B\u70B9|\u901F\u770B|\u56DE\u987E|\u76D8\u70B9|\u5408\u96C6|PV|MV|CM|OST|ED|OP|BD|\u7279\u5178|SP|NCOP|NCED|MENU|Web-DL|rip|x264|x265|aac|flac)(.*?)$"), base_define_property(this, "PROVIDER_SPECIFIC_BLACKLIST_DEFAULT", ""), base_define_property(this, "logger", {
|
|
5034
5104
|
log: function(t) {
|
|
5035
5105
|
for(var r = arguments.length, n = Array(r > 1 ? r - 1 : 0), i = 1; i < r; i++)n[i - 1] = arguments[i];
|
|
5036
5106
|
console[t](`[${e.providerName}]`, ...n);
|
|
@@ -6208,6 +6278,65 @@ class IqiyiScraper extends BaseScraper {
|
|
|
6208
6278
|
});
|
|
6209
6279
|
}
|
|
6210
6280
|
}
|
|
6281
|
+
const assignValue = (e, t, r)=>{
|
|
6282
|
+
let n = e[t];
|
|
6283
|
+
Object.hasOwn(e, t) && eq(n, r) && (void 0 !== r || t in e) || (e[t] = r);
|
|
6284
|
+
}, IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
6285
|
+
function isIndex(e, t = Number.MAX_SAFE_INTEGER) {
|
|
6286
|
+
switch(typeof e){
|
|
6287
|
+
case 'number':
|
|
6288
|
+
return Number.isInteger(e) && e >= 0 && e < t;
|
|
6289
|
+
case 'symbol':
|
|
6290
|
+
return !1;
|
|
6291
|
+
case 'string':
|
|
6292
|
+
return IS_UNSIGNED_INTEGER.test(e);
|
|
6293
|
+
}
|
|
6294
|
+
}
|
|
6295
|
+
function isSymbol(e) {
|
|
6296
|
+
return 'symbol' == typeof e || e instanceof Symbol;
|
|
6297
|
+
}
|
|
6298
|
+
const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, regexIsPlainProp = /^\w*$/;
|
|
6299
|
+
function isKey(e, t) {
|
|
6300
|
+
return !Array.isArray(e) && (!!('number' == typeof e || 'boolean' == typeof e || null == e || isSymbol(e)) || 'string' == typeof e && (regexIsPlainProp.test(e) || !regexIsDeepProp.test(e)) || null != t && Object.hasOwn(t, e));
|
|
6301
|
+
}
|
|
6302
|
+
function isObject_isObject(e) {
|
|
6303
|
+
return null !== e && ('object' == typeof e || 'function' == typeof e);
|
|
6304
|
+
}
|
|
6305
|
+
function updateWith(e, t, r, n) {
|
|
6306
|
+
if (null == e && !isObject_isObject(e)) return e;
|
|
6307
|
+
let i = isKey(t, e) ? [
|
|
6308
|
+
t
|
|
6309
|
+
] : Array.isArray(t) ? t : 'string' == typeof t ? toPath(t) : [
|
|
6310
|
+
t
|
|
6311
|
+
], o = e;
|
|
6312
|
+
for(let t = 0; t < i.length && null != o; t++){
|
|
6313
|
+
let s, a = toKey(i[t]);
|
|
6314
|
+
if (!isUnsafeProperty(a)) {
|
|
6315
|
+
if (t === i.length - 1) s = r(o[a]);
|
|
6316
|
+
else {
|
|
6317
|
+
let r = o[a], l = n?.(r, a, e);
|
|
6318
|
+
s = void 0 !== l ? l : isObject_isObject(r) ? r : isIndex(i[t + 1]) ? [] : {};
|
|
6319
|
+
}
|
|
6320
|
+
assignValue(o, a, s), o = o[a];
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
return e;
|
|
6324
|
+
}
|
|
6325
|
+
function set_set(e, t, r) {
|
|
6326
|
+
return updateWith(e, t, ()=>r, ()=>void 0);
|
|
6327
|
+
}
|
|
6328
|
+
const providerConfigSchema = schemas_object({
|
|
6329
|
+
"provider.renren.mode": schemas_enum([
|
|
6330
|
+
"default",
|
|
6331
|
+
"choice"
|
|
6332
|
+
]).catch("default")
|
|
6333
|
+
}).transform((e)=>{
|
|
6334
|
+
let t = {};
|
|
6335
|
+
return Object.entries(e).forEach((e)=>{
|
|
6336
|
+
let [r, n] = e;
|
|
6337
|
+
set_set(t, r, n);
|
|
6338
|
+
}), t.provider;
|
|
6339
|
+
});
|
|
6211
6340
|
var aes = __webpack_require__(129), aes_default = __webpack_require__.n(aes), enc_utf8 = __webpack_require__(60), enc_utf8_default = __webpack_require__.n(enc_utf8), hmac_sha256 = __webpack_require__(939), hmac_sha256_default = __webpack_require__.n(hmac_sha256), mode_ecb = __webpack_require__(760), mode_ecb_default = __webpack_require__.n(mode_ecb), pad_pkcs7 = __webpack_require__(186), pad_pkcs7_default = __webpack_require__.n(pad_pkcs7);
|
|
6212
6341
|
function isNil(e) {
|
|
6213
6342
|
return null == e;
|
|
@@ -6398,7 +6527,8 @@ class RenRenScraper extends BaseScraper {
|
|
|
6398
6527
|
})).data;
|
|
6399
6528
|
}
|
|
6400
6529
|
async fetchEpisodeDanmu(e) {
|
|
6401
|
-
|
|
6530
|
+
let t = `https://static-dm.rrmj.plus/v1/produce/danmu/EPISODE/${e}`;
|
|
6531
|
+
return "choice" === this.providerConfig.renren.mode && (t = `https://static-dm.rrmj.plus/v1/produce/danmu/choice/EPISODE/${e}`), (await this.fetch.get(t, {
|
|
6402
6532
|
headers: {
|
|
6403
6533
|
Accept: "application/json"
|
|
6404
6534
|
},
|
|
@@ -7085,13 +7215,19 @@ class scrapers_Scraper {
|
|
|
7085
7215
|
}
|
|
7086
7216
|
return this.getEpisodes(...uniqWith(i, isEqual));
|
|
7087
7217
|
}
|
|
7218
|
+
setProviderConfig(e) {
|
|
7219
|
+
let { success: t, data: r } = providerConfigSchema.safeParse(e);
|
|
7220
|
+
t && this.scrapers.forEach((e)=>{
|
|
7221
|
+
e.providerConfig = r;
|
|
7222
|
+
});
|
|
7223
|
+
}
|
|
7088
7224
|
constructor(){
|
|
7089
7225
|
scrapers_define_property(this, "scrapers", []), scrapers.forEach((e)=>{
|
|
7090
7226
|
this.scrapers.push(new e());
|
|
7091
7227
|
});
|
|
7092
7228
|
}
|
|
7093
7229
|
}
|
|
7094
|
-
const widgetVersion = "0.
|
|
7230
|
+
const widgetVersion = "0.3.1";
|
|
7095
7231
|
WidgetMetadata = {
|
|
7096
7232
|
id: "baranwang.danmu.universe",
|
|
7097
7233
|
title: "\u901A\u7528\u5F39\u5E55",
|
|
@@ -7121,6 +7257,23 @@ WidgetMetadata = {
|
|
|
7121
7257
|
value: "never"
|
|
7122
7258
|
}
|
|
7123
7259
|
]
|
|
7260
|
+
},
|
|
7261
|
+
{
|
|
7262
|
+
title: `[${PROVIDER_NAMES.renren}] \u{5F39}\u{5E55}\u{6A21}\u{5F0F}`,
|
|
7263
|
+
name: "provider.renren.mode",
|
|
7264
|
+
description: "\u5F39\u5E55\u6A21\u5F0F\uFF0C\u7CBE\u9009\u5F39\u5E55\u76F8\u6BD4\u9ED8\u8BA4\u5F39\u5E55\u8D28\u91CF\u66F4\u9AD8",
|
|
7265
|
+
value: "default",
|
|
7266
|
+
type: "enumeration",
|
|
7267
|
+
enumOptions: [
|
|
7268
|
+
{
|
|
7269
|
+
title: "\u9ED8\u8BA4",
|
|
7270
|
+
value: "default"
|
|
7271
|
+
},
|
|
7272
|
+
{
|
|
7273
|
+
title: "\u7CBE\u9009",
|
|
7274
|
+
value: "choice"
|
|
7275
|
+
}
|
|
7276
|
+
]
|
|
7124
7277
|
}
|
|
7125
7278
|
],
|
|
7126
7279
|
modules: [
|
|
@@ -7156,6 +7309,7 @@ WidgetMetadata = {
|
|
|
7156
7309
|
};
|
|
7157
7310
|
const src_scraper = new scrapers_Scraper();
|
|
7158
7311
|
searchDanmu = async (e)=>{
|
|
7312
|
+
src_scraper.setProviderConfig(e);
|
|
7159
7313
|
let { type: t, episode: r, fuzzyMatch: n = "auto" } = e, i = [], o = await getDoubanIds(e);
|
|
7160
7314
|
if (o.length && (i = await src_scraper.getDetailWithDoubanIds(o, t, r)), !(null == i ? void 0 : i.length) && "auto" === n || "always" === n) {
|
|
7161
7315
|
let t = await src_scraper.getDetailWithSearchParams(e);
|
|
@@ -7172,16 +7326,19 @@ searchDanmu = async (e)=>{
|
|
|
7172
7326
|
} : {
|
|
7173
7327
|
animes: [
|
|
7174
7328
|
{
|
|
7175
|
-
animeId:
|
|
7176
|
-
animeTitle:
|
|
7329
|
+
animeId: EMPTY_ANIME_CONFIG.ID,
|
|
7330
|
+
animeTitle: EMPTY_ANIME_CONFIG.TITLE
|
|
7177
7331
|
}
|
|
7178
7332
|
]
|
|
7179
7333
|
};
|
|
7180
7334
|
}, getDetail = async (e)=>{
|
|
7335
|
+
src_scraper.setProviderConfig(e);
|
|
7181
7336
|
let { animeId: t, type: r, episode: n } = e;
|
|
7182
|
-
return t ? src_scraper.getDetailWithAnimeId(t.toString(), r, n) : null;
|
|
7337
|
+
return t && t !== EMPTY_ANIME_CONFIG.ID ? src_scraper.getDetailWithAnimeId(t.toString(), r, n) : null;
|
|
7183
7338
|
}, getComments = async (e)=>{
|
|
7339
|
+
src_scraper.setProviderConfig(e);
|
|
7184
7340
|
let { animeId: t, commentId: r, segmentTime: n, tmdbId: i, type: o, episode: s } = e, a = null != r ? r : t;
|
|
7341
|
+
if (a === EMPTY_ANIME_CONFIG.ID) return null;
|
|
7185
7342
|
if (!a) {
|
|
7186
7343
|
if (!i) return null;
|
|
7187
7344
|
let t = await getDoubanIds(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forward-widget/danmu-universe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/danmu-universe.js",
|
|
6
6
|
"exports": {
|
|
@@ -13,22 +13,21 @@
|
|
|
13
13
|
"crypto-js": "^4.2.0",
|
|
14
14
|
"es-toolkit": "^1.39.9",
|
|
15
15
|
"fast-xml-parser": "^5.2.5",
|
|
16
|
-
"p-limit": "^6.2.0",
|
|
17
16
|
"protobufjs": "^7.5.4",
|
|
18
17
|
"url-parse": "^1.5.10",
|
|
19
18
|
"zod": "4.0.17"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
|
-
"@forward-widget/libs": "
|
|
23
|
-
"@forward-widget/rslib-plugin": "
|
|
21
|
+
"@forward-widget/libs": "1.8.5",
|
|
22
|
+
"@forward-widget/rslib-plugin": "1.8.5",
|
|
24
23
|
"@rsdoctor/rspack-plugin": "^1.2.3",
|
|
25
24
|
"@rslib/core": "^0.12.4",
|
|
26
25
|
"@rstest/core": "^0.3.1",
|
|
27
26
|
"@types/crypto-js": "^4.2.2",
|
|
28
27
|
"@types/node": "^22.16.0",
|
|
29
28
|
"@types/url-parse": "^1.4.11",
|
|
30
|
-
"protobufjs-cli": "^1.1.3",
|
|
31
29
|
"rsbuild-plugin-protobufjs": "^0.0.0",
|
|
30
|
+
"type-fest": "^4.41.0",
|
|
32
31
|
"typescript": "^5.8.3"
|
|
33
32
|
},
|
|
34
33
|
"repository": {
|