@wahaha216/koishi-plugin-jmcomic 0.0.4 → 0.0.6
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/error/albumNotExist.error.d.ts +3 -0
- package/lib/error/photoNotExist.error.d.ts +3 -0
- package/lib/index.js +63 -26
- package/package.json +1 -1
- package/readme.md +10 -0
package/lib/index.js
CHANGED
|
@@ -33,14 +33,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// src/locales/zh-CN.yml
|
|
34
34
|
var require_zh_CN = __commonJS({
|
|
35
35
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
36
|
-
module2.exports = { commands: { jm: { description: "下载JM漫画,无需python!", examples: "jm
|
|
36
|
+
module2.exports = { commands: { jm: { description: "下载JM漫画,无需python!", examples: "jm album 本子数字ID\njm album info 本子数字ID\njm photo 本子章节数字ID", album: { examples: "jm album 数字ID", messages: { notExistError: "找不到该ID对应的本子", mysqlError: "已尝试所有备用地址,但是JM坏掉了" }, info: { examples: "jm album info 本子数字ID", messages: { notExistError: "找不到该ID对应的本子", mysqlError: "已尝试所有备用地址,但是JM坏掉了" } } }, photo: { examples: "jm photo 本子章节数字ID", messages: { notExistError: "找不到该ID对应的章节", mysqlError: "已尝试所有备用地址,但是JM坏掉了" } } } }, _config: [{ $desc: "基础设置", url: "JM域名", sendMethod: "发送方式", fileMethod: "文件获取方式<br>`buffer`: 读取成buffer后发送给bot实现端<br>`file`: 以`file:///` 本地路径形式发送,如docker环境,请在bot实现端同时映射/koishi目录", retryCount: "重试次数限制", password: "密码,留空则不加密", fileName: "文件名定义<br>`{{name}}`:标题<br>`{{id}}`:章节或者本子ID<br>`{{index}}`:多章节本子自动填充`1` 、 `2`" }, { level: "压缩级别,0~9,0为仅存储" }, { $desc: "缓存设置", cache: "缓存文件" }, { autoDelete: "自动删除缓存,**依赖cron服务**" }, { cron: "5位cron表达式", deleteInStart: "启动时检测", keepDays: "缓存保留时间(天)" }, { $desc: "开发者选项", debug: "调试模式,输出更多信息" }] };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// src/locales/en-US.yml
|
|
41
41
|
var require_en_US = __commonJS({
|
|
42
42
|
"src/locales/en-US.yml"(exports2, module2) {
|
|
43
|
-
module2.exports = { commands: { jm: { description: "Download JM comics without python!", examples: "jm
|
|
43
|
+
module2.exports = { commands: { jm: { description: "Download JM comics without python!", examples: "jm album albumID\njm album info albumID\njm photo photoID", album: { examples: "jm album albumID", messages: { notExistError: "albumID not found", mysqlError: "All alternate addresses have been tried. But no response." }, info: { examples: "jm album info albumID", messages: { notExistError: "albumID not found", mysqlError: "All alternate addresses have been tried. But no response." } } }, photo: { examples: "jm photo photoID", messages: { notExistError: "photoID not found", mysqlError: "All alternate addresses have been tried. But no response." } } } }, _config: [{ $desc: "Basic settings", url: "JM domain name", sendMethod: "Send method", fileMethod: "File acquisition method<br>`buffer`: Read as buffer and send it to the bot implementation.<br>`file`: Send it in the local path of `file:///`. For example, if in the docker environment, please map the `/koishi` directory at the bot implementation.", retryCount: "Retry limit", password: "Password, leave blank without encryption", fileName: "File name definition<br>`{{name}}`: Title<br>`{{id}}`: Chapter or Book ID<br>`{{index}}`: Multi-chapter book auto-filling `_1` `_2`" }, { level: "Compression level, 0~9, 0 is only stores" }, { $desc: "Cache settings", cache: "Cache files" }, { autoDelete: "Automatically delete cache, **need cron services**" }, { cron: "5-bit cron expression", deleteInStart: "Detection on startup", keepDays: "Cache retention time (days)" }, { $desc: "Developer Options", debug: "Debug mode, output more information" }] };
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -702,6 +702,30 @@ __name(archiverImage, "archiverImage");
|
|
|
702
702
|
var import_path2 = require("path");
|
|
703
703
|
var import_sharp2 = __toESM(require("sharp"));
|
|
704
704
|
var import_muhammara = require("muhammara");
|
|
705
|
+
|
|
706
|
+
// src/error/albumNotExist.error.ts
|
|
707
|
+
var AlbumNotExistError = class extends Error {
|
|
708
|
+
static {
|
|
709
|
+
__name(this, "AlbumNotExistError");
|
|
710
|
+
}
|
|
711
|
+
constructor(message) {
|
|
712
|
+
super(message);
|
|
713
|
+
this.name = "AlbumNotExistError";
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// src/error/photoNotExist.error.ts
|
|
718
|
+
var PhotoNotExistError = class extends Error {
|
|
719
|
+
static {
|
|
720
|
+
__name(this, "PhotoNotExistError");
|
|
721
|
+
}
|
|
722
|
+
constructor(message) {
|
|
723
|
+
super(message);
|
|
724
|
+
this.name = "PhotoNotExistError";
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// src/entity/JMAppClient.ts
|
|
705
729
|
var JMAppClient = class _JMAppClient extends JMClientAbstract {
|
|
706
730
|
static {
|
|
707
731
|
__name(this, "JMAppClient");
|
|
@@ -748,6 +772,7 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
|
|
|
748
772
|
responseType: "json"
|
|
749
773
|
});
|
|
750
774
|
const album_json = this.decodeBase64(res.data, timestamp);
|
|
775
|
+
if (!album_json.name) throw new AlbumNotExistError();
|
|
751
776
|
const album = JMAppAlbum.fromJson(album_json);
|
|
752
777
|
const series = album.getSeries();
|
|
753
778
|
const photos = [];
|
|
@@ -773,6 +798,7 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
|
|
|
773
798
|
responseType: "json"
|
|
774
799
|
});
|
|
775
800
|
const photo_json = this.decodeBase64(res.data, timestamp);
|
|
801
|
+
if (!photo_json.name) throw new PhotoNotExistError();
|
|
776
802
|
const photo = JMAppPhoto.fromJson(photo_json);
|
|
777
803
|
const images = photo.getImages();
|
|
778
804
|
const image_ids = images.map((image) => image.split(".")[0]);
|
|
@@ -794,9 +820,11 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
|
|
|
794
820
|
let path = `${this.root}/${type}/${id}/origin`;
|
|
795
821
|
if (debug) {
|
|
796
822
|
logger.info(`开始下载: ${id}`);
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
823
|
+
if (type === "album") {
|
|
824
|
+
logger.info(`单章节: ${single ? "是" : "否"}`);
|
|
825
|
+
logger.info(`子章节: ${albumId ? "是" : "否"}`);
|
|
826
|
+
logger.info(`本子ID: ${albumId}`);
|
|
827
|
+
}
|
|
800
828
|
}
|
|
801
829
|
if (type === "album") {
|
|
802
830
|
if (single) {
|
|
@@ -1171,13 +1199,16 @@ async function apply(ctx, config) {
|
|
|
1171
1199
|
if (!config.cache) (0, import_promises3.rm)(fileDir, { recursive: true });
|
|
1172
1200
|
}
|
|
1173
1201
|
} catch (error) {
|
|
1174
|
-
if (error instanceof
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1202
|
+
if (error instanceof AlbumNotExistError) {
|
|
1203
|
+
await session.send([
|
|
1204
|
+
import_koishi.h.quote(messageId),
|
|
1205
|
+
import_koishi.h.text(session.text(".notExistError"))
|
|
1206
|
+
]);
|
|
1207
|
+
} else if (error instanceof MySqlError) {
|
|
1208
|
+
await session.send([
|
|
1209
|
+
import_koishi.h.quote(messageId),
|
|
1210
|
+
import_koishi.h.text(session.text(".mysqlError"))
|
|
1211
|
+
]);
|
|
1181
1212
|
} else {
|
|
1182
1213
|
throw new Error(error);
|
|
1183
1214
|
}
|
|
@@ -1223,13 +1254,16 @@ async function apply(ctx, config) {
|
|
|
1223
1254
|
}
|
|
1224
1255
|
if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
|
|
1225
1256
|
} catch (error) {
|
|
1226
|
-
if (error instanceof
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1257
|
+
if (error instanceof PhotoNotExistError) {
|
|
1258
|
+
await session.send([
|
|
1259
|
+
import_koishi.h.quote(messageId),
|
|
1260
|
+
import_koishi.h.text(session.text(".notExistError"))
|
|
1261
|
+
]);
|
|
1262
|
+
} else if (error instanceof MySqlError) {
|
|
1263
|
+
await session.send([
|
|
1264
|
+
import_koishi.h.quote(messageId),
|
|
1265
|
+
import_koishi.h.text(session.text(".mysqlError"))
|
|
1266
|
+
]);
|
|
1233
1267
|
} else {
|
|
1234
1268
|
throw new Error(error);
|
|
1235
1269
|
}
|
|
@@ -1264,13 +1298,16 @@ async function apply(ctx, config) {
|
|
|
1264
1298
|
import_koishi.h.text(`观看数:${album.getTotalViews()}`)
|
|
1265
1299
|
]);
|
|
1266
1300
|
} catch (error) {
|
|
1267
|
-
if (error instanceof
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1301
|
+
if (error instanceof AlbumNotExistError) {
|
|
1302
|
+
await session.send([
|
|
1303
|
+
import_koishi.h.quote(messageId),
|
|
1304
|
+
import_koishi.h.text(session.text(".notExistError"))
|
|
1305
|
+
]);
|
|
1306
|
+
} else if (error instanceof MySqlError) {
|
|
1307
|
+
await session.send([
|
|
1308
|
+
import_koishi.h.quote(messageId),
|
|
1309
|
+
import_koishi.h.text(session.text(".mysqlError"))
|
|
1310
|
+
]);
|
|
1274
1311
|
} else {
|
|
1275
1312
|
throw new Error(error);
|
|
1276
1313
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED