From 30d7693b14b742c17449a91f95cb1603e3a9e0da Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sun, 4 Aug 2024 16:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20pref:=20=E5=8F=96=E6=B6=88=20ins?= =?UTF-8?q?=20=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +--- apps/tools.js | 80 --------------------------------------------------- 2 files changed, 1 insertion(+), 84 deletions(-) diff --git a/README.md b/README.md index d797f63..34c05b6 100644 --- a/README.md +++ b/README.md @@ -302,14 +302,11 @@ aiApiKey: '' # 用于识图的api key,kimi接口申请:https://platform.moon ## 📝 计划功能 - [x] YouTube解析(这个可能要🕊一久) -- [ ] Instagram解析修复 - - [ ] 单张图片解析 - - [ ] 视频解析 - [x] 哔哩哔哩总结 - [x] xhs解析去水印 - [x] kuai_shou解析 - [x] xi_gua视频解析 -- [ ] ... +- [ ] instagram diff --git a/apps/tools.js b/apps/tools.js index 9adfbdc..e40b4a4 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -136,10 +136,6 @@ export class tools extends plugin { reg: "(xhslink.com|xiaohongshu.com)", fnc: "xhs", }, - { - reg: "(instagram.com)", - fnc: "instagram", - }, { reg: "(h5app.kuwo.cn)", fnc: "bodianMusic", @@ -1009,82 +1005,6 @@ export class tools extends plugin { return true; } - // ins解析 - async instagram(e) { - let suffix = e.msg.match(/(?<=com\/)[\/a-z0-9A-Z].*/)[0]; - if (suffix.startsWith("reel")) { - suffix = suffix.replace("reel/", "p/"); - } - const API = `https://imginn.com/${suffix}`; - // logger.info(API); - let imgPromise = []; - const downloadPath = `${this.getCurDownloadPath(e)}`; - // 判断是否是海外服务器 - const isOversea = await this.isOverseasServer(); - // 简单封装图片下载 - const downloadInsImg = (url, destination) => { - return new Promise((resolve, reject) => { - fetch(url, { - timeout: 10000, - agent: isOversea ? '' : new HttpsProxyAgent(this.myProxy), - redirect: "follow", - follow: 10, - }) - .then(res => { - const dest = fs.createWriteStream(destination); - res.body.pipe(dest); - dest.on("finish", () => resolve(destination)); - }) - .catch(err => reject(err)); - }); - }; - await fetch(API, { - headers: { - "User-Agent": COMMON_USER_AGENT, - }, - }).then(async resp => { - const html = await resp.text(); - const desc = html.match(/(?<=content=").*?(?=\")/g)?.[2]; - const images = html.match(/
/g); - if (!_.isNull(images)) { - e.reply(`识别:Insta,${desc || "暂无描述"}\n`); - images.map((item, index) => { - const imgUrl = /(?<=data-src=").*?(?=")/ - .exec(item)[0] - .replace(/#38/g, "") - .replace(/;/g, ""); - imgPromise.push(downloadInsImg(imgUrl, `${downloadPath}/${index}.jpg`)); - }); - } - // TODO 视频,会出bug暂时不做 - // if (html.includes("data-video")) { - // const video = html.match(/(?<=data-video=").*?(?=")/g)[0].replace(/#38/g, "").replace(/;/g, "") - // this.downloadVideo(video, true).then(path => { - // e.reply(segment.video(path)); - // }) - // } - }); - if (imgPromise.length > 0) { - let path = []; - const images = await Promise.all(imgPromise).then(paths => { - return paths.map(item => { - path.push(item); - return { - message: segment.image(fs.readFileSync(item)), - nickname: e.sender.card || e.user_id, - user_id: e.user_id, - }; - }); - }); - await this.reply(await Bot.makeForwardMsg(images)); - // 清理 - path.forEach(item => { - fs.unlinkSync(item); - }); - } - return true; - } - // 波点音乐解析 async bodianMusic(e) { // 音频例子:https://h5app.kuwo.cn/m/bodian/playMusic.html?uid=3216773&musicId=192015898&opusId=&extendType=together