Skip to content

Commit

Permalink
Update autotv.go
Browse files Browse the repository at this point in the history
  • Loading branch information
SunEve committed May 7, 2024
1 parent 34a2e90 commit 0fc9d03
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions autotv.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,45 @@ func gettime() {
fmt.Printf("当前时间已追加到文件 %s\n", filePath)
}

func addxmlpath(addString, filepath string) {
// 读取原始文件内容
content, err := ioutil.ReadFile(filePath)

Check failure on line 64 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: ioutil

Check failure on line 64 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: filePath
if err != nil {
fmt.Println("读取文件时出错:", err)
return
}

lines := strings.Split(string(content), "\n")

Check failure on line 70 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: strings

// 在第一行末尾添加指定字符串
if len(lines) > 0 {
lines[0] += addString
}

// 将修改后的内容写回文件
output := []byte(strings.Join(lines, "\n"))

Check failure on line 78 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: strings
err = ioutil.WriteFile(filePath, output, 0644)

Check failure on line 79 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: ioutil

Check failure on line 79 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: filePath
if err != nil {
fmt.Println("写入文件时出错:", err)
return
}

fmt.Printf("指定字符串已成功添加到文件 %s 的第一行末尾\n", filePath)

Check failure on line 85 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: filePath
}

func main() {
gettime()

fileURL := "https://iitzh.com/cn.m3u"
filePath := "cn.m3u"
fileURL := "https://cdn.jsdelivr.net/gh/BurningC4/Chinese-IPTV@master/TV-IPV4.m3u"
filePath := "public/cn.m3u"

err := downloadFile(fileURL, filePath)
if err != nil {
fmt.Println("下载文件时出错:", err)
return
}

filePath1 := "public/cn11.m3u"

Check failure on line 100 in autotv.go

View workflow job for this annotation

GitHub Actions / build

filePath1 declared but not used
addString := " x-tvg-url=\"https://live.fanmingming.com/e.xml\""
addxmlpath(addString, filepath1)

Check failure on line 102 in autotv.go

View workflow job for this annotation

GitHub Actions / build

undefined: filepath1
}

0 comments on commit 0fc9d03

Please sign in to comment.