From 975dd70a3c39d6973ea8ee105387fb5ec8b92f13 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Mon, 25 Mar 2024 10:25:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20feat:=201.5.13=20=E6=9C=80?= =?UTF-8?q?=E5=8F=B3Plus=E6=9B=B4=E6=96=B0=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现在最右单条帖子信息,现在更加完善 --- apps/tools.js | 70 ++++++++++++++++++++++++++++++++++- config/version.yaml | 2 +- utils/general-link-adapter.js | 8 ---- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 6c91e58..8b145eb 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -50,7 +50,6 @@ import { TIKTOK_INFO, TWITTER_TWEET_INFO, XHS_REQ_LINK, - XHS_VIDEO, GENERAL_REQ_LINK, WEIBO_SINGLE_INFO, WEISHI_VIDEO_INFO } from "../constants/tools.js"; import child_process from 'node:child_process' @@ -128,7 +127,7 @@ export class tools extends plugin { fnc: "bodianMusic", }, { - reg: "(kuaishou.com|ixigua.com|share.xiaochuankeji.cn|h5.pipix.com|h5.pipigx.com|tieba.baidu.com|s.xsj.qq.com)", + reg: "(kuaishou.com|ixigua.com|h5.pipix.com|h5.pipigx.com|tieba.baidu.com|s.xsj.qq.com)", fnc: "general", }, { @@ -154,6 +153,10 @@ export class tools extends plugin { { reg: "(isee.weishi.qq.com)", fnc: "weishi" + }, + { + reg: "share.xiaochuankeji.cn", + fnc: "zuiyou" } ], }); @@ -1300,6 +1303,69 @@ export class tools extends plugin { return true; } + async zuiyou(e) { + // #最右#分享一条有趣的内容给你,不好看算我输。请戳链接>>https://share.xiaochuankeji.cn/hybrid/share/post?pid=365367131&zy_to=applink&share_count=1&m=dc114ccc8e55492642f6a702b510c1f6&d=9e18ca2dace030af656baea96321e0ea353fe5c46097a7f3962b93f995641e962796dd5faa231feea5531ac65547045f&app=zuiyou&recommend=r0&name=n0&title_type=t0 + const url = /(?:https?:\/\/)?(share|share.xiaochuankeji)\.cn\/[A-Za-z\d._?%&+\-=\/#]*/.exec(e.msg)[0]; + try { + const response = await axios.get("https://share.xiaochuankeji.cn/hybrid/share/post?pid=370928872&zy_to=applink&share_count=1&m=dc114ccc8e55492642f6a702b510c1f6&d=9e18ca2dace030af656baea96321e0ea353fe5c46097a7f3962b93f995641e962796dd5faa231feea5531ac65547045f&app=zuiyou&recommend=r0&name=n0&title_type=t0", { + headers: { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36", + } + }); + const html = response.data; + + const videoUrlRegex = /fullscreen="false" src="(.*?)"/; + const videoTitleRegex = /:<\/span>

(.*?)<\/h1><\/div>
(.*?)<\/span>/; + + const videoUrlMatch = html.match(videoUrlRegex); + const videoTitleMatch = html.match(videoTitleRegex); + const videoCoverMatch = html.match(videoCoverRegex); + const videoAuthorMatch = html.match(videoAuthorRegex); + + const imgSrcRegex = /]*src="([^"]*)"[^>]*\/>/gi; + let match; + const imgSrcs = []; + + while ((match = imgSrcRegex.exec(html)) !== null) { + imgSrcs.push(match[1]); // Adds the content of the src attribute to the array + } + + const images = imgSrcs.filter(item => item.startsWith("http://bd-tbfile.izuiyou.com/img/view/id")) + + // Construct the response object + const shortVideoInfo = { + authorName: videoAuthorMatch ? videoAuthorMatch[1] : '', + title: videoTitleMatch ? videoTitleMatch[1] : '', + cover: videoCoverMatch ? videoCoverMatch[1] : '', + noWatermarkDownloadUrl: videoUrlMatch ? videoUrlMatch[1] : '', + images, + }; + + e.reply([segment.image(shortVideoInfo.cover), `识别:最右,${shortVideoInfo.authorName}\n${shortVideoInfo.title}`]) + + if (shortVideoInfo.images.length > 0) { + const replyImages = shortVideoInfo.images.map(item => { + return { + message: segment.image(item), + nickname: this.e.sender.card || this.e.user_id, + user_id: this.e.user_id, + } + }); + e.reply(Bot.makeForwardMsg(replyImages)); + } + if (shortVideoInfo.noWatermarkDownloadUrl) { + this.downloadVideo(shortVideoInfo.noWatermarkDownloadUrl).then(path => { + e.reply(segment.video(path + "/temp.mp4")); + }); + } + } catch (error) { + console.error(error); + throw error; // Rethrow the error so it can be handled by the caller + } + } + /** * 哔哩哔哩下载 * @param title diff --git a/config/version.yaml b/config/version.yaml index b7e5b44..96a4d40 100644 --- a/config/version.yaml +++ b/config/version.yaml @@ -1,5 +1,5 @@ - { - version: 1.5.12, + version: 1.5.13, data: [ 新增微视解析功能, diff --git a/utils/general-link-adapter.js b/utils/general-link-adapter.js index 406ff5d..91102cd 100644 --- a/utils/general-link-adapter.js +++ b/utils/general-link-adapter.js @@ -63,13 +63,6 @@ class GeneralLinkAdapter { }; } - async zuiyou(link) { - // #最右#分享一条有趣的内容给你,不好看算我输。请戳链接>>https://share.xiaochuankeji.cn/hybrid/share/post?pid=365367131&zy_to=applink&share_count=1&m=dc114ccc8e55492642f6a702b510c1f6&d=9e18ca2dace030af656baea96321e0ea353fe5c46097a7f3962b93f995641e962796dd5faa231feea5531ac65547045f&app=zuiyou&recommend=r0&name=n0&title_type=t0 - const msg = /(?:https?:\/\/)?(share|share.xiaochuankeji)\.cn\/[A-Za-z\d._?%&+\-=\/#]*/.exec(link)[0]; - const reqLink = this.createReqLink(GENERAL_REQ_LINK, msg); - return { name: "最右", reqLink }; - } - async xigua(link) { // 1. https://v.ixigua.com/ienrQ5bR/ // 2. https://www.ixigua.com/7270448082586698281 @@ -120,7 +113,6 @@ class GeneralLinkAdapter { async init(link) { logger.mark("[R插件][通用解析]", link) const handlers = new Map([ - [/share.xiaochuankeji.cn/, this.zuiyou.bind(this)], [/kuaishou.com/, this.ks.bind(this)], [/ixigua.com/, this.xigua.bind(this)], [/h5.pipix.com/, this.pipixia.bind(this)],