mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 15:25:03 +08:00
更新
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { dataList } from "./utils/fetchList.js"
|
||||
import { appendFile, appendFileSync, renameFileSync, writeFile } from "./utils/fileUtil.js"
|
||||
import { updatePlaybackData } from "./utils/playback.js"
|
||||
import { host, token, userId } from "./config.js"
|
||||
import { /* refreshToken as mrefreshToken, */ host, token, userId } from "./config.js"
|
||||
import refreshToken from "./utils/refreshToken.js"
|
||||
import { printBlue, printGreen, printMagenta, printRed, printYellow } from "./utils/colorOut.js"
|
||||
import { printGreen, printRed, printYellow } from "./utils/colorOut.js"
|
||||
|
||||
async function update(hours) {
|
||||
|
||||
@@ -12,6 +12,7 @@ async function update(hours) {
|
||||
let interfacePath = ""
|
||||
// 获取数据
|
||||
const datas = await dataList()
|
||||
printGreen("数据获取成功!")
|
||||
|
||||
if (!(hours % 24)) {
|
||||
// 必须绝对路径
|
||||
@@ -22,10 +23,14 @@ async function update(hours) {
|
||||
|
||||
if (!(hours % 24)) {
|
||||
// 每24小时刷新token
|
||||
if (!(userId == "" || token == "")) {
|
||||
if (userId != "" && token != "") {
|
||||
// if (mrefreshToken) {
|
||||
await refreshToken(userId, token) ? printGreen("token刷新成功") : printRed("token刷新失败")
|
||||
// } else {
|
||||
// printGreen(`跳过token刷新`)
|
||||
// }
|
||||
}
|
||||
appendFile(interfacePath, `#EXTM3U x-tvg-url="${host}/playback.xml" catchup="append" catchup-source="?playbackbegin=\${(b)yyyyMMddHHmmss}&playbackend=\${(e)yyyyMMddHHmmss}"\n`)
|
||||
appendFile(interfacePath, `#EXTM3U x-tvg-url="\${replace}/playback.xml" catchup="append" catchup-source="?playbackbegin=\${(b)yyyyMMddHHmmss}&playbackend=\${(e)yyyyMMddHHmmss}"\n`)
|
||||
}
|
||||
printYellow("正在更新...")
|
||||
// 回放
|
||||
@@ -36,26 +41,22 @@ async function update(hours) {
|
||||
|
||||
// 分类列表
|
||||
for (let i = 0; i < datas.length; i++) {
|
||||
if (!(hours % 24)) {
|
||||
printBlue(`分类###:${datas[i].name}`)
|
||||
}
|
||||
|
||||
const data = datas[i].dataList
|
||||
// 写入节目
|
||||
for (let j = 0; j < data.length; j++) {
|
||||
printMagenta(`${data[j].name}:`)
|
||||
const res = await updatePlaybackData(data[j], playbackFile)
|
||||
if (res) {
|
||||
printGreen(` 节目单更新成功`)
|
||||
} else {
|
||||
printRed(` 节目单更新失败`)
|
||||
}
|
||||
|
||||
await updatePlaybackData(data[j], playbackFile)
|
||||
|
||||
if (!(hours % 24)) {
|
||||
// 写入节目
|
||||
appendFile(interfacePath, `#EXTINF:-1 svg-id="${data[j].name}" svg-name="${data[j].name}" tvg-logo="${data[j].pics.highResolutionH}" group-title="${datas[i].name}",${data[j].name}\n${host}/${data[j].pID}\n`)
|
||||
printGreen(` 节目链接更新成功`)
|
||||
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`)
|
||||
// printGreen(` 节目链接更新成功`)
|
||||
}
|
||||
}
|
||||
if (!(hours % 24)) {
|
||||
printGreen(`分类###:${datas[i].name} 更新完成!`)
|
||||
}
|
||||
}
|
||||
|
||||
appendFileSync(playbackFile, `</tv>\n`)
|
||||
@@ -65,9 +66,9 @@ async function update(hours) {
|
||||
if (!(hours % 24)) {
|
||||
renameFileSync(interfacePath, interfacePath.replace(".bak", ""))
|
||||
}
|
||||
printYellow("更新完成")
|
||||
printYellow("更新完成!")
|
||||
const end = Date.now()
|
||||
printYellow(`本次耗时:${(end - start) / 1000}秒`)
|
||||
printYellow(`本次耗时: ${(end - start) / 1000}秒`)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user