From e2dd18afcd84bc081b03340fcde58847bde37b49 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Tue, 14 Mar 2023 01:21:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=BC=BA=E5=8C=96=E6=90=9C?= =?UTF-8?q?=E4=B9=A6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 增加更多的信息 2. 增加直连下载 --- apps/query.js | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/apps/query.js b/apps/query.js index 9296302..eb93ac3 100644 --- a/apps/query.js +++ b/apps/query.js @@ -421,12 +421,13 @@ export class query extends plugin { nickname: this.e.sender.card || this.e.user_id, user_id: this.e.user_id, }; + // 主要数据来源 axios .post("https://api.ylibrary.org/api/search/", { headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14", - referer: "https://search.zhelper.net/", + "referer": "https://search.zhelper.net/" }, keyword: keyword, page: 1, @@ -447,6 +448,7 @@ export class query extends plugin { id, source, } = item; + // 数据组合 bookMsg.push({ message: { type: "text", @@ -455,7 +457,10 @@ export class query extends plugin { `作者:${author}\n` + `书籍类型:${extension}\n` + `出版年月:${year}\n` + - `来源:${source}`, + `来源:${source}\n` + + `ISBN:${isbn||"暂无"}\n` + + `出版社:${publisher}\n` + + `文件大小:${(Number(filesize)/1024/1024).toFixed(2)}MB` }, ...sendTemplate, }); @@ -482,6 +487,31 @@ export class query extends plugin { await this.getBookDetail(e, id, source); } + /** + * 获取直接下载的来源 + * @param keyword 书名 + * @returns {Promise} + */ + async getDirectDownload(keyword) { + // 下载字典(异步去执行) + return axios + .post("https://worker.zlib.app/api/search/", { + headers: { + "user-agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14", + "referer": "https://search.zhelper.net/" + }, + keyword: keyword, + page: 1, + sensitive: false, + }).then(resp => { + // 标题去重 + return resp.data.data.filter(item => { + return item.title === keyword + }).map(item => `https://worker.zlib.app/download/${item.id}`) + }) + } + /** * @link searchBook 的上下文 * @returns {Promise} @@ -557,6 +587,17 @@ export class query extends plugin { } }) await this.reply(await Bot.makeForwardMsg(bookMethods)) + // 异步获取直连 + this.getDirectDownload(title).then(async res => { + const directDownloadUrls = res.map(item => { + return { + message: {type: "text", text: item}, + nickname: this.e.sender.card || this.e.user_id, + user_id: this.e.user_id, + } + }) + await this.reply(await Bot.makeForwardMsg(directDownloadUrls??"无直连下载")) + }) }); }