MCPcopy Create free account
hub / github.com/develop202/migu_video / fetchURLByAndroid720p

Function fetchURLByAndroid720p

fetchURLByAndroid720p.js:7–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { printBlue, printGreen, printRed, printYellow } from "./utils/colorOut.js"
6
7async function fetchURLByAndroid720p() {
8
9 const start = Date.now()
10
11 // 获取数据
12 const datas = await dataList()
13
14 printGreen("数据获取成功!")
15 // 必须绝对路径
16 const path = process.cwd() + '/interface.txt.bak'
17 // 创建写入空内容
18 writeFile(path, "")
19
20 printYellow("正在更新...")
21 // 回放
22 const playbackFile = process.cwd() + '/playback.xml.bak'
23 writeFile(playbackFile,
24 `<?xml version="1.0" encoding="UTF-8"?>\n` +
25 `<tv generator-info-name="Tak" generator-info-url="https://github.com/develop202/migu_video">\n`)
26
27 // 写入开头
28 appendFile(path, `#EXTM3U x-tvg-url="https://gh-proxy.com/https://raw.githubusercontent.com/develop202/migu_video/refs/heads/main/playback.xml,https://hk.gh-proxy.org/raw.githubusercontent.com/develop202/migu_video/refs/heads/main/playback.xml,https://develop202.github.io/migu_video/playback.xml,https://raw.githubusercontents.com/develop202/migu_video/refs/heads/main/playback.xml" catchup="append" catchup-source="&playbackbegin=\${(b)yyyyMMddHHmmss}&playbackend=\${(e)yyyyMMddHHmmss}"\n`)
29
30 // 分类列表
31 for (let i = 0; i < datas.length; i++) {
32
33 const data = datas[i].dataList
34
35 printBlue(`开始更新分类###: ${datas[i].name}`)
36 // 写入节目
37 for (let j = 0; j < data.length; j++) {
38
39 await updatePlaybackData(data[j], playbackFile)
40
41 // 获取链接
42 const resObj = await getAndroidURL720p(data[j].pID)
43
44 if (resObj.url != "") {
45 let z = 1
46 while (z <= 6) {
47 if (z >= 2) {
48 printYellow(`${data[j].name} 获取失败,正在第${z - 1}次重试`)
49 }
50 const obj = await fetch(`${resObj.url}`, {
51 method: "GET",
52 redirect: "manual"
53 })
54
55 const location = obj.headers.get("Location")
56
57
58 if (location == "" || location == undefined || location == null) {
59 continue
60 }
61 if (!location.startsWith("http://bofang")) {
62 resObj.url = location
63 break
64 }

Callers 1

Calls 12

dataListFunction · 0.90
printGreenFunction · 0.90
writeFileFunction · 0.90
printYellowFunction · 0.90
appendFileFunction · 0.90
printBlueFunction · 0.90
updatePlaybackDataFunction · 0.90
getAndroidURL720pFunction · 0.90
delayFunction · 0.90
printRedFunction · 0.90
appendFileSyncFunction · 0.90
renameFileSyncFunction · 0.90

Tested by

no test coverage detected