From df66c85ee6da49e08407f796d351b485c42ef5ca Mon Sep 17 00:00:00 2001 From: zhiyu <542716863@qq.com> Date: Fri, 19 Jan 2024 10:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20[#I85G9L]=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Ddouyin=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修复了当前版本的douyin解析问题 2. 加入了douyin_ck 3. 更新了README 4. 加入了未来计划的功能 --- README.md | 47 ++++++++++++++++++--------------------------- apps/tools.js | 15 ++++++++++++--- config/tools.yaml | 2 ++ config/version.yaml | 2 +- guoba.support.js | 11 +++++++++++ 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 845925f..e278ad5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ utils -- 工具类 1.【必要】下载插件 ```shell git clone https://gitee.com/kyrzy0416/rconsole-plugin.git ./plugins/rconsole-plugin/ -`````` +``` 2.【必要】在`Yunzai-Bot`目录下安装axios(0.27.2)、魔法工具(tunnel)、哔哩哔哩总结(chatgpt-api)依赖 @@ -56,8 +56,9 @@ sudo apt-get install ffmpeg # Windows 参考:https://www.jianshu.com/p/5015a477de3c ```` 4. 【可选】小程序解析适配了: -* 原版的衍变:[Yoimiya / Yunzai-Bot](https://gitee.com/yoimiya-kokomi/Yunzai-Bot) -* 如果你不用原神选择:[听语惊花 / Yunzai-Bot-lite](https://gitee.com/Nwflower/yunzai-bot-lite) +* 喵崽:[Yoimiya / Miao-Yunzai](https://gitee.com/yoimiya-kokomi/Miao-Yunzai) +* TRSS:[时雨◎星空 / Yunzai](https://gitee.com/TimeRainStarSky/Yunzai) +* 听语惊花:[听语惊花 / Yunzai-Bot-lite](https://gitee.com/Nwflower/yunzai-bot-lite) > 如果解析有问题参考issue:[#I6MFF7](https://gitee.com/kyrzy0416/rconsole-plugin/issues/I6MFF7) @@ -71,22 +72,13 @@ sudo apt-get install ffmpeg - 在config/tools.yaml里设置`biliDuration` - 锅巴设置 -7. 【可选】基于文字识别的拓展功能 -> 代码解释: -> 小程序解析 -> 英文翻译和优化: -> 小程序解析 -> 总结: -> 小程序解析 - ## 🐤 Q&A > 哔哩哔哩的SESSDATA? > 进入哔哩哔哩网站 -- 打开F12开发者选项 -- 应用 -- 找到Cookie -- 找到SESSDATA -- 复制 -- 粘贴到plugins/rconsole-plugin/config/tools.yaml or 锅巴 > [图文教程【群友推荐!】](https://www.bilibili.com/read/cv12349604) ## 🤺 R插件交流群 -重新开放TG交流氛围群(群内不解答任何问题,只提供交流环境) -[点击进群](https://t.me/+ZsZMNE8OI7E3MDdl) +马上开放 ## 🧑‍🌾 进阶内容 【可选】相关配置(apps/tools.js): @@ -96,21 +88,28 @@ sudo apt-get install ffmpeg > (非必要不更改)更改魔法在`config/tools.yaml` 或 [锅巴插件](https://gitee.com/guoba-yunzai/guoba-plugin)的配置位置: `proxyAddr: '127.0.0.1' # 魔法地址` `proxyPort: '7890' # 魔法端口` + +## douyin_cookie问题 +由于douyin的解析变化莫测,现版本需要填入自己的cookkie,具体步骤如下: +1. 打开`https://www.douyin.com/` 扫码登入自己的账号 +2. F12进入控制台,或者下载一个[Cookie-Editor](https://www.crxsoso.com/webstore/detail/hlkenndednhfkekhgcdicdfddnkalmdm) +3. 如果是F12,就将以下参数填入到`tools.yaml - douyinCookie`,或者使用锅巴 +> odin_tt=xxx;sessionid_ss=xxx;ttwid=xxx;passport_csrf_token=xxx;msToken=xxx; + +3. 如果是`Cookie-Editor`就直接到插件复制到`tools.yaml - douyinCookie`,或者锅巴 + ## 📦 业务 ![help](./img/help.webp) -## 📦 扩展业务 -[点击体验R插件的补集(自定义回复、GPT Bing二合一回复)](https://gitee.com/kyrzy0416/rconsole-plugin-complementary-set) -![help](https://gitee.com/kyrzy0416/rconsole-plugin-complementary-set/raw/master/img/example.jpg) -![help](https://gitee.com/kyrzy0416/rconsole-plugin-complementary-set/raw/master/img/gpt2.png) - ## 📝 计划功能 - [ ] YouTube解析(这个可能要🕊一久) -- [x] Instagram解析 +- [ ] Instagram解析修复 - [ ] 单张图片解析 - [ ] 视频解析 - [x] 哔哩哔哩总结 -- [ ] 精简工具功能冗余代码 +- [ ] xhs解析去水印 +- [ ] 快手解析 +- [ ] 西瓜视频解析 - [ ] ... @@ -143,14 +142,6 @@ sudo apt-get install ffmpeg | mitsuha | 1杯瑞幸 | | [Kr] 5s¹ | 1杯瑞幸 | -## 👩‍👩‍👧‍👧 开发团队 -| Nickname | Contribution | -| :----------------------------------------------------------: |--------------| -|[易曦翰](https://gitee.com/yixihan) | 后端开发 | -|[zhiyu](https://gitee.com/kyrzy0416) | 后端开发 | -|[Diviner](https://gitee.com/divinerJJ) | 前端开发 | -|[小白白](https://gitee.com/little_White01) | 后端开发 | - ## 🚀 后记 * 文件借鉴了很多插件,精简个人认为可以精简的内容。 * 素材来源于网络,仅供交流学习使用 diff --git a/apps/tools.js b/apps/tools.js index d13a9ba..42e9481 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -93,6 +93,8 @@ export class tools extends plugin { this.biliSessData = this.toolsConfig.biliSessData; // 加载哔哩哔哩的限制时长 this.biliDuration = this.toolsConfig.biliDuration; + // 加载抖音Cookie + this.douyinCookie = this.toolsConfig.douyinCookie; // 加载gpt配置:accessToken、apiKey、模型 this.openaiAccessToken = this.toolsConfig.openaiAccessToken; this.openaiApiKey = this.toolsConfig.openaiApiKey; @@ -151,6 +153,11 @@ export class tools extends plugin { const douUrl = urlRex.exec(e.msg.trim())[0]; await this.douyinRequest(douUrl).then(async res => { + // 当前版本需要填入cookie + if (_.isEmpty(this.douyinCookie)) { + e.reply("检测到没有Cookie,无法解析抖音"); + return; + } const douId = /note\/(\d+)/g.exec(res)?.[1] || /video\/(\d+)/g.exec(res)?.[1]; // 以下是更新了很多次的抖音API历史,且用且珍惜 // const url = `https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=${ douId }`; @@ -160,10 +167,10 @@ export class tools extends plugin { "accept-encoding": "gzip, deflate, br", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36", - referer: "https://www.douyin.com/", - cookie: "s_v_web_id=verify_leytkxgn_kvO5kOmO_SdMs_4t1o_B5ml_BUqtWM1mP6BF;", + Referer: "https://www.douyin.com/", + cookie: this.douyinCookie, }; - const dyApi = `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${douId}&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=1344&screen_height=756&browser_language=zh-CN&browser_platform=Win32&browser_name=Firefox&browser_version=110.0&browser_online=true&engine_name=Gecko&engine_version=109.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=&platform=PC&webid=7158288523463362079&msToken=abL8SeUTPa9-EToD8qfC7toScSADxpg6yLh2dbNcpWHzE0bT04txM_4UwquIcRvkRb9IU8sifwgM1Kwf1Lsld81o9Irt2_yNyUbbQPSUO8EfVlZJ_78FckDFnwVBVUVK`; + const dyApi = `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${douId}&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=1344&screen_height=756&browser_language=zh-CN&browser_platform=Win32&browser_name=Firefox&browser_version=118.0&browser_online=true&engine_name=Gecko&engine_version=109.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=&platform=PC&webid=7284189800734082615&msToken=B1N9FM825TkvFbayDsDvZxM8r5suLrsfQbC93TciS0O9Iii8iJpAPd__FM2rpLUJi5xtMencSXLeNn8xmOS9q7bP0CUsrt9oVTL08YXLPRzZm0dHKLc9PGRlyEk=`; // xg参数 const xbParam = xBogus.sign( new URLSearchParams(new URL(dyApi).search).toString(), @@ -171,6 +178,7 @@ export class tools extends plugin { ); // const param = resp.data.result[0].paramsencode; const resDyApi = `${dyApi}&X-Bogus=${xbParam}`; + headers['Referer'] = `https://www.douyin.com/video/${douId}` axios .get(resDyApi, { headers, @@ -180,6 +188,7 @@ export class tools extends plugin { e.reply("解析失败,请重试!"); return; } + console.log(resp.data) const item = resp.data.aweme_detail; e.reply(`识别:抖音, ${item.desc}`); const urlTypeCode = item.aweme_type; diff --git a/config/tools.yaml b/config/tools.yaml index a6d406d..7f2a926 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -11,3 +11,5 @@ biliDuration: 480 # 哔哩哔哩限制的最大视频时长(默认8分钟) openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session openaiApiKey: '' # sk... openaiModel: 'gpt-3.5-turbo' # 目前gpt-3.5-turbo效果比较好,廉价,适合群友 + +douyinCookie: '' # douyin's cookie, 格式:odin_tt=xxx;sessionid_ss=xxx;ttwid=xxx;passport_csrf_token=xxx;msToken=xxx; \ No newline at end of file diff --git a/config/version.yaml b/config/version.yaml index cdad36d..a5dc360 100644 --- a/config/version.yaml +++ b/config/version.yaml @@ -1,5 +1,5 @@ - { - version: 1.1.0-rc1, + version: 1.1.1, data: [ 新增竹白百科功能, diff --git a/guoba.support.js b/guoba.support.js index 9a104e2..8198d91 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -108,6 +108,17 @@ export function supportGuoba() { placeholder: "请输入OpenAI的AccessToken(ey.....)", }, }, + { + field: "tools.douyinCookie", + label: "抖音的Cookie", + bottomHelpMessage: + "登陆https://www.douyin.com/ - F12 - 自己替换一下odin_tt=xxx;sessionid_ss=xxx;ttwid=xxx;passport_csrf_token=xxx;msToken=xxx;", + component: "Input", + required: false, + componentProps: { + placeholder: "请输入抖音的Cookie", + }, + }, ], getConfigData() { const toolsData = {