From 353b3e5e33a5ce0659faa0bac17689c1a0f47a3a Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Thu, 16 Mar 2023 16:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8Ddy?= =?UTF-8?q?=E9=97=AE=E9=A2=98[#I6NKX2](https://gitee.com/kyrzy0416/rconsol?= =?UTF-8?q?e-plugin/issues/I6NKX2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 7 ++++--- utils/common.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index bf4f13a..e46a09a 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -13,7 +13,7 @@ import { mkdirsSync } from "../utils/file.js"; import { downloadBFile, getDownloadUrl, mergeFileToMp4, getDynamic } from "../utils/bilibili.js"; import { parseUrl, parseM3u8, downloadM3u8Videos, mergeAcFileToMp4 } from "../utils/acfun.js"; import { transMap, douyinTypeMap, TEN_THOUSAND } from "../utils/constant.js"; -import { getIdVideo } from "../utils/common.js"; +import { getIdVideo, generateRandomStr } from "../utils/common.js"; import config from "../model/index.js"; export class tools extends plugin { @@ -145,14 +145,15 @@ export class tools extends plugin { const ttwid = resp.headers.get("set-cookie"); const odin_tt = "a09d8eb0d95b7b9adb4b6fc6591918bfb996096967a7aa4305bd81b5150a8199d2e29ed21883cdd7709c5beaa2be3baa"; + const passport_csrf_token = '2f142a9bb5db1f81f249d6fc997fe4a1' const headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36", referer: "https://www.douyin.com/", - Cookie: `ttwid=${ttwid};${odin_tt}`, + Cookie: `ttwid=${ttwid};odin_tt=${odin_tt};passport_csrf_token=${passport_csrf_token}`, }; const dyApi = "https://www.douyin.com/aweme/v1/web/aweme/detail/?"; - const params = `aweme_id=${douId}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`; + const params = `msToken=${generateRandomStr(107)}&aweme_id=${douId}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`; // xg参数 axios .post(`http://47.115.200.238/xg/path?url=${params.replaceAll("&", "%26")}`, { diff --git a/utils/common.js b/utils/common.js index 80b39e8..4f66ebe 100644 --- a/utils/common.js +++ b/utils/common.js @@ -109,4 +109,13 @@ async function getIdVideo(url) { return idVideo.length > 19 ? idVideo.substring(0, idVideo.indexOf("?")) : idVideo; } -export { jFeatch, autoTask, retry, getIdVideo }; \ No newline at end of file +function generateRandomStr(randomlength = 16){ + const base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789=' + let random_str = '' + for (let i = 0; i < randomlength; i++) { + random_str += base_str.charAt(Math.floor(Math.random() * base_str.length)) + } + return random_str +} + +export { jFeatch, autoTask, retry, getIdVideo, generateRandomStr }; \ No newline at end of file