koishi-plugin-magnet-get-lizard 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/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const name = "magnet-get-lizard";
3
+ export declare const inject: string[];
4
+ export declare const usage = "\n# \u26A0\uFE0F NSFW\u8B66\u544A!!!\n## \u901A\u8FC7\u5173\u952E\u8BCD\u641C\u7D22\u78C1\u529B\u94FE\u63A5\u8D44\u6E90\u3002\n\n## \u914D\u7F6E\u591A\u4E2A\u8D44\u6E90\u7AD9\u70B9\uFF0C\u82E5\u641C\u7D22\u5931\u8D25\u53EF\u66F4\u6362\u7AD9\u70B9\u3002\n\n## \u8BF7\u4F4E\u8C03\u4F7F\u7528\uFF0C\u8BF7\u52FF\u914D\u7F6E\u4E8E QQ \u6216\u5176\u4ED6\u56FD\u5185 APP \u5E73\u53F0\uFF0C\u5E26\u6765\u7684\u540E\u679C\u8BF7\u81EA\u884C\u627F\u62C5\u3002\n\n---\n\n<details>\n<summary><strong><span style=\"font-size: 1.3em; color: #2a2a2a;\">\u4F7F\u7528\u65B9\u6CD5</span></strong></summary>\n\n### \u5173\u952E\u8BCD\u641C\u7D22\u78C1\u529B\u94FE\u63A5\n#### \u793A\u4F8B\uFF1A\n<pre style=\"background-color: #f4f4f4; padding: 10px; border-radius: 4px; border: 1px solid #ddd;\">magnet sone111 // \u641C\u7D22\u5173\u952E\u8BCDsone111\u7684\u8D44\u6E90</pre>\n\n### \u652F\u6301\u914D\u7F6E\uFF1A\n- **\u641C\u7D22\u7AD9\u70B9**\uFF1A\u5982\u641C\u7D22\u5931\u8D25\u53EF\u5728\u914D\u7F6E\u4E2D\u5207\u6362\u4F7F\u7528\u7684\u8D44\u6E90\u7AD9\u3002\n- **\u8FD4\u56DE\u6570\u91CF**\uFF1A\u53EF\u8BBE\u7F6E\u6BCF\u6B21\u6700\u591A\u8FD4\u56DE\u51E0\u6761\u641C\u7D22\u7ED3\u679C\uFF08\u9ED8\u8BA4 3 \u6761\uFF0C\u6700\u591A 10 \u6761\uFF09\u3002\n- **\u662F\u5426\u663E\u793A\u5F71\u7247\u4FE1\u606F**\uFF1A\u5982\u53D1\u5E03\u65E5\u671F\u3001\u5F71\u7247\u4FE1\u606F\u3001\u6F14\u5458\u7B49\uFF0C\u542F\u7528\u540E\u4F1A\u4E00\u5E76\u663E\u793A\u3002\n - \u5F71\u7247\u4FE1\u606F\u4E0D\u5168\u9762\uFF0C\u53EF\u4EE5\u548C\u6211\u7684\u53E6\u4E00\u4E2A\u63D2\u4EF6[javbus-lizard](https://github.com/lizard0126/javbus-lizard)\u7ED3\u5408\u4F7F\u7528\u3002\n\n### \u5173\u952E\u8BCD\uFF1A\n- \u65E0\u9700\u4E25\u683C\u8F93\u5165\u756A\u53F7\uFF0C\u652F\u6301\u6A21\u7CCA\u641C\u7D22\u3002\n- \u652F\u6301\u4E2D\u6587\u641C\u7D22\uFF0C\u5982\u201C\u67D0\u67D0\u63A2\u82B1\u201D\u7B49\u3002\n\n</details>\n\n<details>\n<summary><strong><span style=\"font-size: 1.3em; color: #2a2a2a;\">\u53CD\u9988\u5EFA\u8BAE\u6216\u62A5\u544A\u95EE\u9898</span></strong></summary>\n\n<strong>\u53EF\u4EE5[\u70B9\u8FD9\u91CC](https://github.com/lizard0126/magnet-get-lizard/issues)\u521B\u5EFA\u8BAE\u9898~</strong>\n\n</details>\n\n<details>\n<summary><strong><span style=\"font-size: 1.3em; color: #2a2a2a;\">\u5982\u679C\u559C\u6B22\u6211\u7684\u63D2\u4EF6</span></strong></summary>\n\n<strong>\u53EF\u4EE5[\u8BF7\u6211\u559D\u53EF\u4E50](https://ifdian.net/a/lizard0126)\uFF0C\u6CA1\u51C6\u5C31\u6709\u52A8\u529B\u66F4\u65B0\u65B0\u529F\u80FD\u4E86~</strong>\n\n</details>\n";
5
+ export interface Config {
6
+ site: string;
7
+ maxResults?: number;
8
+ ifMessage: boolean;
9
+ }
10
+ export declare const Config: Schema<Config>;
11
+ export declare function apply(ctx: Context, config: any): void;
package/lib/index.js ADDED
@@ -0,0 +1,147 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name2 in all)
8
+ __defProp(target, name2, { get: all[name2], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Config: () => Config,
24
+ apply: () => apply,
25
+ inject: () => inject,
26
+ name: () => name,
27
+ usage: () => usage
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+ var import_koishi = require("koishi");
31
+ var name = "magnet-get-lizard";
32
+ var inject = ["puppeteer"];
33
+ var usage = `
34
+ # ⚠️ NSFW警告!!!
35
+ ## 通过关键词搜索磁力链接资源。
36
+
37
+ ## 配置多个资源站点,若搜索失败可更换站点。
38
+
39
+ ## 请低调使用,请勿配置于 QQ 或其他国内 APP 平台,带来的后果请自行承担。
40
+
41
+ ---
42
+
43
+ <details>
44
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">使用方法</span></strong></summary>
45
+
46
+ ### 关键词搜索磁力链接
47
+ #### 示例:
48
+ <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 4px; border: 1px solid #ddd;">magnet sone111 // 搜索关键词sone111的资源</pre>
49
+
50
+ ### 支持配置:
51
+ - **搜索站点**:如搜索失败可在配置中切换使用的资源站。
52
+ - **返回数量**:可设置每次最多返回几条搜索结果(默认 3 条,最多 10 条)。
53
+ - **是否显示影片信息**:如发布日期、影片信息、演员等,启用后会一并显示。
54
+ - 影片信息不全面,可以和我的另一个插件[javbus-lizard](https://github.com/lizard0126/javbus-lizard)结合使用。
55
+
56
+ ### 关键词:
57
+ - 无需严格输入番号,支持模糊搜索。
58
+ - 支持中文搜索,如“某某探花”等。
59
+
60
+ </details>
61
+
62
+ <details>
63
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">反馈建议或报告问题</span></strong></summary>
64
+
65
+ <strong>可以[点这里](https://github.com/lizard0126/magnet-get-lizard/issues)创建议题~</strong>
66
+
67
+ </details>
68
+
69
+ <details>
70
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">如果喜欢我的插件</span></strong></summary>
71
+
72
+ <strong>可以[请我喝可乐](https://ifdian.net/a/lizard0126),没准就有动力更新新功能了~</strong>
73
+
74
+ </details>
75
+ `;
76
+ var sites = [
77
+ "https://18mag.net",
78
+ "https://xcili.com",
79
+ "https://1cili.com",
80
+ "https://cili.info",
81
+ "https://cili.uk",
82
+ "https://wuji.me"
83
+ ];
84
+ var Config = import_koishi.Schema.object({
85
+ site: import_koishi.Schema.union(sites.map((site) => import_koishi.Schema.const(site))).default("https://18mag.net").description("如果一直搜索失败,可以更换站点再试"),
86
+ maxResults: import_koishi.Schema.number().min(1).max(10).default(3).description("搜索结果展示数量"),
87
+ ifMessage: import_koishi.Schema.boolean().default(false).description("是否展示影片信息(发布日期、影片信息、演员,不一定都有)")
88
+ });
89
+ function apply(ctx, config) {
90
+ ctx.command("搜片 <keyword>", "关键词搜索磁链资源").action(async ({ session }, keyword) => {
91
+ if (!keyword) return "未输入关键词!";
92
+ try {
93
+ const searchUrl = `${config.site}/search?q=${encodeURIComponent(keyword)}`;
94
+ const page = await ctx.puppeteer.page();
95
+ await page.goto(searchUrl, { waitUntil: "domcontentloaded" });
96
+ let links = await page.$$eval(".file-list tr a", (elements, max, site) => {
97
+ return elements.map((el) => el.getAttribute("href")).filter((href) => href).map((href) => site + href).slice(0, max);
98
+ }, config.maxResults, config.site);
99
+ if (links.length === 0) {
100
+ await page.close();
101
+ return "没有找到相关信息,请更换关键词重试";
102
+ }
103
+ let result = "";
104
+ for (const link of links) {
105
+ await page.goto(link, { waitUntil: "domcontentloaded" });
106
+ const detail = await page.evaluate((ifMessage) => {
107
+ const title = document.querySelector(".magnet-title")?.textContent?.trim();
108
+ const dtElements = Array.from(document.querySelectorAll(".torrent-info dt"));
109
+ const info = dtElements.map((dt) => {
110
+ let key = dt.textContent?.trim().replace(/[::\s]/g, "");
111
+ let dd = dt.nextElementSibling?.textContent?.trim();
112
+ if (key === "种子特征码") {
113
+ key = "磁链";
114
+ dd = `magnet:?xt=urn:btih:${dd}`;
115
+ }
116
+ if (!ifMessage) {
117
+ if (key === "发布日期") return "";
118
+ else if (key === "影片信息") return "";
119
+ else if (key === "演员") return "";
120
+ }
121
+ if (key === "推荐网盘") return "";
122
+ return key && dd ? `${key} :${dd}` : "";
123
+ }).filter(Boolean).join("\n");
124
+ return { title, info };
125
+ }, config.ifMessage);
126
+ result += `标题:${detail.title}
127
+ ${detail.info}
128
+
129
+ `;
130
+ }
131
+ await page.close();
132
+ return result;
133
+ } catch (err) {
134
+ console.error(err);
135
+ return "获取失败,请稍后重试。";
136
+ }
137
+ });
138
+ }
139
+ __name(apply, "apply");
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ Config,
143
+ apply,
144
+ inject,
145
+ name,
146
+ usage
147
+ });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "koishi-plugin-magnet-get-lizard",
3
+ "description": "获取磁链资源,比我的另一个插件[javbus-lizard](https://github.com/lizard0126/javbus-lizard)收集的快。支持搜索国产资源",
4
+ "version": "0.0.1",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lizard0126/magnet-get-lizard.git"
8
+ },
9
+ "main": "lib/index.js",
10
+ "typings": "lib/index.d.ts",
11
+ "files": [
12
+ "lib",
13
+ "dist"
14
+ ],
15
+ "license": "MIT",
16
+ "keywords": [
17
+ "chatbot",
18
+ "koishi",
19
+ "plugin"
20
+ ],
21
+ "peerDependencies": {
22
+ "koishi": "4.18.8",
23
+ "koishi-plugin-puppeteer": "^3.9.0"
24
+ }
25
+ }
package/readme.md ADDED
@@ -0,0 +1,45 @@
1
+ # koishi-plugin-magnet-get-lizard
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-magnet-get-lizard?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-magnet-get-lizard)
4
+
5
+ # ⚠️ NSFW警告!!!
6
+ ## 通过关键词搜索磁力链接资源。
7
+
8
+ ## 配置多个资源站点,若搜索失败可更换站点。
9
+
10
+ ## 请低调使用,请勿配置于 QQ 或其他国内 APP 平台,带来的后果请自行承担。
11
+
12
+ ---
13
+
14
+ <details>
15
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">使用方法</span></strong></summary>
16
+
17
+ ### 关键词搜索磁力链接
18
+ #### 示例:
19
+ <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 4px; border: 1px solid #ddd;">magnet sone111 // 搜索关键词sone111的资源</pre>
20
+
21
+ ### 支持配置:
22
+ - **搜索站点**:如搜索失败可在配置中切换使用的资源站。
23
+ - **返回数量**:可设置每次最多返回几条搜索结果(默认 3 条,最多 10 条)。
24
+ - **是否显示影片信息**:如发布日期、影片信息、演员等,启用后会一并显示。
25
+ - 影片信息不全面,可以和我的另一个插件[javbus-lizard](https://github.com/lizard0126/javbus-lizard)结合使用。
26
+
27
+ ### 关键词:
28
+ - 无需严格输入番号,支持模糊搜索。
29
+ - 支持中文搜索,如“某某探花”等。
30
+
31
+ </details>
32
+
33
+ <details>
34
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">反馈建议或报告问题</span></strong></summary>
35
+
36
+ <strong>可以[点这里](https://github.com/lizard0126/magnet-get-lizard/issues)创建议题~</strong>
37
+
38
+ </details>
39
+
40
+ <details>
41
+ <summary><strong><span style="font-size: 1.3em; color: #2a2a2a;">如果喜欢我的插件</span></strong></summary>
42
+
43
+ <strong>可以[请我喝可乐](https://ifdian.net/a/lizard0126),没准就有动力更新新功能了~</strong>
44
+
45
+ </details>