mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 07:18:22 +08:00
更新
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { dataList } from "./utils/fetchList.js"
|
||||
import { dataList, delay } from "./utils/fetchList.js"
|
||||
import { getAndroidURL720p } from "./utils/androidURL.js"
|
||||
import { appendFile, appendFileSync, renameFileSync, writeFile } from "./utils/fileUtil.js"
|
||||
import { updatePlaybackData } from "./utils/playback.js"
|
||||
import { printBlue, printGreen, printMagenta, printRed, printYellow } from "./utils/colorOut.js"
|
||||
import { printBlue, printGreen, printRed, printYellow } from "./utils/colorOut.js"
|
||||
|
||||
async function fetchURLByAndroid720p() {
|
||||
|
||||
@@ -10,11 +10,14 @@ async function fetchURLByAndroid720p() {
|
||||
|
||||
// 获取数据
|
||||
const datas = await dataList()
|
||||
|
||||
printGreen("数据获取成功!")
|
||||
// 必须绝对路径
|
||||
const path = process.cwd() + '/interface.txt.bak'
|
||||
// 创建写入空内容
|
||||
writeFile(path, "")
|
||||
|
||||
printYellow("正在更新...")
|
||||
// 回放
|
||||
const playbackFile = process.cwd() + '/playback.xml.bak'
|
||||
writeFile(playbackFile,
|
||||
@@ -26,30 +29,50 @@ async function fetchURLByAndroid720p() {
|
||||
|
||||
// 分类列表
|
||||
for (let i = 0; i < datas.length; i++) {
|
||||
printBlue(`分类###:${datas[i].name}`)
|
||||
|
||||
const data = datas[i].dataList
|
||||
|
||||
printBlue(`开始更新分类###: ${datas[i].name}`)
|
||||
// 写入节目
|
||||
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)
|
||||
|
||||
// 获取链接
|
||||
const resObj = await getAndroidURL720p(data[j].pID)
|
||||
if (resObj.url == "") {
|
||||
printRed(` 节目调整,暂不提供服务`)
|
||||
continue
|
||||
|
||||
if (resObj.url != "") {
|
||||
let z = 1
|
||||
while (z <= 6) {
|
||||
if (z >= 2) {
|
||||
printYellow(`${data[j].name} 获取失败,正在第${z - 1}次重试`)
|
||||
}
|
||||
const obj = await fetch(`${resObj.url}`, {
|
||||
method: "GET",
|
||||
redirect: "manual"
|
||||
})
|
||||
|
||||
const location = obj.headers.get("Location")
|
||||
if (location.startsWith("http://hlsz")) {
|
||||
resObj.url = location
|
||||
break
|
||||
}
|
||||
if (z == 6) {
|
||||
resObj.url = ""
|
||||
} else {
|
||||
await delay(150)
|
||||
}
|
||||
z++
|
||||
}
|
||||
}
|
||||
|
||||
if (resObj.url == "") {
|
||||
printRed(`${data[j].name} 更新失败`)
|
||||
continue
|
||||
}
|
||||
// 写入节目
|
||||
appendFile(path, `#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${resObj.url}\n`)
|
||||
printGreen(` 节目链接更新成功`)
|
||||
printGreen(`${data[j].name} 更新成功!`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +81,7 @@ async function fetchURLByAndroid720p() {
|
||||
renameFileSync(playbackFile, playbackFile.replace(".bak", ""))
|
||||
renameFileSync(path, path.replace(".bak", ""))
|
||||
const end = Date.now()
|
||||
printYellow(`本次耗时:${(end - start) / 1000}秒`)
|
||||
printYellow(`本次耗时: ${(end - start) / 1000}秒`)
|
||||
}
|
||||
|
||||
fetchURLByAndroid720p()
|
||||
|
||||
Reference in New Issue
Block a user