diff --git a/README.md b/README.md index 8ca93ef..0d878b1 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,8 @@ chmod a+rx ~/.local/bin/yt-dlp ### ✖️ 小蓝鸟问题 **2024-2-5**,修复小蓝鸟的时候看到free计划已经[没有给查看Tweet的api](https://developer.twitter.com/en/portal/products/basic),原先[使用的库也出现了403报错](https://github.com/PLhery/node-twitter-api-v2),开通会员要100美元,不值得。目前暂停更新,后续有方案和精力再更新! +> 2024/2/26 目前的替代方案:使用第三方解析,但是无法解析组图,只能解析单个图片,望周知! + ## 🤺 R插件交流群 扫码不行就:575663150 diff --git a/apps/tools.js b/apps/tools.js index d705127..3bda245 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -92,8 +92,8 @@ export class tools extends plugin { fnc: "wiki", }, { - reg: "(twitter.com)", - fnc: "twitter", + reg: "(x.com)", + fnc: "twitter_x", }, { reg: "(acfun.cn)", @@ -610,6 +610,42 @@ export class tools extends plugin { return true; } + // 使用现有api解析小蓝鸟 + async twitter_x(e) { + // 配置参数及解析 + const reg = /https?:\/\/x.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/; + const twitterUrl = reg.exec(e.msg)[0]; + // 提取视频 + const videoUrl = XIGUA_REQ_LINK.replace("{}", twitterUrl); + e.reply("识别:小蓝鸟"); + axios.get(videoUrl, { + headers: { + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', + 'Accept-Language': 'zh-CN,zh;q=0.9', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive', + 'Pragma': 'no-cache', + 'Sec-Fetch-Dest': 'document', + 'Sec-Fetch-Mode': 'navigate', + 'Sec-Fetch-Site': 'none', + 'Sec-Fetch-User': '?1', + 'Upgrade-Insecure-Requests': '1', + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36', + + }, + timeout: 10000 // 设置超时时间 + }).then(resp => { + const url = resp.data.data?.url; + if (url && (url.endsWith(".jpg") || url.endsWith(".png"))) { + e.reply(segment.image(url)); + } else { + this.downloadVideo(url).then(path => { + e.reply(segment.video(path + "/temp.mp4")); + }); + } + }); + } + // acfun解析 async acfun(e) { const path = `${ this.getCurDownloadPath(e) }/temp/`; @@ -1096,6 +1132,7 @@ export class tools extends plugin { return true } + // 米游社 async miyoushe(e) { let msg = /(?:https?:\/\/)?(m|www)\.miyoushe\.com\/[A-Za-z\d._?%&+\-=\/#]*/.exec(e.msg)[0]; const id = /\/(\d+)$/.exec(msg)?.[0].replace("\/", ""); diff --git a/config/version.yaml b/config/version.yaml index cc8371a..7a45b71 100644 --- a/config/version.yaml +++ b/config/version.yaml @@ -1,5 +1,5 @@ - { - version: 1.4.2, + version: 1.4.3, data: [ 新增米游社解析功能, diff --git a/utils/acfun.js b/utils/acfun.js index 14544f9..1d520b9 100644 --- a/utils/acfun.js +++ b/utils/acfun.js @@ -13,13 +13,13 @@ function escapeSpecialChars(str) { } const parseVideoName = videoInfo => { - const strAc号 = "ac" + (videoInfo?.dougaId || ""); - const str标题 = videoInfo?.title; - const str作者 = videoInfo?.user.name; - const str上传时间 = videoInfo?.createTime; - const str描述 = videoInfo?.description; + const acfunId = "ac" + (videoInfo?.dougaId || ""); + const acfunTitle = videoInfo?.title; + const acfunAuthor = videoInfo?.user.name; + const uploadTime = videoInfo?.createTime; + const description = videoInfo?.description; - const raw = [strAc号, str标题, str作者, str上传时间, str描述] + const raw = [acfunId, acfunTitle, acfunAuthor, uploadTime, description] .map(d => d || "") .join("_") .slice(0, 100);