From 248b10f85d4941abf4c24216fcf0d6a8ad7584dc Mon Sep 17 00:00:00 2001 From: test Date: Wed, 17 Sep 2025 12:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F2=E5=B0=8F=E6=97=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=EF=BC=8C=E5=A4=AE=E8=A7=86=E8=8A=82=E7=9B=AE?= =?UTF-8?q?=E5=8D=95=E4=BB=8Ecntv=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .workflow/fetch.yml | 2 +- fetchURLByAndroid720p.js | 13 +----------- utils/datas.js | 26 +++++++++++++++++++++++- utils/playback.js | 43 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/.workflow/fetch.yml b/.workflow/fetch.yml index f88d606..2414f01 100644 --- a/.workflow/fetch.yml +++ b/.workflow/fetch.yml @@ -8,7 +8,7 @@ triggers: precise: - main schedule: - - cron: '* 0 */3 * * ? *' + - cron: '* 0 */2 * * ? *' variables: global: - GITHUB_TOKEN diff --git a/fetchURLByAndroid720p.js b/fetchURLByAndroid720p.js index c1d5af1..2225cc9 100644 --- a/fetchURLByAndroid720p.js +++ b/fetchURLByAndroid720p.js @@ -1,16 +1,11 @@ import { dataList } from "./utils/fetchList.js" import { getAndroidURL720p } from "./utils/androidURL.js" -import refreshToken from "./utils/refreshToken.js" import { appendFile, writeFile } from "./utils/fileUtil.js" import { updatePlaybackData } from "./utils/playback.js" async function fetchURLByAndroid() { - const userId = process.env.USERID - const token = process.env.MIGU_TOKEN - - const date = new Date() - const start = date.getTime() + const start = Date.now() // 必须绝对路径 const path = process.cwd() + '/interface.txt' @@ -26,13 +21,7 @@ async function fetchURLByAndroid() { `\n` + `\n`) - if (!date.getHours()) { - // 0点刷新token - await refreshToken(userId, token) ? console.log("token刷新成功") : console.log("token刷新失败") - } - // 写入开头 - // appendFile(aptvPath, `#EXTM3U x-tvg-url="https://gitee.com/dream-deve/migu_video/raw/main/playback.xml" catchup="append" catchup-source="&playbackbegin=\${(b)yyyyMMddHHmmss}&playbackend=\${(e)yyyyMMddHHmmss}"\n`) appendFile(path, `#EXTM3U x-tvg-url="https://develop202.github.io/migu_video/playback.xml,https://raw.githubusercontent.com/develop202/migu_video/refs/heads/main/playback.xml,https://gh-proxy.com/https://raw.githubusercontent.com/develop202/migu_video/refs/heads/main/playback.xml" catchup="append" catchup-source="&playbackbegin=\${(b)yyyyMMddHHmmss}&playbackend=\${(e)yyyyMMddHHmmss}"\n`) // 分类列表 diff --git a/utils/datas.js b/utils/datas.js index d924b00..390f8a2 100644 --- a/utils/datas.js +++ b/utils/datas.js @@ -1,3 +1,27 @@ +// 回放 +const cntvNames = { + "CCTV1综合": "cctv1", + "CCTV2财经": "cctv2", + "CCTV3综艺": "cctv3", + "CCTV4中文国际": "cctv4", + "CCTV5体育": "cctv5", + "CCTV5+体育赛事": "cctv5plus", + "CCTV6电影": "cctv6", + "CCTV7国防军事": "cctv7", + "CCTV8电视剧": "cctv8", + "CCTV9纪录": "cctv9", + "CCTV10科教": "cctv10", + "CCTV11戏曲": "cctv11", + "CCTV12社会与法": "cctv12", + "CCTV13新闻": "cctv13", + "CCTV14少儿": "cctvchild", + "CCTV15音乐": "cctv15", + "CCTV17农业农村": "cctv17", + "CCTV4欧洲": "cctveurope", + "CCTV4美洲": "cctvamerica", +} + + // 频道信息 const channelName = [ { @@ -823,4 +847,4 @@ const changedDdCalcu = { }, } -export { changedDdCalcu, channelName } +export { changedDdCalcu, channelName, cntvNames } diff --git a/utils/playback.js b/utils/playback.js index 1c66813..4d43041 100644 --- a/utils/playback.js +++ b/utils/playback.js @@ -1,6 +1,7 @@ import axios from "axios" import { getDateString, getDateTimeString } from "./time.js" import { appendFileSync } from "./fileUtil.js" +import { cntvNames } from "./datas.js" async function getPlaybackData(programId) { @@ -10,7 +11,7 @@ async function getPlaybackData(programId) { return resp.body?.program[0]?.content } -async function updatePlaybackData(program, filePath) { +async function updatePlaybackDataByMigu(program, filePath) { // 今日节目数据 const playbackData = await getPlaybackData(program.pID) if (!playbackData) { @@ -36,5 +37,45 @@ async function updatePlaybackData(program, filePath) { } return true } + +async function updatePlaybackDataByCntv(program, filePath) { + // 今日节目数据 + const date = new Date() + const today = getDateString(date) + const cntvName = cntvNames[program.name] + const resp = await axios.get(`https://api.cntv.cn/epg/epginfo3?serviceId=shiyi&d=${today}&c=${cntvName}`).then(r => r.data) + + const playbackData = resp[cntvName]?.program + if (!playbackData) { + return false + } + // 写入频道信息 + appendFileSync(filePath, + ` \n` + + ` ${program.name}\n` + + ` \n` + ) + + // 写入节目信息 + for (let i = 0; i < playbackData.length; i++) { + // 特殊字符转义 + const contName = playbackData[i].t.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'"); + + appendFileSync(filePath, + ` \n` + + ` ${contName}\n` + + ` \n` + ) + } + return true +} + +async function updatePlaybackData(program, filePath) { + if (cntvNames[program.name]) { + return updatePlaybackDataByCntv(program, filePath) + } + return updatePlaybackDataByMigu(program, filePath) + +} export { updatePlaybackData }