From 37dde4820c448cbb202918b84aa4418dba209adc Mon Sep 17 00:00:00 2001 From: test Date: Fri, 12 Dec 2025 19:46:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 51 ++++++++++++++++++++++++------------------- config.js | 3 ++- utils/androidURL.js | 6 ++--- utils/colorOut.js | 8 ++++++- utils/fetchList.js | 1 - utils/refreshToken.js | 2 ++ 6 files changed, 42 insertions(+), 29 deletions(-) diff --git a/app.js b/app.js index d07f6ba..0912539 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ import { readFileSync } from "./utils/fileUtil.js"; import { host, port, rateType, token, userId } from "./config.js"; import { getDateTimeStr } from "./utils/time.js"; import update from "./updateData.js"; -import { printBlue, printGreen, printGrey, printMagenta, printRed, printYellow } from "./utils/colorOut.js"; +import { printBlue, printDebug, printGreen, printGrey, printMagenta, printRed, printYellow } from "./utils/colorOut.js"; import { delay } from "./utils/fetchList.js"; // 运行时长 @@ -16,7 +16,6 @@ let loading = false const server = http.createServer(async (req, res) => { - // console.dir(req, { depth: null }) while (loading) { await delay(50) } @@ -134,16 +133,22 @@ const server = http.createServer(async (req, res) => { const valTime = urlCache[pid].valTime - Date.now() // 缓存是否有效 if (valTime >= 0) { - - printGreen(`缓存有效,使用缓存数据`) - let playURL = urlCache[pid].url + let msg = "节目调整,暂不提供服务" + if (urlCache[pid].content != null) { + if (urlCache[pid].content.body.auth.logined) { + printGreen("登录认证成功") + if (urlCache[pid].content.body.auth.authResult == "FAIL") { + printRed(`认证失败 视频内容不完整 可能缺少相关VIP: ${urlCache[pid].content.body.auth.resultDesc}`) + } + } else { + printYellow("未登录") + } + msg = urlCache[pid].content.message + } + printGreen(`缓存有效,使用缓存数据`) // 节目调整 if (playURL == "") { - let msg = "节目调整,暂不提供服务" - if (urlCache[pid].content != null) { - msg = urlCache[pid].content.message - } printRed(`${pid} ${msg}`) res.writeHead(200, { "Content-Type": "application/json;charset=UTF-8" }) @@ -187,9 +192,8 @@ const server = http.createServer(async (req, res) => { loading = false return } + printDebug(`添加加密字段后链接 ${resObj.url}`) - // 直接访问g开头的域名链接时概率会302到不能播放的地址,目前不清楚原因,在这重定向正确地址 - // printRed(resObj.url) let changeFailed = false if (resObj.url != "") { let z = 1 @@ -204,12 +208,11 @@ const server = http.createServer(async (req, res) => { const location = obj.headers.get("Location") - if (location == "" || location == undefined || location == null) { - continue - } - if (location.startsWith("http://hlsz") || location.startsWith("http://mgsp") || location.startsWith("http://trial")) { - resObj.url = location - break + if (location != "" && location != undefined && location != null) { + if (location.startsWith("http://hlsz") || location.startsWith("http://mgsp") || location.startsWith("http://trial")) { + resObj.url = location + break + } } if (z == 6) { printYellow(`获取失败,返回原链接`) @@ -220,7 +223,14 @@ const server = http.createServer(async (req, res) => { z++ } } - + if (resObj.content.body.auth.logined) { + printGreen("登录认证成功") + if (resObj.content.body.auth.authResult == "FAIL") { + printRed(`认证失败 视频内容不完整 可能缺少相关VIP: ${resObj.content.body.auth.resultDesc}`) + } + } else { + printYellow("未登录") + } // printRed(resObj.url) printGreen(`添加节目缓存 ${pid}`) // 缓存有效时长 @@ -240,7 +250,6 @@ const server = http.createServer(async (req, res) => { url: resObj.url, content: resObj.content, } - // console.log(resObj.url) if (resObj.url == "") { let msg = "节目调整,暂不提供服务" @@ -256,8 +265,6 @@ const server = http.createServer(async (req, res) => { } let playURL = resObj.url - // console.dir(playURL, { depth: null }) - // 添加回放参数 if (params != "") { const resultParams = new URLSearchParams(params); @@ -289,7 +296,6 @@ server.listen(port, async () => { } catch (error) { printRed(error) printRed("更新失败") - console.log(error) } printBlue(`当前已运行${hours}小时`) @@ -301,7 +307,6 @@ server.listen(port, async () => { } catch (error) { printRed(error) printRed("更新失败") - console.log(error) } printGreen("每3小时更新一次") diff --git a/config.js b/config.js index 146f01a..de7f9fc 100644 --- a/config.js +++ b/config.js @@ -13,5 +13,6 @@ const host = process.env.mhost || "" const rateType = process.env.mrateType || 3 // 是否刷新token,可能是导致封号的原因 // const refreshToken = process.env.mrefreshToken || true +const debug = process.env.mdebug || false -export { userId, token, port, host, rateType/* , refreshToken */ } +export { userId, token, port, host, rateType, debug/* , refreshToken */ } diff --git a/utils/androidURL.js b/utils/androidURL.js index c549f16..4b76304 100644 --- a/utils/androidURL.js +++ b/utils/androidURL.js @@ -1,6 +1,6 @@ import { getStringMD5 } from "./EncryUtils.js"; import { getddCalcuURL, getddCalcuURL720p } from "./ddCalcuURL.js"; -import { printYellow } from "./colorOut.js"; +import { printDebug, printYellow } from "./colorOut.js"; /** * @typedef {object} SaltSign @@ -80,7 +80,7 @@ async function getAndroidURL(userId, token, pid, rateType) { }).then(r => r.json()) } - // console.dir(respData, { depth: null }) + printDebug(respData) // console.log(respData) const url = respData.body.urlInfo?.url // console.log(rateType) @@ -98,7 +98,6 @@ async function getAndroidURL(userId, token, pid, rateType) { rateType = respData.body.urlInfo?.rateType // console.log("清晰度" + rateType) - return { url: resURL, rateType: parseInt(rateType), @@ -144,6 +143,7 @@ async function getAndroidURL720p(pid) { headers: headers }).then(r => r.json()) + printDebug(respData) // console.dir(respData, { depth: null }) const url = respData.body.urlInfo?.url // console.log(rateType) diff --git a/utils/colorOut.js b/utils/colorOut.js index 3073081..a7f876a 100644 --- a/utils/colorOut.js +++ b/utils/colorOut.js @@ -1,3 +1,4 @@ +import { debug } from "../config.js" import { getLogDateTime } from "./time.js" function basePrint(color, msg) { @@ -27,7 +28,12 @@ function printMagenta(msg) { function printGrey(msg) { basePrint("\x1B[2m", msg) } +function printDebug(obj) { + if (debug) { + console.dir(obj, { depth: null }) + } +} export { - printGreen, printBlue, printRed, printYellow, printMagenta, printGrey + printGreen, printBlue, printRed, printYellow, printMagenta, printGrey, printDebug } diff --git a/utils/fetchList.js b/utils/fetchList.js index bb1295b..5cc98cd 100644 --- a/utils/fetchList.js +++ b/utils/fetchList.js @@ -1,5 +1,4 @@ -// 睡眠 function delay(ms) { return new Promise(resolve => { setTimeout(resolve, ms) diff --git a/utils/refreshToken.js b/utils/refreshToken.js index a7357e0..3d23a73 100644 --- a/utils/refreshToken.js +++ b/utils/refreshToken.js @@ -1,3 +1,4 @@ +import { printDebug } from "./colorOut.js"; import { AESencrypt, getStringMD5, RSAencrypt } from "./EncryUtils.js" /** @@ -57,6 +58,7 @@ async function refreshToken(userId, token) { // console.log(respResult) return true } + console.dir(respResult, { depth: null }) return false }