This commit is contained in:
test
2025-12-02 17:24:50 +08:00
parent 81781bea7f
commit 290574b945
14 changed files with 220 additions and 260 deletions

View File

@@ -206,7 +206,8 @@ async function getAndroidURL(userId, token, pid, rateType) {
return {
url: resURL,
rateType: parseInt(rateType)
rateType: parseInt(rateType),
content: respData
}
}
@@ -265,7 +266,8 @@ async function getAndroidURL720p(pid) {
return {
url: resURL,
rateType: parseInt(rateType)
rateType: parseInt(rateType),
content: respData
}
}

View File

@@ -1,26 +1,31 @@
import { getLogDateTime } from "./time.js"
function basePrint(color, msg) {
console.log(`${color}%s %s\x1B[0m`, `[${getLogDateTime(new Date())}]`, msg)
}
function printRed(msg) {
console.log('\x1B[31m%s\x1B[0m', msg)
basePrint("\x1B[31m", msg)
}
function printGreen(msg) {
console.log('\x1B[32m%s\x1B[0m', msg)
basePrint("\x1B[32m", msg)
}
function printYellow(msg) {
console.log('\x1B[33m%s\x1B[0m', msg)
basePrint("\x1B[33m", msg)
}
function printBlue(msg) {
console.log('\x1B[34m%s\x1B[0m', msg)
basePrint("\x1B[33m", msg)
}
function printMagenta(msg) {
console.log('\x1B[35m%s\x1B[0m', msg)
basePrint("\x1B[35m", msg)
}
function printGrey(msg) {
console.log('\x1B[2m%s\x1B[0m', msg)
basePrint("\x1B[2m", msg)
}
export {

View File

@@ -9,64 +9,41 @@ function delay(ms) {
// 获取分类集合
async function cateList() {
try {
const resp = await axios.get("https://program-sc.miguvideo.com/live/v2/tv-data/1ff892f2b5ab4a79be6e25b69d2f5d05")
let liveList = resp.data.body.liveList
// 热门内容重复
liveList = liveList.filter((item) => {
return item.name != "热门"
})
const resp = await axios.get("https://program-sc.miguvideo.com/live/v2/tv-data/1ff892f2b5ab4a79be6e25b69d2f5d05")
let liveList = resp.data.body.liveList
// 热门内容重复
liveList = liveList.filter((item) => {
return item.name != "热门"
})
// 央视作为首个分类
liveList.sort((a, b) => {
if (a.name === "央视") return -1;
if (b.name === "央视") return 1
return 0
})
// 央视作为首个分类
liveList.sort((a, b) => {
if (a.name === "央视") return -1;
if (b.name === "央视") return 1
return 0
})
return liveList
} catch (error) {
throw error
}
return liveList
}
// 所有数据
async function dataList() {
try {
let cates = await cateList()
let cates = await cateList()
for (let cate in cates) {
try {
const resp = await axios.get("https://program-sc.miguvideo.com/live/v2/tv-data/" + cates[cate].vomsID)
cates[cate].dataList = resp.data.body.dataList
} catch (error) {
cates[cate].dataList = [];
}
for (let cate in cates) {
try {
const resp = await axios.get("https://program-sc.miguvideo.com/live/v2/tv-data/" + cates[cate].vomsID)
cates[cate].dataList = resp.data.body.dataList
} catch (error) {
cates[cate].dataList = [];
}
// 去除重复节目
cates = uniqueData(cates)
// console.dir(cates, { depth: null })
// console.log(cates)
return cates
} catch (error) {
throw error
}
}
// 获取电视链接
async function getUrlInfo(contId) {
try {
const resp = await axios.get(`https://webapi.miguvideo.com/gateway/playurl/v2/play/playurlh5?contId=${contId}&rateType=999&clientId=-&startPlay=true&xh265=false&channelId=0131_200300220100002`)
// console.log(resp.data.body.urlInfo.url)
// console.log(resp.data)
if (resp.data?.body?.urlInfo?.url) {
return resp.data.body.urlInfo.url
}
return ""
} catch (error) {
throw error
}
// 去除重复节目
cates = uniqueData(cates)
// console.dir(cates, { depth: null })
// console.log(cates)
return cates
}
// 对data的dataList去重
@@ -120,4 +97,4 @@ function uniqueData(liveList) {
return liveList
}
export { cateList, dataList, getUrlInfo, delay }
export { cateList, dataList, delay }

View File

@@ -1,38 +0,0 @@
import puppeteer from 'puppeteer';
// 打开浏览器
async function get_browser(path) {
return await puppeteer.launch({
args: [
"--no-sandbox"
]
});
}
// 创建页面
async function get_page(browser) {
return await browser.newPage();
}
// 获取url
async function get_url(page, video_id) {
let url = ""
let base_url = ""
page.on("requestfinished", request => {
if (request.url().startsWith("https://hlszymgsplive.miguvideo.com/")) {
url = request.url()
}
if (request.url().startsWith("https://h5live.gslb.cmvideo.cn/")) {
base_url = request.url()
}
})
await page.goto('https://m.miguvideo.com/m/liveDetail/' + video_id, { waitUntil: "networkidle2" });
return url, base_url
}
// 关闭浏览器
async function close_browser(browser) {
await browser.close()
}
export { get_browser, get_page, get_url, close_browser }

27
utils/net.js Normal file
View File

@@ -0,0 +1,27 @@
import os from "os"
function getLocalIPv(ver = 4) {
const ips = []
const inter = os.networkInterfaces()
// console.dir(inter, { depth: null })
for (let net in inter) {
// console.dir(net, { depth: null })
// console.log()
for (let netPort of inter[net]) {
// netPort = inter[net][netPort]
// console.dir(netPort, { depth: null })
if (netPort.family === `IPv${ver}`) {
// console.dir(netPort, { depth: null })
ips.push(netPort.address)
}
}
}
// console.log()
// console.dir(ips, { depth: null })
return ips
}
export {
getLocalIPv
}

View File

@@ -16,4 +16,8 @@ function getDateTimeStr(date) {
`${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}:${String(date.getSeconds()).padStart(2, "0")}`
}
export { getDateString, getTimeString, getDateTimeString, getDateTimeStr }
function getLogDateTime(date) {
return `${getDateTimeStr(date)}:${String(date.getMilliseconds()).padStart(3, "0")}`
}
export { getDateString, getTimeString, getDateTimeString, getDateTimeStr, getLogDateTime }