@wahaha216/koishi-plugin-jmcomic 0.0.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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 wahaha216
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,70 @@
1
+ import { IJMAlbumSeries } from "../types/JMClient";
2
+ import { JMPhotoAbstract } from "./JMPhotoAbstract";
3
+ export declare abstract class JMAlbumAbstract {
4
+ /**
5
+ * 本子ID
6
+ */
7
+ protected id: string;
8
+ /**
9
+ * 名称
10
+ */
11
+ protected name: string;
12
+ /**
13
+ * 章节列表
14
+ */
15
+ protected series: IJMAlbumSeries[];
16
+ /**
17
+ * 作品
18
+ */
19
+ protected works: string[];
20
+ /**
21
+ * 登场人物
22
+ */
23
+ protected actors: string[];
24
+ /**
25
+ * 标签
26
+ */
27
+ protected tags: string[];
28
+ /**
29
+ * 作者
30
+ */
31
+ protected authors: string[];
32
+ /**
33
+ * 描述
34
+ */
35
+ protected description: string;
36
+ /**
37
+ * 点赞数
38
+ */
39
+ protected likes: string;
40
+ /**
41
+ * 观看次数
42
+ */
43
+ protected total_views: string;
44
+ /**
45
+ * 章节信息
46
+ */
47
+ protected photos: JMPhotoAbstract[];
48
+ setId(id: string): void;
49
+ getId(): string;
50
+ setName(name: string): void;
51
+ getName(): string;
52
+ setSeries(series: IJMAlbumSeries[]): void;
53
+ getSeries(): IJMAlbumSeries[];
54
+ setWorks(works: string[]): void;
55
+ getWorks(): string[];
56
+ setActors(actors: string[]): void;
57
+ getActors(): string[];
58
+ setTags(tags: string[]): void;
59
+ getTags(): string[];
60
+ setAuthors(authors: string[]): void;
61
+ getAuthors(): string[];
62
+ setDescription(description: string): void;
63
+ getDescription(): string;
64
+ setLikes(likes: string): void;
65
+ getLikes(): string;
66
+ setTotalViews(totalViews: string): void;
67
+ getTotalViews(): string;
68
+ setPhotos(photos: JMPhotoAbstract[]): void;
69
+ getPhotos(): JMPhotoAbstract[];
70
+ }
@@ -0,0 +1,87 @@
1
+ import crypto from "crypto";
2
+ import { IJMUser } from "../types/JMClient";
3
+ import { JMPhotoAbstract } from "./JMPhotoAbstract";
4
+ import { JMAlbumAbstract } from "./JMAlbumAbstract";
5
+ export declare abstract class JMClientAbstract {
6
+ protected root: string;
7
+ constructor(root: string);
8
+ setRoot(root: string): void;
9
+ getRoot(): string;
10
+ /**
11
+ * JM登录
12
+ * @param username 用户名
13
+ * @param password 密码
14
+ * @returns JM用户信息
15
+ */
16
+ abstract login(username: string, password: string): Promise<IJMUser>;
17
+ /**
18
+ * 根据本子ID获取本子信息
19
+ * @param id 本子ID
20
+ * @returns JM本子信息
21
+ */
22
+ abstract getAlbumById(id: string): Promise<JMAlbumAbstract>;
23
+ /**
24
+ * 根据章节ID获取章节信息
25
+ * @param id 章节ID
26
+ * @returns JM章节信息
27
+ */
28
+ abstract getPhotoById(id: string): Promise<JMPhotoAbstract>;
29
+ /**
30
+ * 根据本子信息下载
31
+ * @param album 本子
32
+ */
33
+ abstract downloadByAlbum(album: JMAlbumAbstract): Promise<void>;
34
+ /**
35
+ * 根据章节信息下载
36
+ * @param photo 章节
37
+ * @param type 类型,章节或是本子
38
+ * @param albumId 类型为本子时,对应的本子ID
39
+ * @param single 类型为本子时,该本子是否是单章节
40
+ */
41
+ abstract downloadByPhoto(photo: JMPhotoAbstract, type: "photo" | "album", albumId: string, single: boolean): Promise<void>;
42
+ /**
43
+ * 本子 -> PDF
44
+ * @param album 本子信息
45
+ * @param password 可选:密码
46
+ */
47
+ abstract albumToPdf(album: JMAlbumAbstract, password?: string): Promise<string | string[]>;
48
+ /**
49
+ * 本子 -> 压缩包
50
+ * @param album 章节信息
51
+ * @param password 可选:密码
52
+ * @param level 可选:压缩等级
53
+ */
54
+ abstract albumToZip(album: JMAlbumAbstract, password?: string, level?: number): Promise<string>;
55
+ /**
56
+ * 章节 -> PDF
57
+ * @param photo 章节
58
+ * @param pdfName PDF路径
59
+ * @param type 类型,章节或是本子
60
+ * @param albumId 类型为本子时,对应的本子ID
61
+ * @param single 类型为本子时,该本子是否是单章节
62
+ * @param password 可选:密码
63
+ */
64
+ abstract photoToPdf(photo: JMPhotoAbstract, pdfName: string, type: "photo" | "album", albumId: string, single: boolean, password?: string): Promise<string>;
65
+ /**
66
+ * 章节 -> ZIP
67
+ * @param photo 章节信息
68
+ * @param zipName zip名称
69
+ * @param password 可选,压缩包密码
70
+ * @param level 可选,压缩等级
71
+ */
72
+ abstract photoToZip(photo: JMPhotoAbstract, zipName: string, password?: string, level?: number): Promise<string>;
73
+ /**
74
+ * 解密章节图片
75
+ * @param photo 章节
76
+ * @param type 类型,章节或是本子
77
+ * @param albumId 类型为本子时,对应的本子ID
78
+ * @param single 类型为本子时,该本子是否是单章节
79
+ */
80
+ abstract decodeByPhoto(photo: JMPhotoAbstract, type: "photo" | "album", albumId: string, single: boolean): Promise<void>;
81
+ /**
82
+ * 使用MD5将字符串加密成十六进制
83
+ * @param key 要计算MD5的字符串
84
+ * @returns 十六进制MD5
85
+ */
86
+ md5Hex(key: string, inputEncoding?: crypto.Encoding): string;
87
+ }
@@ -0,0 +1,20 @@
1
+ export declare abstract class JMPhotoAbstract {
2
+ static SCRAMBLE_268850: number;
3
+ static SCRAMBLE_421926: number;
4
+ protected id: number;
5
+ protected images: string[];
6
+ protected image_names: string[];
7
+ protected splitNumbers: number[];
8
+ setId(id: number): void;
9
+ getId(): number;
10
+ setImages(images: string[]): void;
11
+ getImages(): string[];
12
+ setImageNames(imageNames: string[]): void;
13
+ getImageNames(): string[];
14
+ setSplitNumbers(splitNumbers: number[]): void;
15
+ getSplitNumbers(): number[];
16
+ /**
17
+ * 生成图片分割数
18
+ */
19
+ generateSplitNumbers(scramble_id: number): void;
20
+ }
@@ -0,0 +1,80 @@
1
+ import { Photo } from "./Photo";
2
+ export declare class Album {
3
+ private id;
4
+ private jmId;
5
+ private scramble_id;
6
+ /**
7
+ * 名称
8
+ */
9
+ private name;
10
+ /**
11
+ * 章节列表
12
+ */
13
+ private episodes;
14
+ /**
15
+ * 总页数
16
+ */
17
+ private page_count;
18
+ /**
19
+ * 发布时间
20
+ */
21
+ private public_date;
22
+ /**
23
+ * 更新时间
24
+ */
25
+ private update_date;
26
+ /**
27
+ * 作品
28
+ */
29
+ private works;
30
+ /**
31
+ * 登场人物
32
+ */
33
+ private actors;
34
+ /**
35
+ * 标签
36
+ */
37
+ private tags;
38
+ /**
39
+ * 作者
40
+ */
41
+ private authors;
42
+ /**
43
+ * 描述
44
+ */
45
+ private description;
46
+ /**
47
+ * 点赞数
48
+ */
49
+ private likes;
50
+ /**
51
+ * 观看次数
52
+ */
53
+ private views;
54
+ /**
55
+ * 章节详情列表
56
+ */
57
+ private photos;
58
+ constructor(html: string);
59
+ private extractLables;
60
+ getId(): string;
61
+ getJMId(): string;
62
+ getName(): string;
63
+ getScrambleId(): number;
64
+ getEpisodes(): {
65
+ name: string;
66
+ photoId: string;
67
+ }[];
68
+ addPhoto(photo: Photo): void;
69
+ getPhotos(): Photo[];
70
+ getPageCount(): number;
71
+ getPublicDate(): string;
72
+ getUpdateDate(): string;
73
+ getWorks(): string[];
74
+ getActors(): string[];
75
+ getTags(): string[];
76
+ getAuthor(): string[];
77
+ getDescription(): string;
78
+ getLikes(): string;
79
+ getViews(): string;
80
+ }
@@ -0,0 +1,38 @@
1
+ import { JMAlbumAbstract } from "../abstract/JMAlbumAbstract";
2
+ import { IJMAlbum, IJMAlbumRelated } from "../types/JMClient";
3
+ import { JMAppPhoto } from "./JMAppPhoto";
4
+ export declare class JMAppAlbum extends JMAlbumAbstract {
5
+ private images;
6
+ private addtime;
7
+ private series_id;
8
+ private comment_total;
9
+ private related_list;
10
+ private liked;
11
+ private is_favorite;
12
+ private is_aids;
13
+ private price;
14
+ private purchased;
15
+ constructor(json: IJMAlbum);
16
+ setImages(images: string[]): void;
17
+ getImages(): string[];
18
+ setAddtime(addtime: string): void;
19
+ getAddtime(): string;
20
+ setSeriesId(seriesId: string): void;
21
+ getSeriesId(): string;
22
+ setCommentTotal(commentTotal: string): void;
23
+ getCommentTotal(): string;
24
+ setRelatedList(relatedList: IJMAlbumRelated[]): void;
25
+ getRelatedList(): IJMAlbumRelated[];
26
+ setLiked(liked: boolean): void;
27
+ getLiked(): boolean;
28
+ setIsFavorite(isFavorite: boolean): void;
29
+ getIsFavorite(): boolean;
30
+ setIsAids(isAids: boolean): void;
31
+ getIsAids(): boolean;
32
+ setPrice(price: string): void;
33
+ getPrice(): string;
34
+ setPurchased(purchased: string): void;
35
+ getPurchased(): string;
36
+ getPhotos(): JMAppPhoto[];
37
+ static fromJson(json: IJMAlbum): JMAppAlbum;
38
+ }
@@ -0,0 +1,54 @@
1
+ import { IJMUser } from "../types/JMClient";
2
+ import { JMClientAbstract } from "../abstract/JMClientAbstract";
3
+ import { JMAppPhoto } from "./JMAppPhoto";
4
+ import { JMAppAlbum } from "./JMAppAlbum";
5
+ import { JMPhotoAbstract } from "../abstract/JMPhotoAbstract";
6
+ export declare class JMAppClient extends JMClientAbstract {
7
+ static APP_VERSION: string;
8
+ static APP_TOKEN_SECRET: string;
9
+ static APP_TOKEN_SECRET_2: string;
10
+ static APP_DATA_SECRET: string;
11
+ constructor(root: string);
12
+ /**
13
+ * 登录,未完成
14
+ * @param username 用户名
15
+ * @param password 密码
16
+ * @returns 用户信息
17
+ */
18
+ login(username: string, password: string): Promise<IJMUser>;
19
+ getAlbumById(id: string): Promise<JMAppAlbum>;
20
+ getPhotoById(id: string): Promise<JMAppPhoto>;
21
+ downloadByAlbum(album: JMAppAlbum): Promise<void>;
22
+ downloadByPhoto(photo: JMAppPhoto, type?: "photo" | "album", albumId?: string, single?: boolean): Promise<void>;
23
+ decodeByPhoto(photo: JMPhotoAbstract, type?: "photo" | "album", albumId?: string, single?: boolean): Promise<void>;
24
+ albumToPdf(album: JMAppAlbum, password?: string): Promise<string | string[]>;
25
+ photoToPdf(photo: JMAppPhoto, pdfName: string, type?: "photo" | "album", albumId?: string, single?: boolean, password?: string): Promise<string>;
26
+ albumToZip(album: JMAppAlbum, password?: string, level?: number): Promise<string>;
27
+ photoToZip(photo: JMPhotoAbstract, zipName: string, password?: string, level?: number): Promise<string>;
28
+ /**
29
+ * 获取时间戳
30
+ * @returns 时间戳
31
+ */
32
+ getTimeStamp(): number;
33
+ /**
34
+ * 获取Scramble ID
35
+ * @param id JM本子ID
36
+ */
37
+ requestScrambleId(id: number): Promise<number>;
38
+ /**
39
+ * 获取请求时所需的token和tokenparam
40
+ * @param timestamp 时间戳
41
+ * @param version APP版本
42
+ * @param secret 密钥
43
+ * @returns 请求时所需的token和tokenparam
44
+ */
45
+ private getTokenAndTokenParam;
46
+ /**
47
+ * 解密加密字符串
48
+ * @param timestamp 请求时传递的时间戳
49
+ * @param base64 待解密的字符串
50
+ * @param secret
51
+ * @returns 解密结果,JSON
52
+ */
53
+ private decodeBase64;
54
+ }
@@ -0,0 +1,32 @@
1
+ import { JMPhotoAbstract } from "../abstract/JMPhotoAbstract";
2
+ import { IJMPhoto } from "../types/JMClient";
3
+ export declare class JMAppPhoto extends JMPhotoAbstract {
4
+ private series;
5
+ private tags;
6
+ private name;
7
+ private addtime;
8
+ private series_id;
9
+ private is_favorite;
10
+ private liked;
11
+ constructor(json: IJMPhoto);
12
+ setSeries(series: string[]): void;
13
+ getSeries(): string[];
14
+ setTags(tags: string): void;
15
+ getTags(): string;
16
+ setName(name: string): void;
17
+ getName(): string;
18
+ setAddtime(addtime: string): void;
19
+ getAddtime(): string;
20
+ setSeriesId(seriesId: string): void;
21
+ getSeriesId(): string;
22
+ setIsFavorite(isFavorite: boolean): void;
23
+ getIsFavorite(): boolean;
24
+ setLiked(liked: boolean): void;
25
+ getLiked(): boolean;
26
+ /**
27
+ * 从JSON数据返回JMPhoto实体类
28
+ * @param json JMPhoto JSON数据
29
+ * @returns
30
+ */
31
+ static fromJson(json: IJMPhoto): JMAppPhoto;
32
+ }
@@ -0,0 +1,43 @@
1
+ import { JMAlbumAbstract } from "../abstract/JMAlbumAbstract";
2
+ import { JMHtmlPhoto } from "./JMHtmlPhoto";
3
+ export declare class JMHtmlAlbum extends JMAlbumAbstract {
4
+ private jmId;
5
+ private scramble_id;
6
+ /**
7
+ * 章节列表
8
+ */
9
+ private episodes;
10
+ /**
11
+ * 总页数
12
+ */
13
+ private page_count;
14
+ /**
15
+ * 发布时间
16
+ */
17
+ private public_date;
18
+ /**
19
+ * 更新时间
20
+ */
21
+ private update_date;
22
+ constructor(html: string);
23
+ private extractLables;
24
+ getId(): string;
25
+ getJMId(): string;
26
+ getName(): string;
27
+ getScrambleId(): number;
28
+ getEpisodes(): {
29
+ name: string;
30
+ photoId: string;
31
+ }[];
32
+ getPhotos(): JMHtmlPhoto[];
33
+ getPageCount(): number;
34
+ getPublicDate(): string;
35
+ getUpdateDate(): string;
36
+ getWorks(): string[];
37
+ getActors(): string[];
38
+ getTags(): string[];
39
+ getAuthor(): string[];
40
+ getDescription(): string;
41
+ getLikes(): string;
42
+ getTotalViews(): string;
43
+ }
@@ -0,0 +1,17 @@
1
+ import { JMClientAbstract } from "../abstract/JMClientAbstract";
2
+ import { IJMUser } from "../types/JMClient";
3
+ import { JMHtmlAlbum } from "./JMHtmlAlbum";
4
+ import { JMHtmlPhoto } from "./JMHtmlPhoto";
5
+ export declare class JMHtmlClient extends JMClientAbstract {
6
+ constructor(root: string);
7
+ login(username: string, password: string): Promise<IJMUser>;
8
+ getAlbumById(id: string): Promise<JMHtmlAlbum>;
9
+ getPhotoById(id: string): Promise<JMHtmlPhoto>;
10
+ downloadByAlbum(album: JMHtmlAlbum): Promise<void>;
11
+ downloadByPhoto(photo: JMHtmlPhoto, type?: "photo" | "album", albumId?: string, single?: boolean): Promise<void>;
12
+ decodeByPhoto(photo: JMHtmlPhoto, type?: "photo" | "album", albumId?: string, single?: boolean): Promise<void>;
13
+ albumToPdf(album: JMHtmlAlbum, password?: string): Promise<string | string[]>;
14
+ albumToZip(album: JMHtmlAlbum, password?: string, level?: number): Promise<string>;
15
+ photoToPdf(photo: JMHtmlPhoto, pdfName: string, type: "photo" | "album", albumId: string, single: boolean, password?: string): Promise<string>;
16
+ photoToZip(photo: JMHtmlPhoto, zipName: string, password?: string, level?: number): Promise<string>;
17
+ }
@@ -0,0 +1,22 @@
1
+ import { JMPhotoAbstract } from "../abstract/JMPhotoAbstract";
2
+ export declare class JMHtmlPhoto extends JMPhotoAbstract {
3
+ static SCRAMBLE_268850: number;
4
+ static SCRAMBLE_421926: number;
5
+ private scramble_id;
6
+ private photo_ids;
7
+ private photo_urls;
8
+ constructor(html: string);
9
+ /**
10
+ * 获取图片分割数
11
+ * @returns {number} 图片分割数
12
+ * @description 根据 scramble_id 和 id 获取图片分割数
13
+ */
14
+ getSplitNumbers(): number[];
15
+ /**
16
+ * 获取JM ID
17
+ * @returns {number} JM ID
18
+ */
19
+ getId(): number;
20
+ getPhotoUrls(): string[];
21
+ getPhotoIds(): string[];
22
+ }
@@ -0,0 +1,30 @@
1
+ import { IJMUser } from "../types/JMClient";
2
+ export declare class JMUser {
3
+ private uid;
4
+ private username;
5
+ private email;
6
+ private emailverified;
7
+ private photo;
8
+ private fname;
9
+ private gender;
10
+ private message;
11
+ private coin;
12
+ private album_favorites;
13
+ private s;
14
+ private level_name;
15
+ private level;
16
+ private nextLevelExp;
17
+ private exp;
18
+ private expPercent;
19
+ private badges;
20
+ private album_favorites_max;
21
+ private ad_free;
22
+ private ad_free_before;
23
+ private charge;
24
+ private jar;
25
+ private invitation_qrcode;
26
+ private invitation_url;
27
+ private invited_cnt;
28
+ private jwttoken;
29
+ constructor(info: IJMUser);
30
+ }
@@ -0,0 +1,32 @@
1
+ export declare class Photo {
2
+ static SCRAMBLE_268850: number;
3
+ static SCRAMBLE_421926: number;
4
+ /**
5
+ * JMComic ID
6
+ */
7
+ private id;
8
+ private scramble_id;
9
+ /**
10
+ * 图片名称列表
11
+ * @type {string[]} 图片名称列表
12
+ * @description 例如 ["00001", "00002", ...]
13
+ */
14
+ private photo_names;
15
+ private photo_ids;
16
+ private photo_urls;
17
+ constructor(html: string);
18
+ /**
19
+ * 获取图片分割数
20
+ * @returns {number} 图片分割数
21
+ * @description 根据 scramble_id 和 id 获取图片分割数
22
+ */
23
+ getSplitNumbers(): number[];
24
+ /**
25
+ * 获取JM ID
26
+ * @returns {number} JM ID
27
+ */
28
+ getId(): number;
29
+ getPhotoUrls(): string[];
30
+ getPhotoNames(): string[];
31
+ getPhotoIds(): string[];
32
+ }
@@ -0,0 +1,3 @@
1
+ export declare class EmptyBufferError extends Error {
2
+ constructor(message?: string);
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare class MySqlError extends Error {
2
+ constructor(message?: string);
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare class OverRetryError extends Error {
2
+ constructor(message?: string);
3
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { Context, HTTP, Logger, Schema } from "koishi";
2
+ export declare const name = "jmcomic";
3
+ export interface Config {
4
+ sendMethod?: "zip" | "pdf";
5
+ retryCount?: number;
6
+ password?: string;
7
+ fileName?: string;
8
+ level?: number;
9
+ cache?: boolean;
10
+ autoDelete?: boolean;
11
+ deleteInStart?: boolean;
12
+ keepDays?: number;
13
+ cron?: string;
14
+ debug?: boolean;
15
+ }
16
+ export declare const Config: Schema<Config>;
17
+ export declare const inject: {
18
+ required: string[];
19
+ optional: string[];
20
+ };
21
+ export declare let http: HTTP;
22
+ export declare let logger: Logger;
23
+ export declare let retryCount: number;
24
+ export declare let debug: boolean;
25
+ export declare function apply(ctx: Context, config: Config): Promise<void>;