mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-13 23:59:19 +00:00
🐞 fix: 修复dy解析1
This commit is contained in:
parent
d98cd52e87
commit
2acdb0e631
@ -14,7 +14,7 @@ import { transMap, douyinTypeMap, XHS_CK, TEN_THOUSAND } from "../utils/constant
|
||||
import { getIdVideo, generateRandomStr } from "../utils/common.js";
|
||||
import config from "../model/index.js";
|
||||
import Translate from "../utils/trans-strategy.js";
|
||||
import { getXB } from "../utils/x-bogus.js";
|
||||
import * as xBogus from "../utils/x-bogus.cjs";
|
||||
import { getVideoInfo } from "../utils/biliInfo.js";
|
||||
import { getBiliGptInputText } from "../utils/biliSummary.js";
|
||||
import { getBodianAudio, getBodianMv, getBodianMusicInfo } from "../utils/bodian.js";
|
||||
@ -155,20 +155,16 @@ export class tools extends plugin {
|
||||
// const url = `https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=${ douId }&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`;
|
||||
// 感谢 Evil0ctal(https://github.com/Evil0ctal)提供的header 和 B1gM8c(https://github.com/B1gM8c)的逆向算法X-Bogus
|
||||
const headers = {
|
||||
"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;",
|
||||
'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;"
|
||||
};
|
||||
const dyApi = "https://www.douyin.com/aweme/v1/web/aweme/detail/?";
|
||||
const params = `msToken=${generateRandomStr(
|
||||
107,
|
||||
)}&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`;
|
||||
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`
|
||||
// xg参数
|
||||
const xbParam = getXB(params.replaceAll("&", "%26"));
|
||||
const xbParam = xBogus.sign(new URLSearchParams(new URL(dyApi).search).toString(), headers["User-Agent"]);
|
||||
// const param = resp.data.result[0].paramsencode;
|
||||
const resDyApi = `${dyApi}${params}&X-Bogus=${xbParam}`;
|
||||
const resDyApi = `${dyApi}&X-Bogus=${xbParam}`;
|
||||
axios
|
||||
.get(resDyApi, {
|
||||
headers,
|
||||
@ -183,16 +179,23 @@ export class tools extends plugin {
|
||||
const urlTypeCode = item.aweme_type;
|
||||
const urlType = douyinTypeMap[urlTypeCode];
|
||||
if (urlType === "video") {
|
||||
const url_2 = item.video.play_addr.url_list[2];
|
||||
this.downloadVideo(url_2, false, headers).then(_ => {
|
||||
e.reply(
|
||||
segment.video(
|
||||
`${this.defaultPath}${
|
||||
this.e.group_id || this.e.user_id
|
||||
}/temp.mp4`,
|
||||
),
|
||||
);
|
||||
});
|
||||
const resUrl = item.video.play_addr_h264.url_list[0]
|
||||
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`
|
||||
axios({
|
||||
resUrl,
|
||||
method: "GET",
|
||||
responseType: "stream",
|
||||
proxy: false
|
||||
})
|
||||
.then((response) => {
|
||||
const writer = fs.createWriteStream(path);
|
||||
response.data.pipe(writer);
|
||||
})
|
||||
.then(res => {
|
||||
e.reply(segment.video(
|
||||
path
|
||||
))
|
||||
})
|
||||
} else if (urlType === "image") {
|
||||
// 无水印图片列表
|
||||
let no_watermark_image_list = [];
|
||||
|
564
utils/x-bogus.cjs
Normal file
564
utils/x-bogus.cjs
Normal file
File diff suppressed because one or more lines are too long
132
utils/x-bogus.js
132
utils/x-bogus.js
@ -1,132 +0,0 @@
|
||||
import MD5 from 'md5'
|
||||
|
||||
let Array = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 10, 11, 12, 13, 14, 15];
|
||||
|
||||
// let _0x4129ad = 'Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe';
|
||||
// let _0x127ecb = '=';
|
||||
let _0x377d66 = "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=";
|
||||
|
||||
function _0x39ced2(l) {
|
||||
let n = [];
|
||||
for (let u = 0; u < l.length;) {
|
||||
n.push(Array[l.charCodeAt(u++)] << 4 | Array[l.charCodeAt(u++)]);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function _0x1da120(l) {
|
||||
return _0x39ced2(MD5(_0x39ced2(MD5(l))));
|
||||
}
|
||||
|
||||
function _0x2efd11(l) {
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(l);
|
||||
}
|
||||
|
||||
function _0x2d9dba(l) {
|
||||
var n, u, e, t, r, o = "";
|
||||
for (n = 0; n < l.length - 3; n += 4) {
|
||||
u = _0x2efd11(l.charAt(n)), e = _0x2efd11(l.charAt(n + 1)), t = _0x2efd11(l.charAt(n + 2)),
|
||||
r = _0x2efd11(l.charAt(n + 3)), o += String.fromCharCode(u << 2 | e >>> 4), "=" !== l.charAt(n + 2) && (o += String.fromCharCode(e << 4 & 240 | t >>> 2 & 15)),
|
||||
"=" !== l.charAt(n + 3) && (o += String.fromCharCode(t << 6 & 192 | r));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
function _0x24e7c9() {
|
||||
var l = "";
|
||||
try {
|
||||
window.sessionStorage && (l = window.sessionStorage.getItem("_byted_param_sw")),
|
||||
l && !window.localStorage || (l = window.localStorage.getItem("_byted_param_sw"));
|
||||
} catch (l) { }
|
||||
if (l) {
|
||||
try {
|
||||
var n = _0x3459bb(_0x2d9dba(l.slice(8)), l.slice(0, 8));
|
||||
if ("on" === n) {
|
||||
return !0;
|
||||
}
|
||||
if ("off" === n) {
|
||||
return !1;
|
||||
}
|
||||
} catch (l) { }
|
||||
}
|
||||
return !1;
|
||||
}
|
||||
|
||||
function _0x4d54ed(l) {
|
||||
try {
|
||||
return window.localStorage ? window.localStorage.getItem(l) : null;
|
||||
} catch (l) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function _0x478bb3(l, n, u) {
|
||||
let e = (255 & l) << 16;
|
||||
let t = (255 & n) << 8;
|
||||
let r = e | t | u;
|
||||
return _0x377d66[(16515072 & r) >> 18] + _0x377d66[(258048 & r) >> 12] + _0x377d66[(4032 & r) >> 6] + _0x377d66[63 & r];
|
||||
}
|
||||
|
||||
function _0x481826(l) {
|
||||
void 0 !== l && "" != l && (_0x402a35.ttwid = l);
|
||||
}
|
||||
|
||||
function _0x37f15d() {
|
||||
var l = _0x4d54ed("xmst");
|
||||
return l || "";
|
||||
}
|
||||
|
||||
function _0x330d11(l, n, u, e, t, r, o, d, a, c, i, f, x, _, h, g, C, s, p) {
|
||||
let w = new Uint8Array(19);
|
||||
w[0] = l, w[1] = i, w[2] = n, w[3] = f, w[4] = u, w[5] = x, w[6] = e, w[7] = _,
|
||||
w[8] = t, w[9] = h, w[10] = r, w[11] = g, w[12] = o, w[13] = C, w[14] = d, w[15] = s,
|
||||
w[16] = a, w[17] = p, w[18] = c;
|
||||
return String.fromCharCode.apply(null, w);
|
||||
}
|
||||
|
||||
function _0x330d112(l, n) {
|
||||
let u, e = [], t = 0, r = "", o = 0, d = 0, a = 0;
|
||||
for (let l = 0; l < 256; l++) {
|
||||
e[l] = l;
|
||||
}
|
||||
for (; o < 256; o++) {
|
||||
t = (t + e[o] + l.charCodeAt(o % l.length)) % 256, u = e[o], e[o] = e[t], e[t] = u;
|
||||
}
|
||||
t = 0;
|
||||
for (; d < n.length; d++) {
|
||||
t = (t + e[a = (a + 1) % 256]) % 256, u = e[a], e[a] = e[t], e[t] = u, r += String.fromCharCode(n.charCodeAt(d) ^ e[(e[a] + e[t]) % 256]);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function _0x33baa6(l, n, u) {
|
||||
return String.fromCharCode(l) + String.fromCharCode(n) + u;
|
||||
}
|
||||
|
||||
function getXB(l) {
|
||||
// douyin
|
||||
let n = _0x39ced2(MD5("d4+pTKoNjJFb5tMtAC3XB9XrDDxlig1kjbh32u+x5YcwWb/me2pvLTh6ZdBVN5skEeIaOYNixbnFK6wyJdl/Lcy9CDAcpXLLQc3QFKIDQ3KkQYie3n258eLS1YFUqFLDjn7dqCRp1jjoORamU2SV"));
|
||||
// douyin & tiktok
|
||||
let u = _0x39ced2(MD5(_0x39ced2("d41d8cd98f00b204e9800998ecf8427e")));
|
||||
let e = _0x1da120(l), t = new Date().getTime() / 1e3, r = 536919696, o = [], d = [], a = "";
|
||||
let c = [64, .00390625, 1, 8, e[14], e[15], u[14], u[15], n[14], n[15], t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, t >> 0 & 255, r >> 24 & 255, r >> 16 & 255, r >> 8 & 255, r >> 0 & 255];
|
||||
c.push(c.reduce(function (l, n) {
|
||||
return l ^ n;
|
||||
}));
|
||||
for (let l = 0; l < c.length; l += 2) {
|
||||
o.push(c[l]);
|
||||
d.push(c[l + 1]);
|
||||
}
|
||||
//unescape('%FF')
|
||||
let i = _0x33baa6.apply(null, [2, 255, _0x330d112.apply(null, [String.fromCharCode(255), _0x330d11.apply(null, o.concat(d).slice(0, 19))])]);
|
||||
for (let l = 0; l < i.length;) {
|
||||
a += _0x478bb3(i.charCodeAt(l++), i.charCodeAt(l++), i.charCodeAt(l++));
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
let _0x180b4c = _0x37f15d();
|
||||
|
||||
export {
|
||||
getXB
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user