添加自定义token close #69,添加更新间隔配置 close #76,close #61
This commit is contained in:
@@ -2,6 +2,7 @@ import { getStringMD5 } from "./EncryUtils.js";
|
||||
import { getddCalcuURL, getddCalcuURL720p } from "./ddCalcuURL.js";
|
||||
import { printDebug, printGreen, printRed, printYellow } from "./colorOut.js";
|
||||
import { fetchUrl } from "./net.js";
|
||||
import { enableHDR } from "../config.js";
|
||||
|
||||
/**
|
||||
* @typedef {object} SaltSign
|
||||
@@ -29,7 +30,7 @@ function getSaltAndSign(md5) {
|
||||
* @param {string} token - 用户token
|
||||
* @param {string} pid - 节目ID
|
||||
* @param {number} rateType - 清晰度
|
||||
* @returns {object} -
|
||||
* @returns {} -
|
||||
*/
|
||||
async function getAndroidURL(userId, token, pid, rateType) {
|
||||
|
||||
@@ -62,11 +63,16 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
||||
const md5 = getStringMD5(str)
|
||||
const result = getSaltAndSign(md5)
|
||||
|
||||
let enableHDRStr = ""
|
||||
if (enableHDR) {
|
||||
enableHDRStr = "&4kvivid=true&2Kvivid=true&vivid=2"
|
||||
}
|
||||
// 请求
|
||||
const baseURL = "https://play.miguvideo.com/playurl/v1/play/playurl"
|
||||
let params = "?sign=" + result.sign + "&rateType=" + rateType
|
||||
+ "&contId=" + pid + "×tamp=" + timestramp + "&salt=" + result.salt
|
||||
+ "&flvEnable=true&super4k=true&h265N=true&4kvivid=true&2Kvivid=true&vivid=2"
|
||||
+ "&flvEnable=true&super4k=true&h265N=true" + enableHDRStr
|
||||
printDebug(`请求链接: ${baseURL + params}`)
|
||||
let respData = await fetchUrl(baseURL + params, {
|
||||
headers: headers
|
||||
})
|
||||
@@ -76,7 +82,8 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
||||
|
||||
params = "?sign=" + result.sign + "&rateType=3"
|
||||
+ "&contId=" + pid + "×tamp=" + timestramp + "&salt=" + result.salt
|
||||
+ "&flvEnable=true&super4k=true&h265N=true&4kvivid=true&2Kvivid=true&vivid=2"
|
||||
+ "&flvEnable=true&super4k=true&h265N=true" + enableHDRStr
|
||||
printDebug(`请求链接: ${baseURL + params}`)
|
||||
respData = await fetchUrl(baseURL + params, {
|
||||
headers: headers
|
||||
})
|
||||
@@ -97,7 +104,7 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
||||
pid = respData.body.content.contId
|
||||
|
||||
// 将URL加密
|
||||
const resURL = getddCalcuURL(url, pid, "android", rateType)
|
||||
const resURL = getddCalcuURL(url, pid, "android", rateType, userId)
|
||||
|
||||
rateType = respData.body.urlInfo?.rateType
|
||||
// console.log("清晰度" + rateType)
|
||||
@@ -113,7 +120,7 @@ async function getAndroidURL(userId, token, pid, rateType) {
|
||||
/**
|
||||
* 旧版高清画质
|
||||
* @param {string} pid - 节目ID
|
||||
* @returns {object} -
|
||||
* @returns {} -
|
||||
*/
|
||||
async function getAndroidURL720p(pid) {
|
||||
// 获取url
|
||||
@@ -138,11 +145,16 @@ async function getAndroidURL720p(pid) {
|
||||
const sign = getStringMD5(md5 + suffix)
|
||||
|
||||
let rateType = 3
|
||||
let enableHDRStr = ""
|
||||
if (enableHDR) {
|
||||
enableHDRStr = "&4kvivid=true&2Kvivid=true&vivid=2"
|
||||
}
|
||||
// 请求
|
||||
const baseURL = "https://play.miguvideo.com/playurl/v1/play/playurl"
|
||||
const params = "?sign=" + sign + "&rateType=" + rateType
|
||||
+ "&contId=" + pid + "×tamp=" + timestramp + "&salt=" + salt + "&flvEnable=true"
|
||||
+ "&flvEnable=true&super4k=true&h265N=true&4kvivid=true&2Kvivid=true&vivid=2"
|
||||
+ "&contId=" + pid + "×tamp=" + timestramp + "&salt=" + salt
|
||||
+ "&flvEnable=true&super4k=true&h265N=true" + enableHDRStr
|
||||
printDebug(`请求链接: ${baseURL + params}`)
|
||||
const respData = await fetchUrl(baseURL + params, {
|
||||
headers: headers
|
||||
})
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { get302URL, getAndroidURL, getAndroidURL720p, printLoginInfo } from "./androidURL.js";
|
||||
import { readFileSync } from "./fileUtil.js";
|
||||
import { host, rateType, token, userId } from "../config.js";
|
||||
import { host, pass, rateType, token, userId } from "../config.js";
|
||||
import { printDebug, printGreen, printGrey, printRed, printYellow } from "./colorOut.js";
|
||||
|
||||
// url缓存 降低请求频率
|
||||
const urlCache = {}
|
||||
|
||||
function interfaceStr(url, headers) {
|
||||
function interfaceStr(url, headers, urlUserId, urlToken) {
|
||||
|
||||
let result = {
|
||||
content: null,
|
||||
@@ -42,6 +42,12 @@ function interfaceStr(url, headers) {
|
||||
}
|
||||
|
||||
let replaceHost = `http://${headers.host}`
|
||||
if (pass != "") {
|
||||
replaceHost = `${replaceHost}/${pass}`
|
||||
}
|
||||
if (urlUserId != userId && urlToken != token) {
|
||||
replaceHost = `${replaceHost}/${urlUserId}/${urlToken}`
|
||||
}
|
||||
|
||||
if (host != "" && (headers["x-real-ip"] || headers["x-forwarded-for"] || host.indexOf(headers.host) != -1)) {
|
||||
replaceHost = host
|
||||
@@ -52,7 +58,7 @@ function interfaceStr(url, headers) {
|
||||
return result
|
||||
}
|
||||
|
||||
async function channel(url) {
|
||||
async function channel(url, urlUserId, urlToken) {
|
||||
|
||||
let result = {
|
||||
code: 200,
|
||||
@@ -95,10 +101,10 @@ async function channel(url) {
|
||||
let resObj = {}
|
||||
try {
|
||||
// 未登录请求720p
|
||||
if (rateType >= 3 && (userId == "" || token == "")) {
|
||||
if (rateType >= 3 && (urlUserId == "" || urlToken == "")) {
|
||||
resObj = await getAndroidURL720p(pid)
|
||||
} else {
|
||||
resObj = await getAndroidURL(userId, token, pid, rateType)
|
||||
resObj = await getAndroidURL(urlUserId, urlToken, pid, rateType)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
@@ -104,7 +104,7 @@ function getEncryptURL(exports, videoURL) {
|
||||
* @param {string} rateType - 清晰度 2:标清 3:高清 4:蓝光
|
||||
* @returns {string} - ddCalcu
|
||||
*/
|
||||
function getddCalcu(puData, programId, clientType, rateType) {
|
||||
function getddCalcu(puData, programId, clientType, rateType, urlUserId) {
|
||||
|
||||
if (puData == null || puData == undefined) {
|
||||
return ""
|
||||
@@ -123,7 +123,7 @@ function getddCalcu(puData, programId, clientType, rateType) {
|
||||
}
|
||||
|
||||
// 不登录标清是默认v
|
||||
const id = userId ? userId : process.env.USERID
|
||||
const id = urlUserId || userId || process.env.USERID || ""
|
||||
if (id) {
|
||||
const words1 = list.android.keys[id[7]]
|
||||
list.android.words[0] = words1
|
||||
@@ -137,7 +137,7 @@ function getddCalcu(puData, programId, clientType, rateType) {
|
||||
if (clientType == "android" && rateType == "2") {
|
||||
words[0] = "v"
|
||||
}
|
||||
if (userId.length > 3 && userId.length <= 8) {
|
||||
if (id.length > 3 && id.length <= 8) {
|
||||
words[0] = "e"
|
||||
}
|
||||
const puDataLength = puData.length
|
||||
@@ -172,7 +172,7 @@ function getddCalcu(puData, programId, clientType, rateType) {
|
||||
* @param {string} rateType - 清晰度 2:标清 3:高清 4:蓝光
|
||||
* @returns {string} - 加密链接
|
||||
*/
|
||||
function getddCalcuURL(puDataURL, programId, clientType, rateType) {
|
||||
function getddCalcuURL(puDataURL, programId, clientType, rateType, urlUserId) {
|
||||
|
||||
if (puDataURL == null || puDataURL == undefined) {
|
||||
return ""
|
||||
@@ -191,7 +191,7 @@ function getddCalcuURL(puDataURL, programId, clientType, rateType) {
|
||||
}
|
||||
|
||||
const puData = puDataURL.split("&puData=")[1]
|
||||
const ddCalcu = getddCalcu(puData, programId, clientType, rateType)
|
||||
const ddCalcu = getddCalcu(puData, programId, clientType, rateType, urlUserId)
|
||||
const suffix = list[clientType].suffix
|
||||
|
||||
return `${puDataURL}&ddCalcu=${ddCalcu}${suffix}`
|
||||
|
||||
@@ -58,9 +58,9 @@ async function updateTV(hours) {
|
||||
await updatePlaybackData(data[j], playbackFile)
|
||||
|
||||
// 写入节目
|
||||
appendFile(interfacePath, `#EXTINF:-1 tvg-id="${data[j].name}" tvg-name="${data[j].name}" tvg-logo="${data[j].pics.highResolutionH}" group-title="${datas[i].name}",${data[j].name}\n\${replace}/${pass == "" ? "" : pass + "/"}${data[j].pID}\n`)
|
||||
appendFile(interfacePath, `#EXTINF:-1 tvg-id="${data[j].name}" tvg-name="${data[j].name}" tvg-logo="${data[j].pics.highResolutionH}" group-title="${datas[i].name}",${data[j].name}\n\${replace}/${data[j].pID}\n`)
|
||||
// txt
|
||||
appendFile(interfaceTXTPath, `${data[j].name},\${replace}/${pass == "" ? "" : pass + "/"}${data[j].pID}\n`)
|
||||
appendFile(interfaceTXTPath, `${data[j].name},\${replace}/${data[j].pID}\n`)
|
||||
// printGreen(` 节目链接更新成功`)
|
||||
}
|
||||
printGreen(`分类###:${datas[i].name} 更新完成!`)
|
||||
@@ -142,8 +142,8 @@ async function updatePE(hours) {
|
||||
}
|
||||
const competitionDesc = `${data.competitionName} ${pkInfoTitle} ${replay.name} ${timeStr}`
|
||||
// 写入赛事
|
||||
appendFileSync(interfacePath, `#EXTINF:-1 tvg-id="${pkInfoTitle}" tvg-name="${competitionDesc}" tvg-logo="${data.competitionLogo}" group-title="体育-${relativeDate}",${competitionDesc}\n\${replace}/${pass == "" ? "" : pass + "/"}${replay.pID}\n`)
|
||||
appendFileSync(interfaceTXTPath, `${competitionDesc},\${replace}/${pass == "" ? "" : pass + "/"}${replay.pID}\n`)
|
||||
appendFileSync(interfacePath, `#EXTINF:-1 tvg-id="${pkInfoTitle}" tvg-name="${competitionDesc}" tvg-logo="${data.competitionLogo}" group-title="体育-${relativeDate}",${competitionDesc}\n\${replace}/${replay.pID}\n`)
|
||||
appendFileSync(interfaceTXTPath, `${competitionDesc},\${replace}/${replay.pID}\n`)
|
||||
}
|
||||
}
|
||||
continue
|
||||
@@ -156,12 +156,12 @@ async function updatePE(hours) {
|
||||
}
|
||||
const competitionDesc = `${data.competitionName} ${pkInfoTitle} ${live.name} ${live.startTimeStr.substring(11, 16)}`
|
||||
// 写入赛事
|
||||
appendFileSync(interfacePath, `#EXTINF:-1 tvg-id="${pkInfoTitle}" tvg-name="${competitionDesc}" tvg-logo="${data.competitionLogo}" group-title="体育-${relativeDate}",${competitionDesc}\n\${replace}/${pass == "" ? "" : pass + "/"}${live.pID}\n`)
|
||||
appendFileSync(interfaceTXTPath, `${competitionDesc},\${replace}/${pass == "" ? "" : pass + "/"}${live.pID}\n`)
|
||||
appendFileSync(interfacePath, `#EXTINF:-1 tvg-id="${pkInfoTitle}" tvg-name="${competitionDesc}" tvg-logo="${data.competitionLogo}" group-title="体育-${relativeDate}",${competitionDesc}\n\${replace}/${live.pID}\n`)
|
||||
appendFileSync(interfaceTXTPath, `${competitionDesc},\${replace}/${live.pID}\n`)
|
||||
}
|
||||
} catch (error) {
|
||||
printRed(`${data.mgdbId} ${pkInfoTitle} 更新失败`)
|
||||
printRed(error)
|
||||
printYellow(`${data.mgdbId} ${pkInfoTitle} 更新失败 此警告不影响正常使用 可忽略`)
|
||||
printYellow(error)
|
||||
}
|
||||
}
|
||||
printGreen(`日期 ${date} 更新完成!`)
|
||||
|
||||
Reference in New Issue
Block a user