mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 07:18:22 +08:00
添加是否登录日志
This commit is contained in:
51
app.js
51
app.js
@@ -4,7 +4,7 @@ import { readFileSync } from "./utils/fileUtil.js";
|
|||||||
import { host, port, rateType, token, userId } from "./config.js";
|
import { host, port, rateType, token, userId } from "./config.js";
|
||||||
import { getDateTimeStr } from "./utils/time.js";
|
import { getDateTimeStr } from "./utils/time.js";
|
||||||
import update from "./updateData.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";
|
import { delay } from "./utils/fetchList.js";
|
||||||
|
|
||||||
// 运行时长
|
// 运行时长
|
||||||
@@ -16,7 +16,6 @@ let loading = false
|
|||||||
|
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
|
|
||||||
// console.dir(req, { depth: null })
|
|
||||||
while (loading) {
|
while (loading) {
|
||||||
await delay(50)
|
await delay(50)
|
||||||
}
|
}
|
||||||
@@ -134,16 +133,22 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const valTime = urlCache[pid].valTime - Date.now()
|
const valTime = urlCache[pid].valTime - Date.now()
|
||||||
// 缓存是否有效
|
// 缓存是否有效
|
||||||
if (valTime >= 0) {
|
if (valTime >= 0) {
|
||||||
|
|
||||||
printGreen(`缓存有效,使用缓存数据`)
|
|
||||||
|
|
||||||
let playURL = urlCache[pid].url
|
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 == "") {
|
if (playURL == "") {
|
||||||
let msg = "节目调整,暂不提供服务"
|
|
||||||
if (urlCache[pid].content != null) {
|
|
||||||
msg = urlCache[pid].content.message
|
|
||||||
}
|
|
||||||
printRed(`${pid} ${msg}`)
|
printRed(`${pid} ${msg}`)
|
||||||
|
|
||||||
res.writeHead(200, { "Content-Type": "application/json;charset=UTF-8" })
|
res.writeHead(200, { "Content-Type": "application/json;charset=UTF-8" })
|
||||||
@@ -187,9 +192,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
loading = false
|
loading = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
printDebug(`添加加密字段后链接 ${resObj.url}`)
|
||||||
|
|
||||||
// 直接访问g开头的域名链接时概率会302到不能播放的地址,目前不清楚原因,在这重定向正确地址
|
|
||||||
// printRed(resObj.url)
|
|
||||||
let changeFailed = false
|
let changeFailed = false
|
||||||
if (resObj.url != "") {
|
if (resObj.url != "") {
|
||||||
let z = 1
|
let z = 1
|
||||||
@@ -204,12 +208,11 @@ const server = http.createServer(async (req, res) => {
|
|||||||
|
|
||||||
const location = obj.headers.get("Location")
|
const location = obj.headers.get("Location")
|
||||||
|
|
||||||
if (location == "" || location == undefined || location == null) {
|
if (location != "" && location != undefined && location != null) {
|
||||||
continue
|
if (location.startsWith("http://hlsz") || location.startsWith("http://mgsp") || location.startsWith("http://trial")) {
|
||||||
}
|
resObj.url = location
|
||||||
if (location.startsWith("http://hlsz") || location.startsWith("http://mgsp") || location.startsWith("http://trial")) {
|
break
|
||||||
resObj.url = location
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
if (z == 6) {
|
if (z == 6) {
|
||||||
printYellow(`获取失败,返回原链接`)
|
printYellow(`获取失败,返回原链接`)
|
||||||
@@ -220,7 +223,14 @@ const server = http.createServer(async (req, res) => {
|
|||||||
z++
|
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)
|
// printRed(resObj.url)
|
||||||
printGreen(`添加节目缓存 ${pid}`)
|
printGreen(`添加节目缓存 ${pid}`)
|
||||||
// 缓存有效时长
|
// 缓存有效时长
|
||||||
@@ -240,7 +250,6 @@ const server = http.createServer(async (req, res) => {
|
|||||||
url: resObj.url,
|
url: resObj.url,
|
||||||
content: resObj.content,
|
content: resObj.content,
|
||||||
}
|
}
|
||||||
// console.log(resObj.url)
|
|
||||||
|
|
||||||
if (resObj.url == "") {
|
if (resObj.url == "") {
|
||||||
let msg = "节目调整,暂不提供服务"
|
let msg = "节目调整,暂不提供服务"
|
||||||
@@ -256,8 +265,6 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
let playURL = resObj.url
|
let playURL = resObj.url
|
||||||
|
|
||||||
// console.dir(playURL, { depth: null })
|
|
||||||
|
|
||||||
// 添加回放参数
|
// 添加回放参数
|
||||||
if (params != "") {
|
if (params != "") {
|
||||||
const resultParams = new URLSearchParams(params);
|
const resultParams = new URLSearchParams(params);
|
||||||
@@ -289,7 +296,6 @@ server.listen(port, async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
printRed(error)
|
printRed(error)
|
||||||
printRed("更新失败")
|
printRed("更新失败")
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printBlue(`当前已运行${hours}小时`)
|
printBlue(`当前已运行${hours}小时`)
|
||||||
@@ -301,7 +307,6 @@ server.listen(port, async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
printRed(error)
|
printRed(error)
|
||||||
printRed("更新失败")
|
printRed("更新失败")
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printGreen("每3小时更新一次")
|
printGreen("每3小时更新一次")
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ const host = process.env.mhost || ""
|
|||||||
const rateType = process.env.mrateType || 3
|
const rateType = process.env.mrateType || 3
|
||||||
// 是否刷新token,可能是导致封号的原因
|
// 是否刷新token,可能是导致封号的原因
|
||||||
// const refreshToken = process.env.mrefreshToken || true
|
// 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 */ }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getStringMD5 } from "./EncryUtils.js";
|
import { getStringMD5 } from "./EncryUtils.js";
|
||||||
import { getddCalcuURL, getddCalcuURL720p } from "./ddCalcuURL.js";
|
import { getddCalcuURL, getddCalcuURL720p } from "./ddCalcuURL.js";
|
||||||
import { printYellow } from "./colorOut.js";
|
import { printDebug, printYellow } from "./colorOut.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} SaltSign
|
* @typedef {object} SaltSign
|
||||||
@@ -80,7 +80,7 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
|||||||
}).then(r => r.json())
|
}).then(r => r.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.dir(respData, { depth: null })
|
printDebug(respData)
|
||||||
// console.log(respData)
|
// console.log(respData)
|
||||||
const url = respData.body.urlInfo?.url
|
const url = respData.body.urlInfo?.url
|
||||||
// console.log(rateType)
|
// console.log(rateType)
|
||||||
@@ -98,7 +98,6 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
|||||||
|
|
||||||
rateType = respData.body.urlInfo?.rateType
|
rateType = respData.body.urlInfo?.rateType
|
||||||
// console.log("清晰度" + rateType)
|
// console.log("清晰度" + rateType)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: resURL,
|
url: resURL,
|
||||||
rateType: parseInt(rateType),
|
rateType: parseInt(rateType),
|
||||||
@@ -144,6 +143,7 @@ async function getAndroidURL720p(pid) {
|
|||||||
headers: headers
|
headers: headers
|
||||||
}).then(r => r.json())
|
}).then(r => r.json())
|
||||||
|
|
||||||
|
printDebug(respData)
|
||||||
// console.dir(respData, { depth: null })
|
// console.dir(respData, { depth: null })
|
||||||
const url = respData.body.urlInfo?.url
|
const url = respData.body.urlInfo?.url
|
||||||
// console.log(rateType)
|
// console.log(rateType)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { debug } from "../config.js"
|
||||||
import { getLogDateTime } from "./time.js"
|
import { getLogDateTime } from "./time.js"
|
||||||
|
|
||||||
function basePrint(color, msg) {
|
function basePrint(color, msg) {
|
||||||
@@ -27,7 +28,12 @@ function printMagenta(msg) {
|
|||||||
function printGrey(msg) {
|
function printGrey(msg) {
|
||||||
basePrint("\x1B[2m", msg)
|
basePrint("\x1B[2m", msg)
|
||||||
}
|
}
|
||||||
|
function printDebug(obj) {
|
||||||
|
if (debug) {
|
||||||
|
console.dir(obj, { depth: null })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
printGreen, printBlue, printRed, printYellow, printMagenta, printGrey
|
printGreen, printBlue, printRed, printYellow, printMagenta, printGrey, printDebug
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
// 睡眠
|
|
||||||
function delay(ms) {
|
function delay(ms) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(resolve, ms)
|
setTimeout(resolve, ms)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { printDebug } from "./colorOut.js";
|
||||||
import { AESencrypt, getStringMD5, RSAencrypt } from "./EncryUtils.js"
|
import { AESencrypt, getStringMD5, RSAencrypt } from "./EncryUtils.js"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +58,7 @@ async function refreshToken(userId, token) {
|
|||||||
// console.log(respResult)
|
// console.log(respResult)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
console.dir(respResult, { depth: null })
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user