package main

import ( "fmt" "net/http" "time" )

func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) }

func handler(w http.ResponseWriter, r *http.Request) { error_reporting(0) w.Header().Set("Content-Type", "text/plain; charset=UTF-8") timezone, _ := time.LoadLocation("Asia/Shanghai") time.Local = timezone key := "@.@@.@@.@" id := r.URL.Query().Get("id") typ := r.URL.Query().Get("type") json := []struct { ID string json:"id" Name string json:"name" Time int json:"time" LiveID string json:"liveid" }{ {"1", "浙江卫视", int((time.Now().Unix() + 3370280619) / 3), "ZJTV-"}, {"2", "湖南卫视", int((time.Now().Unix() + 3369612714) / 3), "HNTV-"}, {"3", "江苏卫视", int((time.Now().Unix() + 3369612732) / 3), "JSTV-"}, {"4", "东方卫视", int((time.Now().Unix() + 3369441637) / 3), "SHDFTV-"}, {"5", "北京卫视", int((time.Now().Unix() + 3369711289) / 3), "BJTV-"}, {"6", "河北卫视", int((time.Now().Unix() + 5058660492) / 4), "HEBTV-"}, {"7", "辽宁卫视", int((time.Now().Unix() + 3369418301) / 3), "LNTV-"}, {"8", "安徽卫视", int((time.Now().Unix() + 3369417422) / 3), "AHTV-"}, }

if typ == "txt" {
	fmt.Fprintln(w, "天津万视达,#genre#")
	for _, item := range json {
		fmt.Fprintf(w, "%s,http://%s?id=%s\n", item.Name, r.Host, item.ID)
	}
} else if typ == "m3u" {
	fmt.Fprintln(w, "#EXTM3U")
	for _, item := range json {
		fmt.Fprintf(w, "#EXTINF:-1 tvg-id=\"%s\" tvg-name=\"%s\" tvg-logo=\"%s\" group-title=\"天津万视达\",%s\n", item.ID, item.Name, item.Logo, item.Name)
		fmt.Fprintf(w, "http://%s?id=%s\n", r.Host, item.ID)
	}
} else if typ == "json" {
	list := make([]map[string]interface{}, 0)
	for _, item := range json {
		list = append(list, map[string]interface{}{
			"name": item.Name,
			"url":  fmt.Sprintf("http://%s?id=%s", r.Host, item.ID),
		})
	}
	result := map[string]interface{}{
		"AppStore": "http://" + r.Host + "/",
		"CreateBy": "庸俗的时光",
		"title":    "天津万视达",
		"UpDate":   time.Now().Format("2006-01-02 15:04:05"),
		"data":     list,
	}
	fmt.Fprintf(w, "%v", result)
} else {
	if id == "" {
		fmt.Fprintln(w, "If you need to access txt, please add type=txt")
		fmt.Fprintf(w, "Example: http://%s?type=txt\n", r.Host)
		fmt.Fprintln(w, "If you need to access json, please add type=json")
		fmt.Fprintf(w, "Example: http://%s?type=json\n", r.Host)
		fmt.Fprintln(w, "Enjoy using")
	} else {
		var playURL string
		for _, item := range json {
			if item.ID == id {
				playURL = item.LiveID
				break
			}
		}

		stream := "http://live-bd.wisetv.com.cn/LSTV/"
		if id == "6" {
			stream = "http://live-tx.wisetv.com.cn/LSTV/"
		}

		timestamp := time.Now().Unix()
		current := "#EXTM3U\n"
		current += "#EXT-X-VERSION:3\n"
		current += "#EXT-X-TARGETDURATION:3\n"
		current += "#EXT-X-MEDIA-SEQUENCE:" + fmt.Sprintf("%d\n", timestamp)
		for i := 0; i < 3; i++ {
			timematch := timestamp*10
			timefirst := time.Unix(timematch, 0).Format("2006010215")
			current += "#EXTINF:3,\n"
			current += stream + playURL + fmt.Sprintf("%d.ts\n", timestamp)
			timestamp++
		}
		fmt.Fprint(w, current)
	}
}
phperror_reporting0;headerContent-type textplain; charset=UTF-8;date_default_timezone_setAsiaShanghai;$key=________;$id = isset$_GETid$_GETid;$type = $_GETtype;$json = array arrayid=1name=浙江卫视time=

原文地址: https://www.cveoy.top/t/topic/ivoM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录